Swagger-codegen: JAX-RS ApiResponse 'response' and 'responseContainer' annotations get duplicated

Created on 13 Apr 2016  路  4Comments  路  Source: swagger-api/swagger-codegen

I used the Swagger Editor to create:

swagger: '2.0'
info:
  version: "0.0.1"
  title: Response annotation test
paths:
 /person:
    get:
      summary: Get all person api
      responses:
        200:
          description: Get all person
          schema:
            type: array
            items:          
              $ref: '#/definitions/Person'
        500:
          description: Unexpected error(s)
          schema:
            $ref: '#/definitions/ApiError'
definitions:
  Person:
    type: object
    properties:
      name:
        type: string
  ApiError:
    type: object
    properties:
      errorMsg:
        type: string

Then I generated JAX-RS Server code from the editor. Here is the APIResponses section in the PersonApi class:

   @io.swagger.annotations.ApiResponses(value = { 
        @io.swagger.annotations.ApiResponse(code = 200, message = "Get all person", response = Person.class, responseContainer = "List"),
        @io.swagger.annotations.ApiResponse(code = 500, message = "Unexpected error(s)", response = Person.class, responseContainer = "List") })

The 'response' and 'responseContainer' annotations from the 200 response block got used in the 500 ApiResponse.

Bug Java help wanted

Most helpful comment

Given the above Swagger, I would expect the correct APIResponses to be:

@io.swagger.annotations.ApiResponses(value = { 
        @io.swagger.annotations.ApiResponse(code = 200, message = "Get all person", response = Person.class, responseContainer = "List"),
        @io.swagger.annotations.ApiResponse(code = 500, message = "Unexpected error(s)", response = ApiError.class) })

All 4 comments

@vdillon thanks for reporting the issue. What should be correct APIResponses section looks like?

Given the above Swagger, I would expect the correct APIResponses to be:

@io.swagger.annotations.ApiResponses(value = { 
        @io.swagger.annotations.ApiResponse(code = 200, message = "Get all person", response = Person.class, responseContainer = "List"),
        @io.swagger.annotations.ApiResponse(code = 500, message = "Unexpected error(s)", response = ApiError.class) })

I cannot commit to contributing at this time.

Van

--------- Original Message --------- Subject: Re: [swagger-api/swagger-codegen] JAX-RS ApiResponse 'response' and 'responseContainer' annotations get duplicated (#2588)
From: "wing328" [email protected]
Date: 5/1/16 12:21 am
To: "swagger-api/swagger-codegen" [email protected]
Cc: "vdillon" [email protected], "Mention" [email protected]

@vdillon may I know if you've cycle to contribute the fix? A good starting point is https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey1_18/api.mustache#L48
Ref: https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md
-
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

Was this page helpful?
0 / 5 - 0 ratings