OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Go] Schemas starting with number generated incorrectly to go types
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Hi
when we have a schema which include a proporties which starts with number the relevant go datatype is generated incorrectly, since it will be started with the number. It is interesting that the first level is generated correctly.
Problematic schema:
5GsUserStateInfo:
type: object
properties:
5gsUserState:
$ref: '#/components/schemas/5GsUserState'
accessType:
$ref: 'TS29571_CommonData.yaml#/components/schemas/AccessType'
required:
- 5gsUserState
- accessType
5GsUserState:
anyOf:
- type: string
enum:
- DEREGISTERED
- CONNECTED_NOT_REACHABLE_FOR_PAGING
- CONNECTED_REACHABLE_FOR_PAGING
- NOT_PROVIDED_FROM_AMF
- type: string
Generated datatypes: 5GsUserStateInfo is correct, since "Model" and "Var" was added. But inside the 5GsUserState, those starts with "5"
// Model5GsUserStateInfo struct for Model5GsUserStateInfo
type Model5GsUserStateInfo struct {
Var5gsUserState Model5GsUserState `json:"5gsUserState"`
AccessType AccessType `json:"accessType"`
}
// Model5GsUserState struct for Model5GsUserState
type Model5GsUserState struct {
5GsUserStateAnyOf *5GsUserStateAnyOf
string *string
}
// 5GsUserStateAnyOf the model '5GsUserStateAnyOf'
type 5GsUserStateAnyOf string
Can you check this and correct it? Or suggest how can we avoid this.....(OK, do not use shcemas which starts with number, but this should be discussed with the 3GPP standardization guys ;-)
Thanks
Akos
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 Go datatype generation with the supplied TS29518_Namf_EventExposure.yaml schema, focusing on 5GsUserStateInfo and 5GsUserState. Trace the Go generator's model and property name generation, then verify that identifiers beginning with numbers become valid Go names while preserving the JSON names. Add or run a regression test using this schema and compare the generated output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100