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

Request: option to set the OpenAPI version #298

Closed
EricWittmann opened this issue Apr 16, 2020 · 9 comments · Fixed by #412
Closed

Request: option to set the OpenAPI version #298

EricWittmann opened this issue Apr 16, 2020 · 9 comments · Fixed by #412
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@EricWittmann
Copy link
Contributor

EricWittmann commented Apr 16, 2020

This comes from someone on the Microprofile OpenAPI gitter chat room:

Franck Arnulfo
@farnulfo_twitter
Hi, is there anyway to have a "dynamic backport of OpenApi version" ?
Context: we use Thorntail v2.6.0 which implement OpenAPI 3.0.1 so /openapi return a 3.0.1 document but our API Gateway (WSO2) only support 3.0.0 so we can't use the /openapi endpoint to configure the API. We can manually import an OpenApi 3.0.0 by editing and modifying the dynamic 3.0.1 but I would like to avoid it. So I was thinking about a way to have the /openapi endpoint to output a back version of the current one. Something like /openapi?version=3.0.0.

@EricWittmann EricWittmann added the enhancement New feature or request label Apr 16, 2020
@phillip-kruger
Copy link
Member

phillip-kruger commented Apr 16, 2020

Maybe we allow more that just the version to be overridden in MP Config. Eg. Contact and maybe other field ?

Possible using enums (3.0.0,3.0.1,3.0.2)

@phillip-kruger
Copy link
Member

Also maybe change the default to 3.0.2

@famod
Copy link

famod commented May 6, 2020

Also maybe change the default to 3.0.2

...or 3.0.3? https://github.com/OAI/OpenAPI-Specification/releases

Context: We are using 3.0.3 in our OpenAPI-files and we noticed Quarkus is exposing the API with 3.0.1...

cc @kenfinnigan

@MikeEdgar
Copy link
Member

I think this line in OpenApiAnnotationScanner is to blame.

openApi.setOpenapi(OpenApiConstants.OPEN_API_VERSION);

Perhaps we remove that line and it would allow whatever is given in the static file or the OASModelReader to be available in the result. My concern with adding properties is that the OASModelReader already allows developers to programmatically set values using any configuration source of their choosing and it would be duplicate functionality to some degree.

@phillip-kruger
Copy link
Member

phillip-kruger commented Jul 23, 2020

Hi All.
I discussed this with @MikeEdgar.

My plan is do the following:

  1. When a model file is provided that contains a valid version number, use that. So we remove the "hardcoded" version and allow one to be set from a provided schema.
  2. Allow users to set the version using MP Config. (In case they do not want to supply a schema file)
  3. Else, use the hardcoded version (that we maybe up to the 3.0.3 version)

How does that sound ?

@phillip-kruger phillip-kruger self-assigned this Jul 23, 2020
@phillip-kruger phillip-kruger added this to the 2.0.5 milestone Jul 23, 2020
@famod
Copy link

famod commented Jul 23, 2020

@phillip-kruger That sounds good to me!
The version of smallrye-open-api will certainly limit the version range to some extend, won't it?

@phillip-kruger
Copy link
Member

Yes, we might have to set a max.

@MikeEdgar
Copy link
Member

One thing to consider about validating the user's input for the version is that it's something we don't really do anywhere else. I.e. let the user/developer decide if they want to output something that isn't technically valid. We've kind of hinted in the past that there are countless ways someone could do the wrong thing (from an OAS perspective) that it could get complicated quickly to verify all the inputs.

@phillip-kruger
Copy link
Member

Good point @MikeEdgar . So should we rather not validate the version ? I don't have a strong opinion either way. Maybe start of without any validation and when people log bugs about them setting the wrong version then we add it ? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants