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

Remove internal enum values from validation message #713

Merged
merged 2 commits into from
Mar 15, 2023

Conversation

srchase
Copy link
Contributor

@srchase srchase commented Mar 8, 2023

The enum validation protocol tests were updated in smithy-lang/smithy#1658 to remove enum values with the @internal trait, or which have been tagged with internal. For Smithy IDL 1.0 models which must use the @enum trait (a proper enum shape was introduced with IDL 2.0), the only option for marking an enum value as internal is to use the "internal" tag. For IDL 2.0 models, the preferred way is to use an enum shape, and apply the @internal trait. When Smithy upgrades an enum trait to an enum shape, or downgrades an enum shape to an enum trait, the tags are copied, including an internal tag, but the downgrade does not retain the @internal trait since it cannot be applied to the @enum trait.

For example:

enum Fruit {
    APPLE
    BANANA
    
    @internal
    DURIAN

    @tags(["internal"])
    PAPAYA
}

Validation for the above Fruit enum will check that input is any of the four enum values, but the validation message returned will only include the non-internal values, apple and banana. The same is applied for models which have non-synthetic enum traits, which have not been upgrade to enum shapes.

When https://github.com/aws/aws-sdk-js-v3 updates to use the smithy release that contains smithy-lang/smithy#1658, a PR will be cut to update the generated validation tests.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@srchase srchase requested review from a team as code owners March 8, 2023 16:33
@cmoher cmoher requested a review from gosar March 13, 2023 14:30
@pose pose assigned pose and unassigned pose Mar 13, 2023
@pose pose self-requested a review March 13, 2023 17:53
@@ -503,6 +505,22 @@ private void writeShapeValidator(TypeScriptWriter writer,
});
}

if (shape.isEnumShape()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In smithy-typescript, the code generator does not convert all enum traits to enum shapes, so we have to check the EnumTrait like before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in dc90a62.

@srchase srchase merged commit 5c7495c into smithy-lang:main Mar 15, 2023
@srchase srchase deleted the suppress-internal-enum-values branch March 15, 2023 17:14
srchase added a commit to srchase/smithy-typescript that referenced this pull request Mar 17, 2023
* Remove internal enum values from validation message

* Continue to generate validation for EnumTraits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants