-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
OAS 3.0 - Use OAS 3.0 annotations instead of old Swagger 1.5.x / OAS 2.x ones (@Api / @ApiXxx) #101
Conversation
9b2df9b
to
b7f68c8
Compare
@webron @HugoMario Migrated all JAX-RS part, |
@@ -145,6 +147,7 @@ public AbstractJavaCodegen() { | |||
cliOptions.add(CliOption.newBoolean(FULL_JAVA_UTIL, "whether to use fully qualified name for classes under java.util. This option only works for Java API client")); | |||
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)); | |||
cliOptions.add(CliOption.newBoolean(WITH_XML, "whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)")); | |||
cliOptions.add(CliOption.newBoolean(CodegenConstants.USE_OAS2, "whether to use OpenAPI v2.0 (Swagger 1.5.x) or not (by default, OpenAPI v3.0 is used)")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For use with Maven
plugin
b155092
to
be8488c
Compare
…2.x ones (@Api / @apixxx)
@HugoMario Seems like we all set, if you mind taking a look please. Thanks! |
thanks a lot @reta, going to look right now. |
Hey @reta sorry for delay, i review code and looks pretty fine for me, but before merge i would like to check the generated output on Also i'm not sure how contributor list works, but i saw that there is not email linked to your profile, this could cause that your PR doesn't count as contribution for Github once the PR is merged. |
Thanks a lot @HugoMario , really appreciate that. I have tested all codegens, no doubts, the compilation for server and client stubs was successful for both oas 2.0 / 3.0 but surely the bugs may escape. Regarding the contributor list, not sure how it works either, but not a big deal if I am not there, getting this feature working would be just great. Please let me know if you discover some issues, I will help to fix them. Thanks! |
thanks again @reta , pretty nice stuff !!! |
@reta @HugoMario First, I used the following command to list all possible options for the language:
which results in a list with options, including When I use this command:
it looks like the option The command:
results in the error: swagger-codegen: error: unrecognized arguments: '--use-oas2' When using the last command with java as the language, it does work as expected: code is generated with Swagger 2 annotations. Am I doing something wrong? |
Hey @rockxwre! Your expectations about the feature are absolutely correct. I am curious what version of the Swagger Codegen you are using? Or you are building from source? The OAS2/OAS3 support had been merged into 3.x.x only. Thank you! |
Hi @reta, Thank you for your reply! I used version 3.0.11:
|
Sorry @rockxwre , took me awhile to trace the issue, indeed for command-line tooling the option is not accepted by all server generation libraries (but it is for all client libraries). I will try to submit a fix shortly but if you could use Swagger Codegen Maven Plugin (3.x) or Codegen 2.x (only OAS 2) meantime, it should just work fine. Thank you. |
Any updates on this issue, the latest version 3.0.21 still uses the old annotations instead of io.swagger.v3.oas.annotations |
@SlavchoArsovski haven't had a chance to work on it, will try to wrap it up with next 1-2 weeks, thanks for pinging. |
@reta by any chance that swagger codegen for Spring Server Stub and as Java Client will use io.swagger.v3.oas.annotation soon? But not Spring Server stub and Java Client |
@SlavchoArsovski yes, the Spring Server stubs were merged in #753, please give it a try, thanks! For Java Client, all of them should support |
Hi @reta, i see on online editor when i generate API that indeed now generated code contains io.swagger.v3.oas.annotation, very cool! However i have the maven plugin version: 3.0.22 and still generates the code with old swagger annotations, am i missing something? |
@reta Ahh i see i need to use 3.0.23, i will try it 👍 |
@reta found 2 issues so for with migration from 3.0.21 to 3.0.23 ending with compile errors:
---> schema=@Schema(, defaultValue="0")) has obsolete comma "," which makes the file with compile error |
@SlavchoArsovski could you please submit an issue to |
Hm ... I think you could try these three things:
|
As of now, Swagger Codegen always uses old (
1.5.x
) Swagger annotations,@Api / @ApiModel
/@ApiModelProperty / ...
to decorate model classes, APIs, operations, ... even if the input specification comes in OAS 3.0.x format. It would make sense to use the Swagger 2.0.x annotations in this case since it corresponds to OAS 3.0.x specification and has different, richer set of attributes.Issue:
Server / client stubs updated:
As now
Springfox
(the Swagger/OpenAPI integration forSpring
/Spring Boot
) does not support OpenAPI (Swagger 2.0.x), leaving it untouched.Added new command-line argument to preserve the usages of the older OpenAPI 2.0 (Swagger 1.5.x) annotations and specification.
From the command line:
From
Maven
plugin: