Skip to content

Support --type-mappings flag #2373

Open
@thibautcornolti

Description

@thibautcornolti

Description

See https://openapi-generator.tech/docs/usage/#type-mappings-and-import-mappings

I would love to be able to do this command:
openapi-typescript specs/openapi.yaml -o specs/openapi.ts --type-mappings=date-time=Date

To generate the Date type instead of the string type for date-time fields.

Hence, this YAML:

MyEntity:
  type: object
  required:
    - createdAt
  properties:
    createdAt:
      type: string
      format: date-time
      description: When the entity was created

Would generate this TypeScript:

MyEntity: {
    /**
     * Format: date-time
     * @description When the entity was created
     */
    createdAt: Date; // <- instead of string
};

Proposal

Add the same flag as https://openapi-generator.tech/docs/usage/#type-mappings-and-import-mappings, which is --type-mappings

Extra

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestopenapi-tsRelevant to the openapi-typescript library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions