swagger-api / swagger-api/swagger-codegen

Enum on path parameter causing syntax error

Open
#6,527 1 comment 0 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

Came across an issue where if I have an Enum as a path parameter for a request, the generated api causes Java syntax errors.

It works fine if the parameter is a query parameter.

Swagger-codegen version

2.3.0

Swagger declaration file content or url
---
swagger: '2.0'
info:
  version: 0.0.0
  title: Simple API
paths:
  /users/{userType}:
    get:
      parameters:
        - name: userType
          in: path
          required: true
          type: string
          enum: [admin,normal]
      responses:
        200:
          description: OK
Steps to reproduce

Just generating the api with the above yaml causes a syntax error on the interface method header.
allowableValues="{values=[admin, normal], enumVars=[{name=ADMIN, value="admin"}, {name=NORMAL, value="normal"}]}"

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

Use the supplied Swagger 2.0 YAML declaration to generate the Java API and inspect the interface method header for the path parameter. Done means the generated Java is syntactically valid when the path parameter has enum values, while the query-parameter case continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.