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

[BUG][Typescript] Add 'constructor' to the list of reserved words since a field of that name is not allowed in typescript classes #13724

Closed
3 of 6 tasks
MustansirS opened this issue Oct 18, 2022 · 0 comments · Fixed by #13725

Comments

@MustansirS
Copy link
Contributor

MustansirS commented Oct 18, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant