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
There is an inconsistency in type generation for object schema with additionalProperties. Specifically, when additionalProperties is set to {} (an empty object), it should be treated the same as when additionalProperties is set to true, but currently it is not, leading to incorrect type generation.
Additionally, the swaggo/swag leads to additionalProperties: {} being generated, which results in incorrect output.
// Pet struct for PettypePetstruct {
ConfigWrongmap[string]map[string]interface{} `json:"config_wrong,omitempty"`ConfigCorrectmap[string]interface{} `json:"config_correct,omitempty"`
}
Generation Details
openapi-generator generate -g go -o pkg/api -i openapi.yaml --additional-properties=packageName=api,withGoMod=false
Steps to reproduce
openapi-generator generate -g go -o pkg/api -i openapi.yaml --additional-properties=packageName=api,withGoMod=false
Related issues/PRs
None found.
Suggest a fix
A potential fix would be to standardize the handling of additionalProperties: {} and additionalProperties: true to be treated equivalently, as both should allow for an unspecified number of additional properties. This requires a modification in the parser logic to treat empty object {} as a wildcard, similar to true.
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
There is an inconsistency in type generation for object schema with additionalProperties. Specifically, when additionalProperties is set to {} (an empty object), it should be treated the same as when additionalProperties is set to true, but currently it is not, leading to incorrect type generation.
Additionally, the swaggo/swag leads to additionalProperties: {} being generated, which results in incorrect output.
openapi-generator version
7.10.0
OpenAPI declaration file content or url
yaml to reproduce the bug
and the result is
Generation Details
openapi-generator generate -g go -o pkg/api -i openapi.yaml --additional-properties=packageName=api,withGoMod=false
Steps to reproduce
openapi-generator generate -g go -o pkg/api -i openapi.yaml --additional-properties=packageName=api,withGoMod=false
Related issues/PRs
None found.
Suggest a fix
A potential fix would be to standardize the handling of additionalProperties: {} and additionalProperties: true to be treated equivalently, as both should allow for an unspecified number of additional properties. This requires a modification in the parser logic to treat empty object {} as a wildcard, similar to true.
The text was updated successfully, but these errors were encountered: