OpenAPITools / OpenAPITools/openapi-generator

[BUG] [Go] declared type cannot begin with numerals

Open
#3,226 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug Server: Go
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • [ ] Have you provided a full/minimal spec to reproduce the issue?
    yes
  • [ ] Have you validated the input using an OpenAPI validator ([example]
    (https://apidevtools.org/swagger-parser/online/))?
    yes
  • [ ] What's the version of OpenAPI Generator used?
    4.0.0
  • [ ] Have you search for related issues/PRs?
    yes
  • [ ] What's the actual output vs expected output?

Actual :
package model
// Model5GInterfaceType : 5G interface type
type 5GInterfaceType string
// List of 5GInterfaceType
const (
N2 Model5GInterfaceType = "n2"
N3 Model5GInterfaceType = "n3"
)

Expected :

package model
// Model5GInterfaceType : 5G interface type
type Model5GInterfaceType string
// List of 5GInterfaceType
const (
N2 Model5GInterfaceType = "n2"
N3 Model5GInterfaceType = "n3"
)

  • [Optional] Bounty to sponsor the fix (example)
Description
openapi-generator version
OpenAPI declaration file content or url
Command line used for generation
java -jar ./openapi-generator-cli.jar generate -g go-server -i ./cmd/lizard-rest/yaml/test.yaml -o ./cmd/lizard-rest/generated/ --additional-properties packageName=model

test.txt

Steps to reproduce
Related issues/PRs
Suggest a fix

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

Start by reproducing the issue with the go-server generator command and the linked OpenAPI schema containing the 5GInterfaceType name. Check the generated Go model and verify that the declared type uses a valid identifier such as Model5GInterfaceType, with generation producing compilable output.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
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.