You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Duplicate typename error when generating for Jira Cloud API #1878
$ curl -sSfL 'https://dac-static.atlassian.com/cloud/jira/platform/swagger.v3.json?_v=1.7651.0-0.1317.0' | go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@v2.4.1 /dev/stdin
error generating code: error generating type definitions: error generating code for type definitions: duplicate typename 'ApprovalConfigurationExclude' detected, can't auto-rename, please use x-go-name to specify your own name for one of them
exit status 1
I've tried virtually all compatibility and output options, but nothing fixes the problem. Inspecting the input JSON file, things look legit: the type is defined, plus 2 references. My guess is that the enum is being generated with duplicated names. This may be the same as #1449, and may be a bug.
I left out some bits but the first enum creates the ApprovalConfigurationExclude type. Then the second enum creates another enum type with the same name. This I believe is fixable by ignoring enums for array types, or auto assigning it to the items.
Other generators append a number, so one would be ProjectFeatureStateState and the other ProjectFeatureStateState0. I think this is the enhancement that oapi-codegen needs. I tried adding this but ran into issues.
Activity
paulmach commentedon Jan 9, 2025
This is due to a couple of issues in the schema:
I left out some bits but the first enum creates the
ApprovalConfigurationExcludetype. Then the second enum creates another enum type with the same name. This I believe is fixable by ignoring enums for array types, or auto assigning it to the items.The second issues is more complicated.
and
These will generate the same
ProjectFeatureStateStateenum. Might need to deduplicate or rename somehow.Not exactly sure of the fixes, but those are the causes.
paulmach commentedon Jan 11, 2025
Other generators append a number, so one would be
ProjectFeatureStateStateand the otherProjectFeatureStateState0. I think this is the enhancement that oapi-codegen needs. I tried adding this but ran into issues.As for getting it to work for you right now, you can try using an OpenAPI Overlay https://github.com/oapi-codegen/oapi-codegen?tab=readme-ov-file#modifying-the-input-openapi-specification I've never used it but you could use it to add the
x-go-nameextensions.