Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #13724
Closed
Open
Issue created Oct 18, 2022 by Administrator@rootContributor3 of 6 checklist items completed3/6 checklist items

[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.

Assignee
Assign to
Time tracking