APIDevTools / swagger-parser

Swagger 2.0 and OpenAPI 3.0 parser/validator
https://apitools.dev/swagger-parser
MIT License
1.09k stars 154 forks source link

Updated known-errors to make CI work again #165

Closed seriousme closed 3 years ago

seriousme commented 3 years ago

Running npm run node:test failed because some API's fail to pass validation. This PR assumes that these are all bugs in specifications and not in swagger-parser.

It should make CI on swagger-parser succeed again so we can continue its development. (esp. adding support for v3.1 ;-))

Kind regards, Hans

philsturgeon commented 3 years ago

Thank you @seriousme, but we've still got some errors. I got the Actions running again by adding on: pull_request but they're kicking up some errors now.

seriousme commented 3 years ago

I just checked:

642 apis failed of which:

631 apis (mostly AWS + Azure) fail because of a bug in YAML parsing:

version: 2015-09-21

is now parsed as an object instead of a string , the error message is: "Expected type string but found type object at #/info/version"

adyen.com:MarketPayNotificationService is a 3.1 spec :-) see: https://api.apis.guru/v2/specs/adyen.com/MarketPayNotificationService/6/openapi.yaml

4 gitHub apis fail because of a MissingPointerError, errormessage is Token "expires_at" does not exist. example: 'https://api.apis.guru/v2/specs/github.com/ghes-2.18/1.1.4/openapi.yaml',

3 gitHub apis fail because of a MissingPointerError, errormessage is Token "0" does not exist. example: 'https://api.apis.guru/v2/specs/github.com/ghes-2.22/1.1.4/openapi.yaml',

3 other api's fail because of various errors (probably bugs in their spec):

Hope this helps ;-)

Hans

seriousme commented 3 years ago

Did some more digging:

YAML 1.2 specifies that 2015-09-21 should be read as a date. Hence JS-Yaml makes a date object out of it.

The problem lies in:

return yaml.load(data);

at https://github.com/APIDevTools/json-schema-ref-parser/blob/7a899bcb41820c883e2d434e6bed675604f4d32c/lib/parsers/yaml.js#L48

if you replace this by:

return yaml.load(data, {schema: yaml.JSON_SCHEMA });

Then it should work again for these cases :-) I have tested this using https://www.npmjs.com/package/@seriousme/openapi-schema-validator and it works there. So it should work here as well. This also solved the github cases !

Kind regards, Hans