express-openapi-validator icon indicating copy to clipboard operation
express-openapi-validator copied to clipboard

Support for OpenAPI 3.1.0

Open harryc9 opened this issue 3 years ago • 12 comments
trafficstars

Hi, are there plans to support OpenAPI 3.1.0 with this library?

We're currently running into issues when validating the API spec because Stoplight API exports are using features exclusive to 3.1.0. Mainly trying to avoid workarounds where we manually downgrade the OA version and remove the said block post-export.

The specific feature being a change to the Schema definition to contain examples

components:
  schemas:
    User:
      title: User
      type: object
      description: ''
      examples:
        - id: 0
          firstName: Bob
          lastName: Ross
          email: [email protected]
          emailVerified: true
          createTime: '2019-08-24T12:42:12Z'
          lastUpdateTime: '2020-09-23T08:17:41Z'

Thank you!

harryc9 avatar Sep 08 '22 04:09 harryc9

It seems they have done the work, but have not yet released it as an update: https://github.com/cdimascio/express-openapi-validator/pull/713

nd-jharn avatar Oct 17 '22 11:10 nd-jharn

OpenAPI 3.1 support is blocked on AJV implementing it, even if this library updates: https://github.com/OAI/OpenAPI-Specification/issues/2689

essential-randomness avatar Oct 17 '22 18:10 essential-randomness

@essential-randomness would it possible to have a version that works without $dynamicAnchor and $recursiveAnchor ? With a big warning on the main page about this ? I'm missing so much null type and unevaluatedProperties for composition with allOf.

OlivierCuyp avatar Nov 15 '22 18:11 OlivierCuyp

Ah, man, I wish. There may be some movement on the AJV issue since yesterday, and if I understand correctly they offered a bounty. As far as my exploration went, I don't think it's possible to do anything about this without the AJV issue being resolved.

essential-randomness avatar Nov 15 '22 19:11 essential-randomness

@essential-randomness sorry, I didn't dig into the implication of $dynamicAnchor and $recursiveAnchor. I was just hoping it was ad hoc features... And yes, I saw this 500-1000$ bounty. Hopefully it will create some movement around this AJV issue. It is so sad, OpenApi 3.1 has exactly all the features needed to do good composition and type validation.

OlivierCuyp avatar Nov 16 '22 09:11 OlivierCuyp

@essential-randomness I'm really curious, it seems that fastify-openapi-glue succeed to have the openapi 3.1.0 specification working: https://github.com/seriousme/fastify-openapi-glue/issues/178

To be honest I didn't test it but according to some colleagues, it works well. Maybe they found a valid workaround.

OlivierCuyp avatar Nov 18 '22 22:11 OlivierCuyp

From there:

 3.1, by converting $dynamicRef and $dynamicAnchor into $ref and $anchor for now. This might cause some limitations for now but I think thats worth it.

I have no idea of the implications of this, nor would know what this conversion entails, but this is how they seem to be doing it.

essential-randomness avatar Nov 18 '22 23:11 essential-randomness

Still nothing?

nexsodev avatar May 17 '23 12:05 nexsodev

It would be cool to have features like unevaluatedProperties from draft 2019-9. I tried to change the draft, but I may need to spend more time if nothing happens on this issue.

@cdimascio Is this update on the roadmap?

lhimstedt avatar May 23 '23 07:05 lhimstedt

I think this is a duplicate of this issue.

Jackman3005 avatar Dec 26 '23 22:12 Jackman3005

As I posted about on the above issue, is it possible for this library to take on the preprocess step to resolve $dynamicRef before calling out to AJV? If not, would it be possible to provide a solid reason why it belongs in AJV to respond and continue pushing this forward?

Jackman3005 avatar Dec 26 '23 22:12 Jackman3005

This is a duplicate of https://github.com/cdimascio/express-openapi-validator/issues/573

thernstig avatar Dec 27 '23 13:12 thernstig