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

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

Open
adamhari opened this issue Dec 4, 2020 · 2 comments
Open

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

adamhari opened this issue Dec 4, 2020 · 2 comments

Comments

@adamhari
Copy link

adamhari commented Dec 4, 2020

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.

@hitendramalviya
Copy link

A Similar issue I have also encountered, I also notice in addition that, it is not even generating models with correct static typing everything defined as : anyunderneath it.

@cole-floodbase
Copy link

Same issue in TypeScript Angular. I get autogenerated types like Array<string> | Map;

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

No branches or pull requests

3 participants