Skip to content

[JAXRS-CXF-CDI] Invalid argument on OAS 3.0 annotation @Parameter #132

@HugoMario

Description

@HugoMario

Description

A non declared argument, allowableValues, is placed for OAS 3.0 annotation @Parameter

The issue is related to an array of string set with a enum for a parameter named status, an example of this is /pet/findByStatus: path from petstore sample :

  /pet/findByStatus:
    get:
      tags:
        - pet
      summary: Finds Pets by status
      description: Multiple status values can be provided with comma separated strings
      operationId: findPetsByStatus
      produces:
        - application/xml
        - application/json
      parameters:
        - name: status
          in: query
          description: Status values that need to be considered for filter
          required: true
          type: array
          items:
            type: string
            enum:
              - available
              - pending
              - sold
            default: available
          collectionFormat: csv
      responses:
        '200':
          description: successful operation
          schema:
            type: array
            items:
              $ref: '#/definitions/Pet'
        '400':
          description: Invalid status value
      security:
        - petstore_auth:
            - 'write:pets'

Command used:

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar  generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs-cxf-cdi -o output -DhideGenerationTimestamp=true

Keeping in mind that it does not matter that definition is in OAS 2 format since Swagger Codegen v3 supports it.

So the generated output with error on PetApi.java class is:

public Response findPetsByStatus( @NotNull @Parameter(description = "Status values that need to be considered for filter",required=true, allowableValues="available, pending, sold")  @QueryParam("status") List<String> status) {
        return delegate.findPetsByStatus(status, securityContext);
    }

when we try to build generated code with mvn package command we got:

[ERROR] /Users/hugomercado/GitHub/swagger-codegen/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/io/swagger/api/PetApi.java:[106,111] cannot find symbol
[ERROR]   symbol:   method allowableValues()
[ERROR]   location: @interface io.swagger.v3.oas.annotations.Parameter

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions