OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.63k stars 6.53k forks source link

Cannot find symbol 'allowableValues' in pathParams template with oas3 and JavaSpring #11218

Open agmyrek opened 2 years ago

agmyrek commented 2 years ago
Description

Defining an enum schema in parameters object will cause the following compiling error:

'cannot find symbol': allowableValues

You can see the causing code here:

https://github.com/OpenAPITools/openapi-generator/blob/5.3.x/modules/openapi-generator/src/main/resources/JavaSpring/pathParams.mustache

The field "allowableValues" no longer exists in the annotation @Parameter from io.swagger.v3.oas.annotations

openapi-generator version

5.3.1

OpenAPI declaration file content or url
openapi: 3.0.3
paths:
  /api/{myEnum}:
    post:
      parameters:
        - name: myEnum
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/MyEnum'
components:
  schemas:
    MyEnum:
      type: string
      enum:
        - A
        - B
        - C
Generation Details

I am using the maven plugin with the following config option:

<oas3>true</oas3>

Steps to reproduce

generate with maven plugin

Suggest a fix

Remove "allowableValues" from the template and use the @Schema annotation

wing328 commented 2 years ago

@agmyrek thanks for reporting the issue. Can you please file a PR with the suggested fix?

cachescrubber commented 2 years ago

Closed via #11181. Please pull the latest master to give it another try.