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

feat: support OpenAPI 3.1 #171

Closed LoicBoursin closed 2 years ago

LoicBoursin commented 3 years ago

This adds the support for OpenAPI 3.1 #169.

philsturgeon commented 3 years ago

Got some conflicts on this now we've merged other updates.

LoicBoursin commented 3 years ago

I have reset my branch to be in sync with main after your merges then cherry-picked my commit. Let me know if everything is OK now

OliverDudgeon commented 3 years ago

Any movement here?

philsturgeon commented 3 years ago

Right! After a month of cycling around mountains and deserts and not being able to get a laptop out for anything particularly focused, I am back at it.

This repo has been in a bit of a bad way, had a lot of errors in the build, but those have been fixed with 10.0.3 (npm run test:node at least). If you could pull main, fix the conflict (popped this down to lockfileVersion 1 for now) then run it again, you might notice errors like this:

  1) Real-world APIs
       11) adyen.com:PaymentServiceadyen.com:PaymentServiceadyen.com:PaymentService:
     SyntaxError: Swagger schema validation failed.
  Schema is not an object: boolean at #/x-groups

JSON_OBJECT_VALIDATION_FAILED
      at validateSchema (lib/validators/schema.js:38:15)
      at SwaggerParser.validate (lib/index.js:155:7)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)
      at async validateApi (test/specs/real-world/real-world.spec.js:56:7)
      at async Context.<anonymous> (test/specs/real-world/real-world.spec.js:47:7)

  z-schema validation error: JSON_OBJECT_VALIDATION_FAILED
      at ZSchema.getLastError (node_modules/z-schema/src/ZSchema.js:260:13)
      at validateSchema (lib/validators/schema.js:36:23)
      at SwaggerParser.validate (lib/index.js:155:7)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)
      at async validateApi (test/specs/real-world/real-world.spec.js:56:7)
      at async Context.<anonymous> (test/specs/real-world/real-world.spec.js:47:7)

In main many of the Adyen OpenAPI documents have been disabled because they're OpenAPI v3.1, but of course we'd want to enable them in this repo to test it properly. I found myself adding even more of their APIs to the list, because of this x-groups error, so I think it might be something to do with this change.

https://github.com/APIDevTools/swagger-parser/blob/a391da954d9bd451b1d680f891a114449e03cf51/test/specs/real-world/fetch-api-list.js#L44-L52

Can you investigate?

soyuka commented 3 years ago

x-properties are allowed as specification extensions: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions to be tested

philsturgeon commented 3 years ago

Correct, so we'd need to make sure this PR is still allowing them.

erunion commented 2 years ago

I've got all of these changes working and passing over in https://github.com/APIDevTools/swagger-parser/pull/187.