OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Golang] unexported name is generated for enum
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
When I generate Go model code for an enum where a value starts with a number then the generated const will be unexported.
Actual:
// List of AccessType
const (
_3_GPP_ACCESS AccessType = "3GPP_ACCESS"
NON_3_GPP_ACCESS AccessType = "NON_3GPP_ACCESS"
)
Expected e.g.:
// List of AccessType
const (
ACCESS_TYPE_3_GPP_ACCESS AccessType = "3GPP_ACCESS"
ACCESS_TYPE_NON_3_GPP_ACCESS AccessType = "NON_3GPP_ACCESS"
)
Input validation:
docker run --rm -it -w /gen -e GEN_DIR=/gen -e MAVEN_CONFIG=/var/maven/.m2 -u 0:0 -v /ephemeral/opentas/openapi-generator:/gen -v /root/.m2:/root/.m2 --entrypoint /gen/docker-entrypoint.sh maven:3-jdk-8 validate -i 5GC_APIs/TS29122_CommonData.yaml
Validating spec (5GC_APIs/TS29122_CommonData.yaml)
No validation issues detected.
docker run --rm -it -w /gen -e GEN_DIR=/gen -e MAVEN_CONFIG=/var/maven/.m2 -u 0:0 -v /ephemeral/opentas/openapi-generator:/gen -v /root/.m2:/root/.m2 --entrypoint /gen/docker-entrypoint.sh maven:3-jdk-8 validate -i 5GC_APIs/TS29518_Namf_MT.yaml
Validating spec (5GC_APIs/TS29518_Namf_MT.yaml)
No validation issues detected.
openapi-generator version
4.0.0-SNAPSHOT
OpenAPI declaration file content or url
**AccessType:
type: string
enum:
- 3GPP_ACCESS
- NON_3GPP_ACCESS**
Command line used for generation
./run-in-docker.sh generate -i 5GC_APIs/TS29518_Namf_MT.yam -g go -o /gen/out -Dmodels
Steps to reproduce
./run-in-docker.sh generate -i 5GC_APIs/TS29518_Namf_MT.yam -g go -o /gen/out -Dmodels
cat out/model_access_type.go
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the listed run-in-docker.sh generate command and inspect out/model_access_type.go for the AccessType enum. Trace the Go generator path that derives names from enum values beginning with a number, then confirm the generated constants are exported and retain the expected string values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100