Skip to content

fix: strict server with union type#939

Merged
1 commit merged intooapi-codegen:masterfrom
johanneswuerbach:fix-union
Jun 6, 2023
Merged

fix: strict server with union type#939
1 commit merged intooapi-codegen:masterfrom
johanneswuerbach:fix-union

Conversation

@johanneswuerbach
Copy link
Copy Markdown
Contributor

Fixes #748

Inspired by #865

Encode the .union property when dealing with a .union type.

@johanneswuerbach
Copy link
Copy Markdown
Contributor Author

@deepmap-marcinr sorry for the direct ping, but I wonder if this solution looks reasonable.

@Warboss-rus
Copy link
Copy Markdown
Contributor

I think the proper solution would be to force body to be a separate type with MarshalJSON method (as with other inline unions). For now it looks like a hacky workaround.

@johanneswuerbach johanneswuerbach force-pushed the fix-union branch 3 times, most recently from e4deba3 to ad98f59 Compare June 5, 2023 18:42
@johanneswuerbach
Copy link
Copy Markdown
Contributor Author

@deepmap-marcinr could this also be accepted as a workaround for now?

@ghost
Copy link
Copy Markdown

ghost commented Jun 6, 2023

Yeah, this looks ok. I'll merge it. Thank you.

I have been thinking quite a lot on improving the anyOf/oneOf handling and it's hard - the strict server code was added after the more generic code and there are many edge cases such as this.

@ghost ghost merged commit f5363b0 into oapi-codegen:master Jun 6, 2023
@johanneswuerbach johanneswuerbach deleted the fix-union branch June 6, 2023 15:26
adrianpk pushed a commit to foorester/oapi-codegen that referenced this pull request Jan 16, 2024
adrianpk added a commit to foorester/oapi-codegen that referenced this pull request May 31, 2024
danicc097 pushed a commit to danicc097/oapi-codegen that referenced this pull request Aug 31, 2024
This pull request was closed.
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.

Strict server code generator does not handle properly union type

3 participants