OpenAPITools / OpenAPITools/openapi-generator

[BUG] [Go] Schemas starting with number generated incorrectly to go types

Open
#11,320 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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.

yaml file: https://forge.3gpp.org/swagger/editor-versions/v3.18.0/?url=https://forge.3gpp.org/rep/all/5G_APIs/raw/REL-16/TS29518_Namf_EventExposure.yaml

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.