-
Notifications
You must be signed in to change notification settings - Fork 76
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
Normalize enum member name #2839
Open
MaryGao
wants to merge
108
commits into
Azure:main
Choose a base branch
from
MaryGao:enum-key-name-norm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MaryGao
commented
Oct 28, 2024
packages/typespec-ts/test/modularUnit/scenarios/models/serialization/enumKeyNorm.md
Show resolved
Hide resolved
MaryGao
commented
Nov 6, 2024
MaryGao
commented
Dec 11, 2024
@@ -1008,6 +1010,21 @@ describe("model type", () => { | |||
); | |||
}); | |||
|
|||
it("number enum and not ignore warnings", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to keep this case.
…est.typescript into enum-key-name-norm
MaryGao
commented
Jan 2, 2025
packages/typespec-test/test/faceai/generated/typespec-ts/review/ai-face-rest.api.md
Outdated
Show resolved
Hide resolved
MaryGao
changed the title
Normalize enum member name in Modular
Normalize enum member name
Jan 7, 2025
This reverts commit a8f8757.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #2832
fixes #2958
Background
For generated enum we need enum member name and value, and the typespec member name may not be a valid typescript name so we need to normalize them and also normalization could help produce more ts-style SDKs.
Unlike property or model name enum member could be any chars e.g *&^-, so it would require more sanitize logic during normalization. And to be consistant I apply all these rules to other type normalization also. So we could see some breakings in model name and property.
Design consideration
Num
prefix and report warning to remind renaming for customersignoreEnumMemberNameNormalize: true
at package level$DO_NOT_NORMALIZE$
at member level, e.g $DO_NOT_NORMALIZE$VALIDATION_NOT_REQUIRED => VALIDATION_NOT_REQUIRED$filter
tofilter
Cases
Relevant issues