Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #3959
Closed
Open
Issue created Sep 26, 2019 by Administrator@rootContributor

[Elm] [BUG] Enum paramters not working if not inlined ($ref)

Created by: andys8

Description

Using string enums as url parameters is working, if they're defined inline per path. If a single enum definition should be used for multiple paths as parameter and referenced with $ref, it won't be recognized as being an enum.

Parameter 'flow' cannot be converted to a string. Please report the issue.

For comparison: A parameter reference to an enum seems to be working for java.

openapi-generator version

4.1.2

OpenAPI declaration file content or url
 /conversation/{flow}:
    post:
      summary: Create dental supplementary conversation
      operationId: createConversation
      tags:
        - conversation
      parameters:
        - name: flow
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/FlowType'
      responses:
        "201":
          description: Current conversation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Conversation"
    FlowType:
      type: string
      enum:
        - MyValue
        - MyOtherValue
Exception in thread "main" java.lang.RuntimeException: Could not generate api file for 'Conversation'
        at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:668)
        at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:924)
        at org.openapitools.codegen.cmd.Generate.run(Generate.java:408)
        at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:60)
Caused by: java.lang.RuntimeException: Parameter 'flow' cannot be converted to a string. Please report the issue.
        at org.openapitools.codegen.languages.ElmClientCodegen.paramToStringMapper(ElmClientCodegen.java:593)
        at org.openapitools.codegen.languages.ElmClientCodegen.paramToString(ElmClientCodegen.java:621)
        at org.openapitools.codegen.languages.ElmClientCodegen.postProcessOperationsWithModels(ElmClientCodegen.java:453)
        at org.openapitools.codegen.DefaultGenerator.processOperations(DefaultGenerator.java:1178)
        at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:553)
        ... 3 more
Related issues/PRs

Related to #2585 (closed) and #2982 (great work! @eriktim )

Suggest a fix

My understanding is that a $ref to a schema definition (which is an enum) is not recognized as enum. There has to be a recursive test looking up the parameter.

https://github.com/eriktim/openapi-generator/blob/17af708b064f33da618c62c20c3cadd303ab2611/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java#L590

@eriktim

Assignee
Assign to
Time tracking