OpenAPITools / OpenAPITools/openapi-generator

[JAVA - SpringCodegen] Bug/feature generating code with swagger annotations v3

Open
#3,902 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

In Spring Boot 2.1.6 project we use SpringCodegen and openapi-generator-maven-plugin to generate DTOs and interfaces for controllers from yaml-file with openapi 3.0.0. Generated files contains swagger annotations from package "io.swagger.annotations", although expected annotations from package "io.swagger.v3.oas.annotations", because in source yaml-file used openapi v3. Generated classes works fine, but we cannot later generate swagger documentation with specification v3 from that classes. Only v2. We want to control, that output documentation is the same version 3, like in input yaml-file, to exclude override errors in our code. To generate swagger documentation from java-classes we use another component, that needs swagger annotations v3. Please tell me how can I fix this problem: edit templates or maybe a ready-made solution already exists?

openapi-generator version

4.0.2

OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement

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 by reproducing the SpringCodegen output with openapi-generator-maven-plugin 4.0.2 using an OpenAPI 3.0.0 YAML specification, then trace the generator's annotation selection and template path. Done means generated DTOs and controller interfaces use io.swagger.v3.oas.annotations rather than io.swagger.annotations, while preserving the requested OpenAPI version.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring
Domain
api, backend
Issue type
Bug
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.