-
-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
could certain schemas derived from enums more precisely use oneOf? #98
Comments
What do you think of #96 ? |
@jhoobergs I can see what it's useful for your use case, but I don't really like it for mine. I'd like to be able to generate a client SDK from the OpenAPI spec and I'd like a more direct mapping back into Rust enums. I think a |
Yes that sounds reasonable, and I don't think it would be difficult to implement. I'll take a look when I get some more time - I'd also accept this as a PR |
Thanks! I submitted as #108 |
This behaviour is now available in v0.8.6 |
When writing an SDK generator, we noticed that schemas derived from enums use
anyOf
for complex variants (andenum
for unit variants). This seems necessary in some cases, for example:i.e. where the variants literally cannot be disambiguated. In such a case I don't believe that
oneOf
would be satisfiable since two subschemas would be identical.However with tagged enums (external, internal, or adjacent) would it be reasonable to change
anyOf
tooneOf
? For example in this output of the type above, removing theuntagged
directive:In this case, where each subschema is mutually exclusive, I believe that
anyOf
andoneOf
are equivalent. It would, however, be more explicit to useoneOf
and, as noted earlier, it would simplify our particular use case of SDK generation.If this seems like a reasonable change I'd be happy to submit a PR, but I wanted to check in first.
The text was updated successfully, but these errors were encountered: