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

[Bug][TypeScript]: single quote in enums not escaped #7369

Open
macjohnny opened this issue Jan 11, 2018 · 4 comments
Open

[Bug][TypeScript]: single quote in enums not escaped #7369

macjohnny opened this issue Jan 11, 2018 · 4 comments

Comments

@macjohnny
Copy link
Contributor

Description

When defining a model property as an enum, single quotes are not escaped.

Example input:

definitions:
  Order:
    title: Pet Order
    description: An order for a pets from the pet store
    type: object
    properties:
      status:
        type: string
        description: Order Status
        enum:
          - pla'ced
          - approved
          - delivered

Example output:

export interface Order {
    status?: Order.StatusEnum;
}
export namespace Order {
    export type StatusEnum = 'pla'ced' | 'approved' | 'delivered';
    export const StatusEnum = {
        Placed: 'pla'ced' as StatusEnum,
        Approved: 'approved' as StatusEnum,
        Delivered: 'delivered' as StatusEnum
    }
}
Swagger-codegen version

2.3.0

Suggest a fix/enhancement

Fixing the escaping in https://github.com/swagger-api/swagger-codegen/blob/v2.3.0/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractTypeScriptClientCodegen.java#L342
should solve the issue.
The escapeText() method in
https://github.com/swagger-api/swagger-codegen/blob/v2.3.0/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java#L376
does not escape single quotes.

@macjohnny
Copy link
Contributor Author

@macjohnny
Copy link
Contributor Author

cc @wing328

@macjohnny
Copy link
Contributor Author

this issue also affects the typescript angular generator

@macjohnny
Copy link
Contributor Author

@wing328 could you add this to the 2.4.0 milestone?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants