GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||
GeezerVison is showing github.com — feat: add code generation for discriminator with allOf by RasankRam · Pull Request #2114 · oapi-codegen/oapi-codegen Conversation
|
|
Hey @jamietanna, we meet again! How's it going?? Our teams have just run into this issue as well. Seems like this has been unsupported since 2022 (first issue). Totally get there's likely a reason as well. Any chance that this PR could get looked at sooner than later? Totally cool if not, but figured I'd shoot my shot. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
This is a nice change, however, it's also a bit scary, and I do believe it is breaking, so that it would have to be put behind a default-disabled flag. allOf/anyOf/oneOf have been very difficult to support and I tried all kinds of things until we got where we are today as a least broken approach. The reason it's breaking is that you can no longer generate It's a bit tricky to wrap your head around the meaning of recursive Now, let's chat about discriminators, and merging schemas with contain them. Say we have a top level type, As I understand your code, if I was to make something like this pseudocode: It would fail because of discriminator conflict. Now, is this a valid example? I don't know. If it worked, a I think the only real problem happens if both of the constituent schemas share a discriminator by the same name. Should the top level merged type even have a discriminator? I'm not sure if it needs one to work, but it does need to have one given how OpenAPI specifies that properties are merged in Anyhow, edge cases like these are why I avoided solving as much of this problem as possible, and left it to application logic to figure it out. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
ced092f to
4e63505
Compare
|
Hi, @mromaszewicz . Thanks for your feedback! Regarding the breaking change - indeed, my changes were introducing a breaking change. I reconsidered the discriminator logic - I had code that inherited discriminators when merging allOf. Now, the discriminator is only extracted from the original schema. I agree with the The only case that still errors out is when both schemas have discriminators with the same property name - I don't know what to do with this case, so I'm rejecting it. I pushed the changes, rebased, and squashed the commits. Also, I would like to ask a question about the necessity of the
I added it for compatibility with |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hello @jamietanna, any updates on this issue? We’re also missing support for |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi, we're also really looking forward to this feature |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
4e63505 to
f8829bd
Compare
|
Thanks for your use of |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It's on our TODO list: #2170 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
00fd7e0 to
08488aa
Compare
9c3d31a to
8b693a8
Compare
8b693a8 to
05ce684
Compare
| // Reject same discriminator property names in allOf | ||
| if allOf && s1.Discriminator != nil && s2.Discriminator != nil && s1.Discriminator.PropertyName == s2.Discriminator.PropertyName { | ||
| return openapi3.Schema{}, fmt.Errorf("merging two schemas with the same discriminator property name "+ | ||
| "(%q) in allOf is not supported", s1.Discriminator.PropertyName) | ||
| } | ||
|
|
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This PR actually solved an issue I was having with missing child schemas, unfortunately this change surfaced an error which made a schema that previously generated successfully error out which might be good to be aware of.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
At least 1 approving review is required to merge this pull request.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.