Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Code generation completely skips "string64" parameter #21014

Open
hw-claudio opened this issue Apr 2, 2025 · 1 comment
Open

[BUG] Code generation completely skips "string64" parameter #21014

hw-claudio opened this issue Apr 2, 2025 · 1 comment

Comments

@hw-claudio
Copy link

hw-claudio commented Apr 2, 2025

Description

SPEC contains (extract of the relevant parts):

components:
  schemas:
    string64:
      maxLength: 64
      type: string

which is then referenced elsewhere with a simple ref:

    hoststate:
      $ref: '#/components/schemas/string64'

The generator completely skips hoststate, leading to errors at buildtime (go-server):

$ java -jar openapi-generator-cli.jar generate -o server/ -g go-server -i openapi-3.1.yaml
$ cd server
$ go build

go/model_host.go:24:12: undefined: Hoststate
...
... too many errors


The generated code also forgets to import "errors" and "io" leading to other build errors that can be easily worked around by manually adding the missing imports (separate issue).

By removing the string64 and directly using "string", the problem goes away, like this:

    hoststate:
      maxLength: 64
      type: string

(leaving only the missing "errors" and "io" imports)

It's painful and less concise though to replace everywhere in the API all references to fixed length types, since they appear many times.

openapi-generator version

using latest stable version, at this time 7.12.0

OpenAPI declaration file content or url
components:
  schemas:
    string64:
      maxLength: 64
      type: string
Generation Details

java -jar openapi-generator-cli.jar generate -o server/ -g go-server -i openapi-3.1.yaml

Steps to reproduce

As per Generation Details and the OpenAPI snippet. Adding any ref to string64 does not work.

Suggest a fix

It should generate the code for all components that reference string64. Currently it silently skips all components that are a $ref to string64.

@hw-claudio
Copy link
Author

apparently just renaming string64 to "shortstring" fixes the issue. So digits seem not to be allowed in a schema name, not sure if expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant