Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQ] Support for OpenAPI Spec 3.1 #9083

Open
westn opened this issue Mar 25, 2021 · 48 comments
Open

[REQ] Support for OpenAPI Spec 3.1 #9083

westn opened this issue Mar 25, 2021 · 48 comments

Comments

@westn
Copy link

westn commented Mar 25, 2021

Is your feature request related to a problem? Please describe.

Support for OpenAPI Spec 3.1, released last month: https://github.com/OAI/OpenAPI-Specification/releases/tag/3.1.0

Describe the solution you'd like

Add support for OpenAPI Spec 3.1

Additional context

Couldn't see any other mention of this besides a short mention in #15
Another note on https://www.openapis.org/blog/2020/06/18/openapi-3-1-0-rc0-its-here which mention that the specification-change is bigger than it sounds and might break some tooling.

@spacether
Copy link
Contributor

We use swagger-parser to parse openapi specs. That project must implement v 3.1 spec parsing before we can implement it in the generators.

@darkbasic
Copy link

https://github.com/swagger-api/swagger-parser/commits/oas3.1

@cgfarmer4
Copy link
Contributor

Any updates to share on potentially updating the generators to OAS 3.1?

@gunsluo
Copy link

gunsluo commented May 15, 2022

Any updates to share on potentially updating the generators to OAS 3.1?

swagger-api/swagger-parser#1535, there has been no update for half a year.

@cyangle
Copy link
Contributor

cyangle commented May 27, 2022

OAS 3.1 support has been added to swagger-parser in swagger-api/swagger-parser#1730

@denisgolubovic
Copy link

What release do you aim for this to be implemented in the generator? 6.1.0?

@kiwisincebirth
Copy link

swagger-parser 2.1 has been released with OAS 3.1 support
https://github.com/swagger-api/swagger-parser/releases/tag/v2.1.0

@RickKukiela
Copy link

