Skip to content
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

support openEnum trait on String with @enum #111

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ Specifies that an enumeration is open meaning that it can accept "unknown" value
This trait should be mainly be used for interop with external libraries that require it. Often a string or integer type may be more applicable if there are many different
possible values that the API can return.

This trait can be applied to `enum` or `intEnum` shapes.
This trait can be applied to `enum` or `intEnum` shapes. Additionally it can be used on String shapes with the `smithy.api#enum` trait. This is supported for backward compatibility since the `enum` constraint trait is deprecated.

```smithy
@openEnum
Expand Down
2 changes: 1 addition & 1 deletion modules/core/resources/META-INF/smithy/enums.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace alloy
/// Specifies that an enumeration is open meaning that
/// it can accept "unknown" values that are not explicitly
/// specified inside of the smithy enum shape definition.
@trait(selector: ":test(enum, intEnum)")
@trait(selector: ":test(enum, intEnum, [trait|enum])")
structure openEnum {}
4 changes: 4 additions & 0 deletions modules/core/test/resources/META-INF/smithy/traits.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,7 @@ enum TestOpenEnum {
intEnum TestOpenIntEnum {
ONE = 1
}

@openEnum
@enum([{value: "A", name: "A"}])
string TestOpenEnumTraitEnum
Loading