Skip to content

Remove spaces in enum names #2

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 1 commit into from
Feb 21, 2019
Merged

Remove spaces in enum names #2

merged 1 commit into from
Feb 21, 2019

Conversation

enmand
Copy link
Contributor

@enmand enmand commented Feb 21, 2019

Enum values can be more than one word, so replace whitespace so that enum names are valid

@enmand enmand requested a review from drwpow February 21, 2019 21:23
src/swagger-2.ts Outdated
@@ -27,7 +27,7 @@ const TYPES: { [index: string]: string } = {
};

function capitalize(str: string) {
return `${str[0].toUpperCase()}${str.slice(1)}`;
return `${str[0].toUpperCase()}${str.slice(1).replace(' ', '')}`;
Copy link
Contributor

@drwpow drwpow Feb 21, 2019

Choose a reason for hiding this comment

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

If it’s all the same, maybe this should go at the end of camelCase instead? I think camelCase is expecting non-spaces anyway.

Something like .replace(/\s+/g, '') (I think in your example, only the first space would be replaced, and then it would skip the rest—maybe).

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, wait—camelCase should be replacing spaces with capital letters. 🤔 Why is that failing for 'American Express'?

@enmand enmand force-pushed the dan/bugfix/enum-whitespace branch 4 times, most recently from dbc9716 to e8965d2 Compare February 21, 2019 21:39
Enum values can be more than one word, so replace whitespace so that
enum names are valid
@enmand enmand force-pushed the dan/bugfix/enum-whitespace branch from e8965d2 to 6e9d3c8 Compare February 21, 2019 22:05
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.

🚀

@enmand enmand merged commit 9947306 into master Feb 21, 2019
@enmand enmand deleted the dan/bugfix/enum-whitespace branch February 21, 2019 22:08
@drwpow drwpow mentioned this pull request Sep 30, 2021
@drwpow drwpow mentioned this pull request Oct 5, 2023
3 tasks
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