OpenAPITools / OpenAPITools/openapi-generator

[REQ] Is it possible to use swagger 3 annotation in place of swagger 2 for java?

Open
#6,108 17 comments 37 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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 ?

Replace swagger 2 annotations with swagger 3 annotations (it is already included with springdoc-openapi-ui dependency). Package for swagger 3 annotations is io.swagger.v3.oas.annotations.

@ApiParam -> @Parameter
@ApiOperation -> @Operation
@Api -> @Tag
@ApiImplicitParams -> @Parameters
@ApiImplicitParam -> @Parameter
@ApiIgnore -> @Parameter(hidden = true) or @Operation(hidden = true) or @Hidden
@ApiModel -> @Schema
@ApiModelProperty -> @Schema

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the springdoc migration guide and the requested pom.xml configuration, then trace how Java generation handles the listed Swagger 2 annotations. Compare the requested Swagger 3 mappings with the generated output and determine whether a configuration or generator change is needed; done means the supported approach is clear and covered by an appropriate example or test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.