Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect property path on validation errors #63

Open
pmeinhardt opened this issue Jun 15, 2016 · 0 comments
Open

Incorrect property path on validation errors #63

pmeinhardt opened this issue Jun 15, 2016 · 0 comments

Comments

@pmeinhardt
Copy link

pmeinhardt commented Jun 15, 2016

Hi, I am currently using swaggerize-express/-routes in a client project and find it to be really useful.

However, I have noticed that the property path is set incorrectly for nested objects on input validation. I.e. I have a swagger.json which contains sth. like the following (following the JSON API spec):

{
  "consumes": [ "application/json" ],
  "produces": [ "application/json" ],
  // …
  "parameters": [{
    "name": "body",
    "in": "body",
    "required": true,
    "schema": {
      "type": "object",
      "required": [ "data" ],
      "properties": {
         "data": {
            "type": "object",
            "required": [ "type", "attributes" ],
            "properties": {
                "type": { "type": "string" },
                "attributes": { "type": "object", }
            }
         }
      }
    }
  }]
}

So any input JSON object is required to have data.type (string) and data.attributes (object).

When a validation for a nested property fails though, the "path" provided in the error details contains only the property name, not the full path – i.e. type instead of data.type or email instead of data.attributes.email.

This is the source line that looks like the chief culprit:

detail.path = parameter.name;

Is there a particular reason for replacing the original detail.path with the parameter.name?

Cheers and thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant