swagger-parser icon indicating copy to clipboard operation
swagger-parser copied to clipboard

Error message has no line number or hint

Open AlexHolly opened this issue 5 years ago • 1 comments

Is there a way to show which key is wrong, in the following example line 2 "should not have additionalProperty: inf" or any line number would be good.

Tested with: https://apidevtools.org/swagger-parser/online/

API

openapi: 3.0.0
inf:
  description: Example Api
  version: 1.0.0
  title: Mini Example
servers:
  - url: 'https://petstore.swagger.io/v2'
paths: {}
[object Object] is not a valid Openapi API definition

Error: [object Object] is not a valid Openapi API definition
    at https://apidevtools.org/swagger-parser/online/js/bundle.js:1143:27

SyntaxError: [object Object] is not a valid Openapi API definition
    at Function.syntax (https://apidevtools.org/swagger-parser/dist/swagger-parser.min.js:25:95937)
    at https://apidevtools.org/swagger-parser/dist/swagger-parser.min.js:9:2484

AlexHolly avatar Jun 06 '19 22:06 AlexHolly

Removing these lines helps. https://github.com/APIDevTools/swagger-parser/blob/c77ae7dfa9d0b7fa0f118f32f705effdf9542592/lib/index.js#L64-L66 https://github.com/APIDevTools/swagger-parser/blob/c77ae7dfa9d0b7fa0f118f32f705effdf9542592/lib/index.js#L83-L85

Also need to add some checks for info schema.info && https://github.com/APIDevTools/swagger-parser/blob/c77ae7dfa9d0b7fa0f118f32f705effdf9542592/lib/index.js#L71 https://github.com/APIDevTools/swagger-parser/blob/c77ae7dfa9d0b7fa0f118f32f705effdf9542592/lib/index.js#L90

AlexHolly avatar Jul 24 '19 23:07 AlexHolly