OpenAPITools / OpenAPITools/openapi-generator

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

Open
#11,218 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

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

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 in modules/openapi-generator/src/main/resources/JavaSpring/pathParams.mustache and inspect how the enum path parameter is rendered for the oas3 option. Reproduce the issue with the provided OpenAPI declaration and Maven plugin configuration, then verify that generated JavaSpring code compiles without the missing allowableValues symbol.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.