Skip to content

[Typescript Axios] Type annotations are escaping special characters #10595

@adamhari

Description

@adamhari
Description

I am using the typescript-axios preset to generate the API client. The generated code is using HTML escaping which is causing certain type annotations, particularly ones which use special characters, to not get recognized by Typescript in my client codebase.

Below is what the outputted client code looks like:

export interface ServerpbInvoice {
    /**
     * @inject_tag: validate:\"required\"
     * @type {Array<ServerpbInvoiceItems>}
     * @memberof ServerpbInvoice
     */
    items: any;
    ...
}
Swagger-codegen version

3.0.23

Swagger declaration file content or url
{
    ...
    "definitions": {
        "serverpb.Invoice": {
            "type": "object",
            "required": [
                ...
            ],
            "properties": {
                ...
                "items": {
                    "description": "@inject_tag: validate:\"required\"",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/serverpb.InvoiceItems"
                    }
                },
            }
        }
    }
    ...
}
Command line used for generation

swagger-codegen generate -i docs/swagger.json -l typescript-axios -o ./generated

Steps to reproduce
  1. Run the command described above to generate an API client
  2. Reference a property with escaped special characters in the type annotation
  3. Run the Typescript compiler
Related issues/PRs

I could not find any.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions