[BUG][Typescript] Add 'constructor' to the list of reserved words since a field of that name is not allowed in typescript classes
Created by: MustansirS
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When generating a Typescript client from specs where API responses have a field named constructor
defined, the generated model file corresponding to the Response object contains the following error: Classes may not have a field named 'constructor'.
openapi-generator version
6.2.0
OpenAPI declaration file content or url
tsbug.yaml
:
openapi: 3.0.2
info:
title: Test API
version: '0.0'
contact:
name: Curvegrid
description: Test API.
servers:
- url: 'https://localhost:8080'
tags:
- name: tests
paths:
/tsbug:
get:
operationId: test-bug
summary: Test bug
description: A test endpoint for the typescript bug.
tags:
- tests
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/TestResponse'
components:
schemas:
TestResponse:
title: TestResponse
type: object
description: The response object for the test endpoint.
properties:
constructor:
type: string
required:
- constructor
Generation Details
Steps to reproduce
openapi-generator generate -g typescript -i tsbug.yaml -o typescript_client
Related issues/PRs
Suggest a fix
Add constructor
to the list of reserved words for the typescript client.