Skip to content

AdditionalProperties and oneOf in one Schema#765

Merged
deepmap-marcinr merged 4 commits intooapi-codegen:masterfrom
B-Lorentz:additional-oneOf
Dec 17, 2022
Merged

AdditionalProperties and oneOf in one Schema#765
deepmap-marcinr merged 4 commits intooapi-codegen:masterfrom
B-Lorentz:additional-oneOf

Conversation

@B-Lorentz
Copy link
Copy Markdown
Contributor

@B-Lorentz B-Lorentz commented Sep 30, 2022

Demonstrates and fixes a problem when a schema has both additionalProperties and oneOf union, and two clashing MarshalJSON and UnmarshalJSON methods are generated:

#763

The handling isn't perfect, because the fields that belong to the variants also get copied into the additionalProperties on unmarshal (since in the general case with delayed unmarshalling we don't yet know which of the variants we are dealing with)
but it's strictly better than the previous behaviour when invalid code was generated, while it doesn't change the behaviour in all other cases.

An alternative treatment could be that in such cases the additional properties are "propagated down" into the oneOf elements

@B-Lorentz B-Lorentz changed the title fix: Additional one of AdditionalProperties and oneOf in one Schema Sep 30, 2022
@deepmap-marcinr deepmap-marcinr merged commit e1b4ade into oapi-codegen:master Dec 17, 2022
adrianpk pushed a commit to foorester/oapi-codegen that referenced this pull request Jan 16, 2024
* demonstrate error

* updated templates

* fix template

* test
adrianpk added a commit to foorester/oapi-codegen that referenced this pull request May 31, 2024
* demonstrate error

* updated templates

* fix template

* test
danicc097 pushed a commit to danicc097/oapi-codegen that referenced this pull request Aug 31, 2024
* demonstrate error

* updated templates

* fix template

* test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants