openapi-typescript-codegen icon indicating copy to clipboard operation
openapi-typescript-codegen copied to clipboard

Schema object called `default` generates invalid TypeScript raising reserved keyword error

Open mb21 opened this issue 3 years ago • 0 comments

Sample schema which validates:

openapi: 3.0.0
info:
  version: 1.0.0
  title: Simple API


components:
  schemas:
    default:
      type: object
      properties:
        name:
          type: string

paths:
  /artists:
    get:
      description: Returns a list of artists 
      responses:
        '200':
          description: Successfully returned a list of artists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/default'


generates:

export type default = {
    name?: string;
};

which fails tsc with:

Identifier expected. 'default' is a reserved word that cannot be used here

Would that be easy to fix? In what file? Thanks!

mb21 avatar Aug 08 '22 09:08 mb21