OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.32k stars 6.45k forks source link

[BUG] [Golang] unexported name is generated for enum #2050

Open mroland91 opened 5 years ago

mroland91 commented 5 years ago
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

Type: https://github.com/jdegre/5GC_APIs/blob/7298845c7ede07038838d5c40debb083f929f98b/TS29571_CommonData.yaml#L537

**AccessType:
  type: string
  enum:
    - 3GPP_ACCESS
    - NON_3GPP_ACCESS**

Service: https://github.com/jdegre/5GC_APIs/blob/78b04e48a7fb92b1a5dc6f95419c9ed2f6c3c5ed/TS29518_Namf_MT.yaml#L164

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

auto-labeler[bot] commented 5 years ago

👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

vikashsparky commented 3 years ago

You can use --additional-properties=enumClassPrefix=true That will serve the purpose.