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
  • #535
Closed
Open
Issue created Jul 11, 2018 by Administrator@rootContributor

[Go] Duplicate constant names for enums with same values

Created by: moser4035

Description

I've defined enums that contain same values (see below) The openapi-generator creates constants with the same names. But this is not allowed and the code does not compile anymore.

I get an error like this:

previous declaration at ../go-client/model_color_primaries.go:18:28
../go-client/model_color_space.go:20:26: SMPTE170_M redeclared in this block

used openapi-generator version: 3.0.3

OpenAPI declaration file content or url
ColorSpace:
  title: ColorSpace
  enum:
  - UNSPECIFIED
  - SMPTE170M
  - SMPTE240M

ColorPrimaries:
  title: ColorPrimaries
  enum:
  - UNSPECIFIED
  - SMPTE170M
  - SMPTE240M
Generated Go code

file model_color_space.go:



        type ColorSpace string

        const (
	        UNSPECIFIED ColorSpace = "UNSPECIFIED"
	        SMPTE170_M ColorSpace = "SMPTE170M"
	        SMPTE240_M ColorSpace = "SMPTE240M"
        )

file model_color_primaries.go:

        type ColorPrimaries string

        const (
	        UNSPECIFIED ColorPrimaries = "UNSPECIFIED"
	        SMPTE170_M ColorPrimaries = "SMPTE170M"
	        SMPTE240_M ColorPrimaries = "SMPTE240M"
        )
Command line used for generation

java -jar /opt/openapi-generator-cli.jar generate -g go -i openapi.json -o /go/src/go-client

Suggest a fix/enhancement

Maybe this could be solved by adding a prefix to the constants of the enum

Assignee
Assign to
Time tracking