Repository navigation
Support top level oneOf and anyOf #388
Description
Activity
forest-benchling commented
on Apr 14, 2021 CollaboratorAuthorMore actionsforest-benchling commented
on Apr 19, 2021 CollaboratorAuthorMore actionsI guess on second thought here, it's unclear how we'd actually represent a model which is nothing other than a union of other models. Maybe the desired outcome of this ticket is simply to raise an error during code generation?
For
oneOfwe should probably make a type alias toUnion[ThingOne, ThingTwo].anyOfis a lot harder... my read of it is that it has to validate against at least one schema but can contain properties of other schemas. So we might have to generate several models, each of which has the requirements of one schema and optional fields from all of the others. Sounds messy.I'd love to know how folks are actually using
anyOfto get a better feel for how the implementation should shake out.- added✨ enhancementNew feature or improvementNew feature or improvementand removed🐞bugSomething isn't workingSomething isn't working
on Dec 18, 2021 - changed the title
[-]Models generated with `oneOf` or `anyOf` have empty properties[/-][+]Support top level `oneOf` and `anyOf`[/+]on Dec 18, 2021 Openapi schemas can combine oneOf anyOf allOf and properties all in a single schema.
So I don't think thatFor oneOf we should probably make a type alias to Union[ThingOne, ThingTwo]would work for all cases.What is the status for this issue? Because I am in a situation there I need it and would love to not create workarounds for it 😉
- added🍭 OpenAPI ComplianceSupporting a new bit of the OpenAPI specSupporting a new bit of the OpenAPI spec
on Aug 13, 2023 - locked and limited conversation to collaborators
on Aug 13, 2023
Describe the bug
If a top-level schema is defined using
oneOforanyOf, the generated model has no properties.To Reproduce
See this PR which adds a test case for the bug: #387
Expected behavior
It should work the same way as it does for model properties, i.e., constructing a union type.
OpenAPI Spec File
#387
Desktop (please complete the following information):