OpenAPITools / OpenAPITools/openapi-generator

[BUG] [Javascript] When creating a Enum in a Query Path, it is being generated as model/String and cant be used.

Open
#14,857 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

I have an enum in my path which can be of the values "CLUB" or "EVENT". Definition:


 parameters:
    ClubElementType:
      name: ClubElementType
      in: path
      required: true
      schema:
        type: string
        enum:
          - CLUB
          - EVENT
      description: The type of Element to handle.

When used in a api function, it gets defined as this type:

@param {module:model/String} clubElementType The type of Element to handle.

Which is obviously wrong, since there is no class "model/String".

openapi-generator version

6.4.0

OpenAPI declaration file content or url

 parameters:
    ClubElementType:
      name: ClubElementType
      in: path
      required: true
      schema:
        type: string
        enum:
          - CLUB
          - EVENT
      description: The type of Element to handle.
Generation Details

just use the "javascript" generator.

Steps to reproduce

create a schema with an string enum and use it in a method. Works also inline.

Related issues/PRs

nothing found

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 with the JavaScript generator and reproduce the issue using the inline string enum in the supplied OpenAPI parameter definition. Trace how the path parameter type is rendered in the generated API method documentation; done means the enum is represented as a usable JavaScript type rather than module:model/String.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.