swagger-api / swagger-api/swagger-codegen

[SPRING] Swagger annotations corresponds to older version

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

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Generated API and Model code includes older version of swagger annotations only for SPRING library.
Ex :
import io.swagger.annotations.;
import io.swagger.annotations.
;

Expectation is to use latest swagger annotations. Ex: import io.swagger.v3.oas.annotations.*;

Swagger-codegen version

3.0.16

PetStore.yaml

openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:

  • url: http://petstore.swagger.io/v1
    paths:
    /pets:
    get:
    summary: List all pets
    operationId: listPets
    tags:
    - pets
    parameters:
    - name: limit
    in: query
    description: How many items to return at one time (max 100)
    required: false
    schema:
    type: integer
    format: int32
    responses:
    '200':
    description: A paged array of pets
    headers:
    x-next:
    description: A link to the next page of responses
    schema:
    type: string
    content:
    application/json:
    schema:
    $ref: "#/components/schemas/Pets"
    default:
    description: unexpected error
    content:
    application/json:
    schema:
    $ref: "#/components/schemas/Error"

components:
schemas:
Pet:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Pets:
type: array
items:
$ref: "#/components/schemas/Pet"
Error:
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string

Command line used for generation

java -jar swagger-codegen-cli-3.0.5.jar generate -i ../openapi.yaml -l spring

Generated Code
Attaching the zip
src.zip

Generated Model Pet.java contains older version of swagger annotations
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

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

Reproduce the Spring generation with the provided PetStore.yaml and the swagger-codegen CLI command, then inspect the generated Model Pet.java. Compare its io.swagger.annotations imports with the requested io.swagger.v3.oas.annotations package and verify that generated model and API code consistently use the newer annotation version.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.