-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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][Go] Default string values of enums are not double quoted #14665
Comments
after digging into this more, I'm not sure that this is a bug, or at least its an easy to workaround one. In the spec that was given, we see a property with allOf{}, but only one type set:
So, for it to know how to write the default, it would have to consider all possibilities within allOf. Here there is only one possibility, so rewriting it like so:
makes much more sense and results in a valid client. I will file a pulp bug |
Reopening, as a pulp developer mentioned that $ref in a property overrides siblings, (such as default and description), so this bug still seems valid and not easily worked around |
Bug Report Checklist
Description
When trying to generate a Go client binding for pulp (https://docs.pulpproject.org/pulp_rpm/_static/api.json), default values that are strings do not seem to be double quoted:
For example, a generated model for the mentioned spec is:
This fails to compile, and the generated tests fail with:
I would expect immediate to be wrapped in double quotes:
I suspect that this is related to toDefaultValue() here: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientCodegen.java#L391-L405
Its either not being called, or is not detecting the string properly. The value mentioned is an enum and from testing with a simplified example, that is the root of the problem
openapi-generator version
6.4.0-SNAPSHOT
2023-02-09T02:46:35Z
OpenAPI declaration file content or url
http://localhost:8080/pulp/api/v3/docs/api.json
i've created a simpler example here: https://gist.github.com/jlsherrill/af376f50ca7692332ab19ce01d88ee11
Generation Details
Steps to reproduce
Generate go bindings with the above command, and then run the resulting tests:
Related issues/PRs
Suggest a fix
Currently working to get a build going to try to debug further.
The text was updated successfully, but these errors were encountered: