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
When a model lists required fields, but additionalProperties is not set, it should treat it as being set to true, but instead the JSON parsing fails with an error like.
#17267 added the validation of unknown properties when required fields are set but additionalProperties is not.
Suggest a fix
I think the problem is that an empty additionalProperties field is not being treated equal to being set to true. As far as I understand that's how it should be handled, though.
The text was updated successfully, but these errors were encountered:
By default, this generator generates closed schemas. It does that for historical reasons, and I think it would be good to change the default at this point.
Until the default configuration is changed, you will need to update your generator config to set disallowAdditionalPropertiesIfNotSet=false. With that setting, the generator will treat an empty additionalProperties as being equal to true.
Bug Report Checklist
Description
When a model lists required fields, but
additionalProperties
is not set, it should treat it as being set to true, but instead the JSON parsing fails with an error like.openapi-generator version
7.12.0
OpenAPI declaration file content or url
Minimal OpenAPI spec to reproduce (
spec.yaml
):Generation Details
Steps to reproduce
Run web server serving problematic (but not incompatible with the spec!) JSON, like the following (
server.go
):using a command like
After generating the client, remove the skip in line ~27 in the test file
test/api_default_test.go
,onstall deps and run the test
go mod tidy go test ./...
Adding
additionalProperties: true
to the spec like following makes the test pass:Related issues/PRs
#17267 added the validation of unknown properties when required fields are set but additionalProperties is not.
Suggest a fix
I think the problem is that an empty
additionalProperties
field is not being treated equal to being set to true. As far as I understand that's how it should be handled, though.The text was updated successfully, but these errors were encountered: