You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What, if any limitations are there on the values of an string decorated with the @enum trait? Specifically, Should it be valid for enum's to be modeled with empty string values? I'm asking this question because it will direclty drive how the v2 AWS SDK for Go is able to codegen enum shapes.
I'd like to suggest that enum shapes should not be modeled with enum values of empty string. With validation returning and error if there are empty string value enums.
This question and proposal is similar to stating enum strings have a default value, i.e. empty string. This default value allows SDK to not need to distinguish the difference between unset and empty string. This removes the need for languages like Go to use pointers (aka optional) for enum shapes. The zero value (default) of the enum type would be equivalent to the unset or empty string value.
With this proposal, code generators for languages like Go would not distinguish the difference between unset, null, or empty string of enum values during deserialization. During serialization a unset,null,empty string would also be interpreted as unset, and not be serialized. Or in case of sparse list/map serialized as the protocol's null value.
The text was updated successfully, but these errors were encountered:
The value property of a definition in the @enum trait is defined as a string with a minimum length of 1. We can update the specification to state this more clearly, but the proposed state is already the case in implementation. An empty value would throw a model validation error like this:
[Error] ns.foo#Invalid: Error validating trait `enum`.0.value: String value provided for `smithy.api#NonEmptyString` must be >= 1 characters, but the provided value is only 0 characters. | TraitValue N/A:0:0
Thanks for the feedback! I wasn't aware of the minimum length trait on enum values. This is very helpful. I think with that information it clarifies that the v2 AWS SDK for Go could safely render enum shapes as values, not pointers (aka optional). Since the SDK can use the empty string to identify that the user of the SDK has not provided a valid value.
What, if any limitations are there on the values of an string decorated with the
@enum
trait? Specifically, Should it be valid for enum's to be modeled with empty string values? I'm asking this question because it will direclty drive how the v2 AWS SDK for Go is able to codegen enum shapes.I'd like to suggest that enum shapes should not be modeled with enum values of empty string. With validation returning and error if there are empty string value enums.
This question and proposal is similar to stating enum strings have a default value, i.e. empty string. This default value allows SDK to not need to distinguish the difference between unset and empty string. This removes the need for languages like Go to use pointers (aka optional) for enum shapes. The zero value (default) of the enum type would be equivalent to the unset or empty string value.
With this proposal, code generators for languages like Go would not distinguish the difference between unset, null, or empty string of enum values during deserialization. During serialization a unset,null,empty string would also be interpreted as unset, and not be serialized. Or in case of sparse list/map serialized as the protocol's null value.
The text was updated successfully, but these errors were encountered: