Open thSoft opened 4 years ago
When there is a type named Error in the specification, the generator generates code that does not typecheck.
4.3.0
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
openapi-generator generate -i bug.yaml -g javascript-flowtyped -o bug/
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.
I found none.
Reject the specification if it contains a type named Error.
👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
Bug Report Checklist
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
Command line used for generation
openapi-generator generate -i bug.yaml -g javascript-flowtyped -o bug/
Steps to reproduce
flow check bug
You get
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.