OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
20.74k stars 6.32k forks source link

[BUG] [typescript-axios] Property of number type incorrectly typed as BigDecimal #5919

Open faheem00 opened 4 years ago

faheem00 commented 4 years ago
Description

When generating an openapi using the typescript-axios tool, a property with type as string and format as number generates a type BigDecimal for the generated api.ts file. However, the BigDecimal type does not exist.

example -

properties:
    example:
        type: string
        format: number

generated code -

/**
 * 
 * @export
 * @interface Example
 */
export interface Example {
    /**
     * Example
     * @type {BigDecimal}
     * @memberof Example
     */
    example?: BigDecimal;
}
openapi-generator version

1.0.12-4.3.0

Command line used for generation

node node_modules/@openapitools/openapi-generator-cli/bin/openapi-generator generate -i ./src/openapi.yaml -g typescript-axios -o ./lib -c ./config.json

Related issues/PRs

This may be related - Link to an issue in swagger-codegen

auto-labeler[bot] commented 4 years ago

👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

amakhrov commented 4 years ago

You can probably solve it at your side by providing --type-mappings BigDecimal=string cli argument to the generator.

Looks like such type mapping should be the default behavior for typescript generators. Would you mind filing a PR for that?