Skip to content

fix: Enum option cannot generate enums if values are not valid property names #1761

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

Merged
merged 4 commits into from
Jul 16, 2024

Conversation

yoshi2no
Copy link
Contributor

Changes

#1722

Made the following changes:

  • Quote the name if it consists entirely of invalid characters.
  • Replace only the invalid characters with "_" if they are part of the name.

The existing logic that replaces invalid characters within a key name with "_" has been kept. Additionally, by quoting the name when it consists entirely of invalid characters, it helps prevent errors.

How to Review

Ensure that the test passes.

Checklist

  • Unit tests updated
  • docs/ updated (if necessary)
  • pnpm run update:examples run (only applicable for openapi-typescript)

@yoshi2no yoshi2no requested a review from a team as a code owner July 15, 2024 04:08
Copy link

changeset-bot bot commented Jul 15, 2024

🦋 Changeset detected

Latest commit: 59c6033

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openapi-typescript Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@drwpow drwpow left a comment

Choose a reason for hiding this comment

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

Great fix, thank you! However this needs a Changeset to generate a release. See the Changeset comment for instructions on how to make a patch change for openapi-typescript.

@yoshi2no
Copy link
Contributor Author

Great fix, thank you! However this needs a Changeset to generate a release. See the Changeset comment for instructions on how to make a patch change for openapi-typescript.

@drwpow

Thank you for the review! I have added the changeset.

@yoshi2no yoshi2no requested a review from drwpow July 16, 2024 15:20
Copy link
Contributor

@drwpow drwpow left a comment

Choose a reason for hiding this comment

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

Thank you!

@drwpow drwpow merged commit 8043c5d into openapi-ts:main Jul 16, 2024
7 checks passed
@github-actions github-actions bot mentioned this pull request Jul 16, 2024
kerwanp pushed a commit to kerwanp/openapi-typescript that referenced this pull request Jul 29, 2024
…ty names (openapi-ts#1761)

* chore(test): add InvalidPropertyNameChars with enum flag

* fix: Quote the name if it consists entirely of invalid characters and replace only the invalid characters with "_" if they are part of the name

* chore: fix lint error

* chore: add changeset patch md
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.

2 participants