[BUG] typescript-axios sometimes generates unused imports
Created by: silasdavis
Provided fix here: #3742
Running with generator version: 4.1.1-SNAPSHOT
(docker image 95e2e965b1fe
)
The following valid swagger spec (there's nothing special about this to create the issue):
{
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"schemes": [
"http",
"https"
],
"swagger": "2.0",
"info": {
"description": "Test",
"title": "API",
"version": "0.0.1"
},
"host": "example.com",
"basePath": "/",
"paths": {
"/account": {
"get": {
"operationId": "getAccount",
"responses": {
"200": {
"description": "foo"
}
}
}
}
}
}
Is sufficient to replicate. Code generated with:
openapi-generator-cli generate \
-i swagger-testcase.json \
-g typescript-axios \
-o api
Then api.ts
contains unused imports COLLECTION_FORMATS
and RequiredError
:
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from
base.ts
contains unused imports AxiosPromise
:
import globalAxios, { AxiosPromise, AxiosInstance } from 'axios';
Generates errors like TS6133: 'AxiosPromise' is declared but its value is never read.
Note this is a typescript compiler error so not supressed by the file-wide tslint:disable
(in fact this means you can't easily fix with tslint --fix
) unused imports.