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
  • #6012
Closed
Open
Issue created Apr 22, 2020 by Administrator@rootContributor5 of 5 checklist items completed5/5 checklist items

[BUG] [javascript-flowtyped] Add Error to language primitives

Created by: thSoft

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
Description

When there is a type named Error in the specification, the generator generates code that does not typecheck.

openapi-generator version

4.3.0

OpenAPI declaration file content or url
openapi: '3.0.0'
info:
  version: 0.0.0
  title: Bug
paths:
  /bug:
    get:
      responses:
        default:
          $ref: '#/components/responses/UnexpectedError'
components:
  responses:
    UnexpectedError:
      description: unexpected error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      properties:
        code:
          type: integer
          format: int32
          example: 500
Command line used for generation

openapi-generator generate -i bug.yaml -g javascript-flowtyped -o bug/

Steps to reproduce
  • Generate code with the above command line
  • Check the generated code with flow check bug
  • You get
Cannot reference type Error [1] from a value position.

     62│  * @class RequiredError
     63│  * @extends {Error}
     64│  */
     65│ export class RequiredError extends Error {
     66│     name:string = "RequiredError"
     67│     constructor(field: string, msg?: string) {
     68│         super(msg);
       :
 [1] 76│ export type Error = {

because JavaScript's built-in Error type conflicts with the generated type alias for the Error record defined in the OpenAPI specification.

Related issues/PRs

I found none.

Suggest a fix

Reject the specification if it contains a type named Error.

Assignee
Assign to
Time tracking