-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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] Is it possible to use swagger 3 annotation in place of swagger 2 for java? #6108
Comments
This is related to the work being done in #5803 and we should probably address this at a higher level than just the Spring generator to make it usable for all Java generators. @videki and others have already started work on the updated templates, but the main bottleneck is that the |
I just tried this, it's available from
and you must use configOptions: this will then generate the OAS3 annotations from: and you can remove the Springfox libraries annotations (OAS3).
however, there are some issues: However, a breaking issue with that the OAS3 annotation: @hidden is generated on the parameters, but this annotation is not applicable to the parameter scope. and so causes a compile issue. perhaps 5.4.0 fixes this? |
@PieterJanMindCapture what are the configOptions to set please ? |
generator options are here: configOptions
For "java" generator options are here, and specifically for language/generatorName= "spring" the configOptions are also documented here: |
for springboot is is possible with 5.3.1 version <configOptions>
<library>spring-boot</library>
<!-- all other config options -->
<!-- following is added in v5.3.1 and import oas3 packages instead of swagger2.
<oas3>true</oas3>
</configOptions> see related issue |
@eguller thanks for the pointer! However, with the settings mentioned in your example and the ones in the MR #9775
Some models are generated with v3 annotations AND v2 annotations, for which the import fails: ...
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
...
import io.swagger.v3.oas.annotations.media.Schema; Also, these imports are not used anywhere. Any other configuration ideas to overcome this? Or is this a bug from the oas3 feature? (cc @welshm) Thanks! |
Hi @tofi86 ! So I did accidentally break some of the annotations for some of the mustaches I missed. However, I think these have since been fixed by some wonderful work from @cachescrubber in #11181 and two other improvements after that. Hopefully that will be in a release soon 🤞 |
Hi @welshm, well then we‘re looking forward to the next release! 👍 |
I don’t see the version '5.3.1' anywhere. Can you please explain how I can get 5.4.0 version. as you mentioned 5.3.1 have some issues |
@SamaNaresh 5.4.0 has been officially release and is available from the usual distribution points. |
It works. Thanks |
actually... there's still an issue with the generation of: @parameter(hidden = true) final ServerWebExchange exchange and that is that: you can't assume that the project is running in a Reactor web context. The default in spring is : servlet web context, if both servlet context (eg the so called spring-mvc) and a reactive libraries are found on the classpath it will default to picking Servlet web context. One can have a project that is mostly rest-endpoints in servlet spring-mvc/boot web context, and have some select controllers return a webflux react Mono/Flux response. However, in the default web servlet context, the bean ServerWebExchange does not exist. Now, I've also noticed that the generated response is: instead to confirm with the spec. with both present, and that is because in OAS3, it is not possible to override the "default" content-type anymore. |
The media-type issue is fixed with #11526 |
Is there any way of making the If I use |
The option is currently only available for the |
Is there any place to support OpenAPI 3+ in CXF? |
I have the same issue with swagger codegen 3.0.34 , i did change swagger-annotations to io.swagger.codegen.v3 but still have a probleme with generated Apis.
|
Is your feature request related to a problem? Please describe.
I've migrated my API from swagger codeGen and swagger2 to openApi codeGen and openApi.
I used to expose my paths and json spec to customer through springfox, and I want to update that as to expose an openApi spec file.
Following the guide for migration found https://springdoc.org/migrating-from-springfox.html I see the annotation used by openApiCode are still the "swagger2" one
Describe the solution you'd like
Is there a way to configure that in my pom.xml as to use the newer annotation ?
Is there anyway to configure that ?
The text was updated successfully, but these errors were encountered: