Bug Report Checklist
Description
If parameters names generated in OpenAPI spec are the same as a type in typescript, it will throw errors during build.
openapi-generator version
5.3.0-SNAPSHOT, didn't seems to be a regression
OpenAPI declaration file content or url
openapi: 3.0.0
paths:
/test:
get:
operationId: Test
summary: Test
parameters:
- name: from
required: true
in: query
description: |-
From when to retrieve.
Format ISO 8601 (example: 2021-07-21T13:16:54.050Z)
schema:
format: date-time
type: string
responses:
'200':
description: ''
content:
application/json:
schema:
allOf:
- properties:
nextPageCursor:
type: string
nullable: true
data:
type: array
items:
type: object
tags:
- test
security:
- bearer: []
info:
title: Generates error
description: Generates error
version: 1.0.0
contact: {}
tags: []
servers: []
components:
securitySchemes:
bearer:
scheme: bearer
bearerFormat: JWT
type: http
Generation Details
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate -i /local/openapi.yaml -g typescript -o /local/gen --skip-validate-spec
Steps to reproduce
- Create a file
openapi.yaml and compy the content that is found is this issue.
- execute
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate -i /local/openapi.yaml -g typescript -o /local/gen --skip-validate-spec
cd gen && yarn
- Should generate the following generation error:
Type 'Date' has no call signatures.
31 let middlewarePreObservable = from<RequestContext>(requestContextPromise);
This is due to the fact that "from" is a function imported by Typescript AND the name of the parameter, as you can see it in the generated code:
public test(/*here*/ from: Date, _options?: Configuration): Observable<any> {
const requestContextPromise = this.requestFactory.test(from, _options);
// build promise chain
let middlewarePreObservable = /*here*/ from<RequestContext>(requestContextPromise);
Suggest a fix
If the parameter name can conflict with an internal imported type, rename the parameter to avoid conflicts (in this case, a check that the parameter is not 'from' should do the trick)
Bug Report Checklist
Description
If parameters names generated in OpenAPI spec are the same as a type in typescript, it will throw errors during build.
openapi-generator version
5.3.0-SNAPSHOT, didn't seems to be a regression
OpenAPI declaration file content or url
Generation Details
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate -i /local/openapi.yaml -g typescript -o /local/gen --skip-validate-specSteps to reproduce
openapi.yamland compy the content that is found is this issue.docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate -i /local/openapi.yaml -g typescript -o /local/gen --skip-validate-speccd gen && yarnThis is due to the fact that "from" is a function imported by Typescript AND the name of the parameter, as you can see it in the generated code:
Suggest a fix
If the parameter name can conflict with an internal imported type, rename the parameter to avoid conflicts (in this case, a check that the parameter is not 'from' should do the trick)