Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Add sourcemaps to some swagger validation errors #493

Merged
merged 1 commit into from
Jun 22, 2020
Merged

Conversation

kylef
Copy link
Member

@kylef kylef commented Jun 19, 2020

I noticed source map was missing for one particular error message:

error: (4) Validation failed. Property 'authorizerId' listed as required but does not exist in '/definitions/authorizerInfoType'

The error was as follows:

{
  stack: "SyntaxError: Validation failed. Property 'authorizerId' listed as required but does not exist in '/definitions/authorizerInfoType'\n" +
    '    at validateRequiredPropertiesExist (/Users/kyle/Projects/apiaryio/api-elements.js/node_modules/swagger-parser/lib/validators/spec.js:338:19)\n' +
    '    at validateSpec (/Users/kyle/Projects/apiaryio/api-elements.js/node_modules/swagger-parser/lib/validators/spec.js:37:5)\n' +
    '    at SwaggerParser.validate (/Users/kyle/Projects/apiaryio/api-elements.js/node_modules/swagger-parser/lib/index.js:172:7)',
  message: "Validation failed. Property 'authorizerId' listed as required but does not exist in '/definitions/authorizerInfoType'",
  toJSON: [Function: toJSON],
  name: 'SyntaxError',
  toString: [Function: toString]
}

Given the JSON path is in the error message I was able to extract it out and attach sourcemaps via it.

@kylef kylef added bug Something isn't working openapi2 labels Jun 19, 2020
@kylef kylef requested a review from opichals June 22, 2020 09:03
Copy link
Contributor

@opichals opichals left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

@kylef kylef merged commit f1d81c3 into master Jun 22, 2020
@kylef kylef deleted the kylef/oas2-sm branch June 22, 2020 10:31
kylef added a commit that referenced this pull request Jun 22, 2020
kylef added a commit that referenced this pull request Jun 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working openapi2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants