-
-
Notifications
You must be signed in to change notification settings - Fork 577
support conditional ts enums #2433
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: ad43b6a The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
❌ Deploy Preview for openapi-ts failed.
|
hi @htunnicliff it seems the build failures are due to an issue fetching a particular github contributor:
did you want me to amend the logic in |
hi @drwpow I don't suppose you could take a look please? |
Changes
Adds support (via optional flag) for generating TS Enums only where there is relevant metadata.
TS Enums can provide useful mappings in specific circumstances:
but is also entirely redundant in many others:
This PR provides an optional
--conditional-enums
flag to only create TS Enums where relevant mapping metadata has been explicitly added:Converts to
The particular use case I am targeting is for established code bases that rely 95% on simple type unions, but may occasionally wish to store enum mappings in OAPI where appropriate.
This feature would assist in cases such as #941 and #2366.
How to Review
Prepare an OAPI schema with two kinds of enums, one with metadata and one without (see above
Status
/StatusEnum
example).Test generating typings with the
enum
flag enabled, and then toggle theconditionalEnums
to compare the differences in result.Checklist
docs/
updated (if necessary)pnpm run update:examples
run (only applicable for openapi-typescript)