-
Notifications
You must be signed in to change notification settings - Fork 218
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
Add support for untagged union types #2143
Comments
I don't think this is something we can ever reasonably support. You've already called out the difficulty in representing this in a variety of programming languages, and that is a critical issue that can't be ignored. The way you would achieve the same effect in Smithy is to use a Document, as you mentioned, or to use a custom trait/protocol that knows to flatten unions in serialization. |
You might also be interested in the Alloy library from disneystreaming supports untagged unions and integrates it with OpenAPI conversions: https://github.com/disneystreaming/alloy/blob/main/modules/core/resources/META-INF/smithy/unions.smithy#L54 |
Is there a world where this is feasible if it's limited to only simply differentiable types? e.g. |
You can't necessarily know what's simply differentiable or not, it's highly dependant on the protocol. You could imagine an XML protocol that does things like |
Closing as this is something we do not plan to support in Smithy. |
While working on the Smithy specifications for OpenSearch we've come across a need to represent a field that may have more than one type. In this instance the field is
int | boolean
, which could be represented as a plainDocument
type in Smithy, but this would be too broad of a typing.Our primary target from Smithy is OpenAPI where this could map onto a
oneOf
:I understand that probably the largest challenge for adding this to the Smithy language is determining how to and implementing support for this in the various language generators. As we are only targeting OpenAPI an intermediary step of a trait that only affects OpenAPI translation may be a viable solution for now.
The text was updated successfully, but these errors were encountered: