-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
Add new configuration option to preserve javascript enum names #356
Add new configuration option to preserve javascript enum names #356
Conversation
…of invalid characters
🦋 Changeset detectedLatest commit: d315257 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 |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hi @florence-wolfe, thank you for the pull request! Can you clarify why you want to preserve the original enum name? |
In our particular case we have enums such as But beyond that, different organizations and projects have different style guides for variable and enum naming conventions. |
If I propose changes to this pull request, would you be open to doing them or want me to do them? |
Absolutely feel free to leave any kinds of comments. This should be collaborative |
Love it @florence-wolfe! For context, we're trying to balance asks from different people with maintaining a healthy codebase. My take is we should be opinionated whenever possible to avoid guiding people down the wrong path. For example, allowing people to use positional arguments was a decision that's hard to migrate from and harder to maintain than if Couple of thoughts:
What are your thoughts? Separately, I'm curious what made you use |
We could also consider preserving names being the only option. The challenge with that is that TypeScript variant will conflict with generated |
@florence-wolfe I am going to move enums to a separate file so we are not blocked on conflicts and we can figure out what to do about the rest of open questions when you're around EDIT: done |
@florence-wolfe got a pull request for moving enums into their own file #358 I am not opposed to enum names being preserved with illegal characters being replaced with underscore |
👋 thanks for your time and effort @mrlubos . Unfortunately, the change to a separate enum file is going to mean I need to find a new tool since I need a single file output. I'm going to close this as it's no longer relevant to me nor my team, but by all means feel free to reopen if you have a better approach that aligns better with the architecture here! 👍 All the best! |
@florence-wolfe Can you explain more about why you need a single file output? |
@florence-wolfe bump |
Our team has hundreds of engineers so the least overhead possible was desirable. With that said, we're moving to Protobuf and won't be moving forward with OAS any further. Thanks again! |
Got it @florence-wolfe, thank you! Feel free to reach out if you consider OpenAPI in the future |
👋 My team and I really want to use JavaScript enums but we also want to preserve the original enum name as closely as possible.
This PR introduces a new
javascript-preserve-name
configuration option for theenums
field. When selected it will go through a slightly different path in the models code to only strip out invalid characters and unescape the name. Beyond that it will leave the name as-is, preserving casing and valid characters.For example, given the following enum found in an openapi schema:
This would then output the following:
with
javascript-preserve-output
with the original
javascript
option:and with the
typescript
option: