Skip to content
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

enums with spaces throw an error #71

Closed
brookjordan opened this issue Aug 3, 2020 · 3 comments
Closed

enums with spaces throw an error #71

brookjordan opened this issue Aug 3, 2020 · 3 comments
Assignees
Labels
bug Something isn't working next release

Comments

@brookjordan
Copy link
Contributor

brookjordan commented Aug 3, 2020

For example I have:

enum: [resolved, new, in progress]

And I get this error:

☄️  start generating your typescript api
SyntaxError: An enum member name must be followed by a ',', '=', or '}'. (19:6)
  17 |   resolved = "resolved",
  18 |   new = "new",
> 19 |   in progress = "in progress" 
     |      ^
  20 |  }
  21 | 
    at t (/project/node_modules/prettier/parser-typescript.js:1:287)
    at Object.parse (/project/node_modules/prettier/parser-typescript.js:14:2633274)
    at Object.parse (/project/node_modules/prettier/index.js:11370:19)
    at coreFormat (/project/node_modules/prettier/index.js:14784:25)
    at format (/project/node_modules/prettier/index.js:15019:75)
    at formatWithCursor (/project/node_modules/prettier/index.js:15035:12)
    at /project/node_modules/prettier/index.js:51620:12
    at Object.format (/project/node_modules/prettier/index.js:51640:12)
    at /project/node_modules/swagger-typescript-api/src/index.js:89:39 {

This is because it doesn’t add quotes around the enum declaration. That is, instead of outputting:

export enum Enum {
  resolved = "resolved",
  new = "new",
  in progress = "in progress",
}

should be:

export enum Enum {
  resolved = "resolved",
  new = "new",
  "in progress" = "in progress",
}
@js2me
Copy link
Member

js2me commented Aug 3, 2020

@brookjordan Thanks for this issue, it will be fixed in next release!

@js2me js2me self-assigned this Aug 3, 2020
@js2me js2me added bug Something isn't working next release labels Aug 3, 2020
@js2me
Copy link
Member

js2me commented Aug 18, 2020

I think it should be better like:
image

@js2me js2me mentioned this issue Aug 19, 2020
@js2me
Copy link
Member

js2me commented Aug 19, 2020

Fixed in 1.12.0!

@js2me js2me closed this as completed Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working next release
Projects
None yet
Development

No branches or pull requests

2 participants