You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
While generating Go SDK with OpenAPI Generator, if a composite schema's parent schema contains names with special characters (. _) and a discriminator is defined on the parent schema, Go SDK fails because the sanitized name of the parent model is not used in the composite schema model.
Generate the Go SDK with the specified spec file and observe that the parent schema model name in the composite schema model is not sanitized.
Actual Parent model file
type BaseItem struct {
Title string `json:"title"`
Type string `json:"type"`
}
Actual Composite model file
when referring to the parent schema Base.Item which is not sanitized name, it leads to failure of generated SDK, Instead of referring to sanitized name(BaseItem) of parent model
mohamuni
changed the title
[BUG] [Go] Go SDK breaks for schema names with special character(._)
[BUG] [Go] Go SDK breaks for parent schema names with special character(._)
May 10, 2024
Bug Report Checklist
Description
While generating Go SDK with OpenAPI Generator, if a composite schema's parent schema contains names with special characters (. _) and a discriminator is defined on the parent schema, Go SDK fails because the sanitized name of the parent model is not used in the composite schema model.
openapi-generator version
Latest version(7.5.0)
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Generate the Go SDK with the specified spec file and observe that the parent schema model name in the composite schema model is not sanitized.
Actual Parent model file
Actual Composite model file
when referring to the parent schema Base.Item which is not sanitized name, it leads to failure of generated SDK, Instead of referring to sanitized name(BaseItem) of parent model
Expected model definition in Composite schema model file.
Suggest a fix
In following file, when checking for parent model for composite schema, specify to use parentmodel.classname instead of parentmodel.name
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/go/model_simple.mustache
Following changes are suggested along with line numbers
The text was updated successfully, but these errors were encountered: