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
  • #3743
Closed
Open
Issue created Aug 23, 2019 by Administrator@rootContributor

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

Assignee
Assign to
Time tracking