OpenAPITools / OpenAPITools/openapi-generator
[REQ] Go Server Default values
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
go-server codegen defaultValue is null
We have extended the go-server templates to generate our own specific code.
Here we also use the "{{defaultValue}}" in our templates. We found an issue in the file
org/openapitools/codegen/languages/AbstractGoCodegen.java
in the method toDefaultValue
Change toDefaultValue method
By comparing then Codegen class with other Codegen classes this code works better for us:
org/openapitools/codegen/languages/AbstractGoCodegen.java LINE 727
@Override
public String toDefaultValue(Schema schema) {
if (schema.getDefault() != null) {
return schema.getDefault().toString();
} else {
schema = ModelUtils.getReferencedSchema(this.openAPI, schema);
if (schema.getDefault() != null) {
return schema.getDefault().toString();
}
return null;
}
}
Is it possible to change that code?
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
Start in org/openapitools/codegen/languages/AbstractGoCodegen.java, at the toDefaultValue method around line 727. Compare its handling of referenced schemas with the other Codegen classes mentioned in the issue. Done means Go server templates receive the expected defaultValue when the default is defined on a referenced schema.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100