This is a big oof on my part. I just spent a ton of time setting up an API spec for a client and used 3.1.0 and now that its all approved I need to actually program the API server and need to generate the base files from the spec. Now I find out that not only does this package not support 3.1.0 currently but I cannot seem to find any code generator that does :( big yikes! I have to figure out what my options are at this point as my spec currently makes heavy use of the type as an array not a string and I also use oneOf with "null" or a $ref throughout the whole thing which makes it a major problem to downgrade to 3.0.3 at this point.

I see that as of 27 days ago at the time of me writing this, the 3.1 spec was added to swagger-api/swagger-parser#1535 - Does anyone have any idea when there will be a beta / snapshot release that will support 3.1.0 as if its going to be soon(tm), I might keep just waiting for that as an option before nuking my 3.1.0 setup....

@slPerryRhodan
Copy link

slPerryRhodan commented Jun 23, 2022

We are also waiting for this feature, to generate classes from components if there is no API (e. g. publish Kafka Event Objects as Open Api Spec). I hope there will be soon a new release for that.

@tobq
Copy link

tobq commented Jul 6, 2022

Any updates on 3.1 support?

@Stokestack
Copy link

This is a huge impediment. I too have an API that relies on 3.1 features. It seems to be taking the toolchain a very long time to support it.

@spacether
Copy link
Contributor

This is a big oof on my part. I just spent a ton of time setting up an API spec for a client and used 3.1.0 and now that its all approved I need to actually program the API server and need to generate the base files from the spec. Now I find out that not only does this package not support 3.1.0 currently but I cannot seem to find any code generator that does :( big yikes! I have to figure out what my options are at this point as my spec currently makes heavy use of the type as an array not a string and I also use oneOf with "null" or a $ref throughout the whole thing which makes it a major problem to downgrade to 3.0.3 at this point.

I see that as of 27 days ago at the time of me writing this, the 3.1 spec was added to swagger-api/swagger-parser#1535 - Does anyone have any idea when there will be a beta / snapshot release that will support 3.1.0 as if its going to be soon(tm), I might keep just waiting for that as an option before nuking my 3.1.0 setup....

Type null works with 3.0.3 specs and our tool
Type arrays can be converted to oneOf with each type in a different schema.

@philsturgeon
Copy link
Contributor

Hello! As the maintainer of openapi.tools, and as somebody works with Linux Foundation helping out in OpenAPI-land, I'm reaching out to tooling vendors to track the progress towards supporting OpenAPI v3.1, to see what roadblocks there are beyond folks just generally being busy at this ridiculous time.

OpenAPI v3.1 has a bunch of great little changes, solving problems like the JSON Schema <!=> OpenAPI Schema Object divergence. It also fixes some other inconsistencies and duplicate ways of doing things. It's the best version and everyone should be using it, but we need tooling to catch up. Just in case folks didn't notice, or don't have resources to simplify the process, I'm here to give a friendly prod and send over some handy links.

Here are a few articles showing off the differences between OpenAPI v3.0 and v3.1.

Here are some example files which can make for handy pass/fail test cases:

https://github.com/Mermade/openapi3-examples/tree/master/3.1

If you're looking for the JSON Schema that defines a valid OpenAPI document, that'll be right over here:

https://github.com/OAI/OpenAPI-Specification/tree/main/schemas/v3.1

No rush, but when you're starting work on it, please update this issue so I can update openapi.tools to reflect that, and folks will have a way to subscribe for updates.

LMK if you have any questions!

@marcelstoer
Copy link
Contributor

Apart from the actual lack of 3.1 support the biggest issue I have is that this project does not seem to be open about it.

The README doesn't mention it. https://openapi-generator.tech/ prominently claims

from OpenAPI 2.0/3.x documents

which led me to believe that 3.1 be fully supported.

@RickKukiela
Copy link

Probably should say 3.0.x...

@karenetheridge
Copy link

It would be helpful to see an itemized list of what is still needed to achieve v3.1 support, so that members of the community can help out. Has anyone identified those tasks?

@spacether
Copy link
Contributor

spacether commented Aug 3, 2022

It would be helpful to see an itemized list of what is still needed to achieve v3.1 support, so that members of the community can help out. Has anyone identified those tasks?

I am putting together that list now and we will publish a project very soon. This is something that we all want to add to openapi-generator. It is ~30 feature additions to store the new openapi/json schema data in our java classes. Then that data needs to be used by the generators to generate code that imposes the new json schema validation + adds new openapi features.

@spacether
Copy link
Contributor

spacether commented Aug 4, 2022

We have a project to track adding 3.1.0 support here:
https://github.com/orgs/OpenAPITools/projects/4/views/1 and welcome any PRs adding these features

Generators that will have 3.1.0 support prioritized:
#13073

Tag for 3.1.0 issues/PRs:
https://github.com/OpenAPITools/openapi-generator/issues?q=is%3Aissue+is%3Aopen+label%3A%22Feature%3A+OAS+3.1.0+spec+support%22

@adampoplawski
Copy link

Hello
Is there a plan to add support for OpenAPI 3.1 in the 7.0.0 release?

@phillipuniverse
Copy link
Contributor

phillipuniverse commented Jul 24, 2023

Any sort of updated timeline anywhere? More and more upstream projects are supporting OpenAPI 3.1. For example, FastAPI (Python project) released 0.100.0 a couple of weeks ago that targets OpenAPI 3.1 only.

I see this project at https://github.com/orgs/OpenAPITools/projects/4, but seems like very little activity in the last year. And @spacether, what's your plan with your fork? I can't quite tell how complete the OpenAPI 3.1 support is - the README still seems to indicate OpenAPI 3.0.x only. And it seems like your fork is python generator-focused.

@spacether
Copy link
Contributor

spacether commented Jul 25, 2023

Some updates on my fork, openapi-json-schema-generator

The openapi-core team required the removal of my python generator from this repo despite it thoroughly providing openapi and json schema features, so I will no longer be contributing to this repo

If you are interested in using these features and they do not yet exist in the tooling, please write a PR in openapi-json-schema-generator

If you want json schema support in python or any other language please give the project a look and help me build it. PRs and new generators in any language are welcome We can all be the change that we want to see 🙂 I am actively working on adding 3.1.0 spec features here

@phillipuniverse
Copy link
Contributor

@spacether thanks for the extra information. Really unfortunate that some of the drama caused the fork! Your contributions speak for themselves! Seems like there is no other hope for OpenAPI 3.1 support landing in this repo 😢

in my v3 branch full statically check typing has been added to the python code which means that this generator could be ported into other static languages like Kotlin, Java, Go etc

Nice, maybe we could use the list at #13073 for the next ones to prioritize. From this list, looks like it would be Java and typescript-axios.

@adampoplawski
Copy link

adampoplawski commented Jul 29, 2023

@spacether thx for info. Are you planning to suport only Python in you fork in foreseeable future?

@spacether
Copy link
Contributor

spacether commented Jul 29, 2023

My focus is getting python working for 3.1.0. If people add more languages they will be supported. So PRs and new generators in any language are welcome.

Java client users, can you provide feedback on how you would want operation methods to be generated here? https://stackoverflow.com/questions/76800939/how-should-i-write-a-method-to-make-a-rest-request-to-the-server-and-return-back
I have been thinking about how to port the python code into Java.

Does anyone here want to work on a Java client generator or a different language from python?

@abrahan-munro
Copy link

Note that if the spec document is mostly compatible with 3.0.x, just changing the version string from 3.1.0 to 3.0.3 can be used as a work around. When the version is 3.1, incorrect output is produced, but correct output may be generated if the version is 3.0. This is the case with the spec produced by the current version of FastAPI (0.100.0) for example.

@spacether
Copy link
Contributor

spacether commented Aug 31, 2023

Heads up, as of today just over 50% of the 3.1.0 new json schema keyword features have been implemented in my project: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator in the master branch
Including:

  • const
  • contains
  • dependentRequired
  • dependentSchemas
  • maxContains
  • minContains
  • patternProperties
  • prefixItems
  • propertyNames
  • unevaluatedItems
  • unevaluatedProperties

@Fares-Abubaker
Copy link

Hello all,
when supporting for 3.1.0 will be released ?

@spacether
Copy link
Contributor

spacether commented Sep 27, 2023

Hello! As the maintainer of openapi.tools, and as somebody works with Linux Foundation helping out in OpenAPI-land, I'm reaching out to tooling vendors to track the progress towards supporting OpenAPI v3.1, to see what roadblocks there are beyond folks just generally being busy at this ridiculous time.

...
LMK if you have any questions!

@philsturgeon one big roadblock is that there are a number of bugs in swagger-parser that prevent json schema test cases from running/passing. One can see 10 of those bugs here: https://github.com/swagger-api/swagger-parser/issues?q=is%3Aissue+is%3Aopen+3.1.0+author%3Aspacether
If people want these features to work, please consider helping fix these bugs in swagger-parser.
The one breaking the most test cases is: swagger-api/swagger-parser#1770

@philsturgeon
Copy link
Contributor

philsturgeon commented Sep 28, 2023

@spacether I'm sorry to say I've got absolutely nothing to do with https://github.com/swagger-api/swagger-parser.

You're mistaking it for https://github.com/APIDevTools/swagger-parser, which I do occasionally maintain, but it's is a whole other thing.

@spacether
Copy link
Contributor

spacether commented Sep 28, 2023

Just answering your what are the roadblocks question, not saying that you are associated with swagger-parser.

@spacether
Copy link
Contributor

spacether commented Sep 29, 2023

OpenAPI v3.1.0 python code generation is now supported in openapi-json-schema-generator

Heads up, I just released v3.3.0 of openapi-json-schema-generator which allows python code generation using an openapi v3.1.0 document.

Over 66% of the 3.1.0 new json schema keyword features have been implemented
3.1.0 spec support includes these added/updated json schema keywords:

  1. type (array of types supported in addition to one non-array value)
  2. const: only string values are working because of bugs in swagger parser
  3. contains
  4. dependentRequired
  5. dependentSchemas
  6. maxContains
  7. minContains
  8. patternProperties
  9. prefixItems
  10. propertyNames
  11. unevaluatedItems
  12. unevaluatedProperties
  13. if
  14. then
  15. else

@spacether
Copy link
Contributor

spacether commented Jan 5, 2024

@adampoplawski @phillipuniverse I have been working on a Java generator and v3.0.0-v3.0.3 openapi schema validation has been implemented in java. This includes List/Map output classes, List/Map builder classes, and Enums which are accepted into Schema.validate and the List/Map builders. Read all about it here. The Java schema validation is available in my v4.0.0 release.

@sheldonreddy
Copy link

Hi,

When can we expect the openapi specification version 3.1.0 to be supported by the OpenAPI-Generator tooling? Is there any roadmap we can reference to keep an eye on?

Thanks

@wing328
Copy link
Member

wing328 commented Jan 10, 2024

latest stable version v7.2.0 comes with beta support. you can give it a try to see if it works for your use cases.

@sheldonreddy
Copy link

Thanks @wing328 - will give it a shot.

@spacether
Copy link
Contributor

spacether commented Jan 17, 2024

@wing328

  • Where was the beta support added?
  • What 3.1.0 features were added in what generators?

The only 3.1.0 PR that I see in that release is #17174 looking at the release notes and doing a search for 3.1.0

@spacether
Copy link
Contributor

spacether commented Jan 22, 2024

openapi v3.1.0 schema support added for java in openapi-json-schema-generator

Heads up, I just released v4.1.0 of openapi-json-schema-generator which allows java code generation using an openapi v3.1.0 document.

Over 67% of the 3.1.0 new json schema keyword features have been implemented
3.1.0 spec support includes these added/updated json schema keywords, which are tested with the json schema test suite in CI:

  1. type (array of types supported in addition to one non-array value)
  2. const: only string values are working because of bugs in swagger parser
  3. contains
  4. dependentRequired
  5. dependentSchemas
  6. maxContains
  7. minContains
  8. patternProperties
  9. prefixItems
  10. propertyNames
  11. unevaluatedItems
  12. unevaluatedProperties
  13. if
  14. then
  15. else

@adampoplawski
Copy link

@wing328 Can you share the status of 3.1.0 support?

@wing328
Copy link
Member

wing328 commented Mar 20, 2024

The best way to get updates regarding OpenAPI 3.1 support (beta) is via the Label in the pull request tab: https://github.com/OpenAPITools/openapi-generator/pulls?q=+is%3Apr+label%3A%22Feature%3A+OAS+3.1.0+spec+support%22+

@spacether
Copy link
Contributor

spacether commented Apr 12, 2024

openapi 3.1.0 support added for the java generator in openapi-json-schema-generator

Heads up, I just released v4.2.1 which includes the stable java sdk generator

  • It includes thorough endpoint code samples for schema validation an endpoint invocation
  • Sealed classes are used for validated schema payloads/request bodies/responses/response bodies
  • Code is re-used rather than generated multiple times: If an endpoint has multiple tags, the endpoint method is defined once as a default method in an interface, and that interface is implemented in each tag's api class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests