Skip to content

generating client with Axios Template and useAbortSignal true imports deprecated CancelToken type #5318

@stephenmetzger99

Description

@stephenmetzger99

Describe the bug

I am generating a typescript api client for my dotnet api. I am using the axios template.

The bug I am running in to is when I use useAbortSignal: true to generate my client, it still generates an import for CancelToken at the top of the client:

import type { AxiosInstance, AxiosRequestConfig, AxiosResponse, CancelToken } from 'axios';

My understanding is that with Axios they had their own implementation of cancellation but it was deprecated after AbortSignal debuted.

This is an issue because the generated api client has an error in it since CancelToken is deprecated and no longer available.

Version of NSwag toolchain, computer and .NET runtime used

.NET Core Net90
toolchain v14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))
Ubuntu 24 LTS
Lenovo Yoga 2017

"openApiToTypeScriptClient": {
"className": "{controller}Client",
"moduleName": "",
"namespace": "",
"typeScriptVersion": 4.3,
"template": "Axios",
"promiseType": "Promise",
"withCredentials": true,
"useSingletonProvider": false,
"dateTimeType": "Date",
"nullValue": "Undefined",
"generateClientClasses": true,
"generateClientInterfaces": true,
"generateOptionalParameters": true,
"exportTypes": true,
"wrapDtoExceptions": true,
"exceptionClass": "ApiException",
"clientBaseClass": null,
"wrapResponses": false,
"wrapResponseMethods": [],
"protectedMethods": [],
"configurationClass": null,
"generateDtoTypes": true,
"operationGenerationMode": "MultipleClientsFromFirstTagAndOperationName",
"includedOperationIds": [],
"excludedOperationIds": [],
"markOptionalProperties": true,
"generateCloneMethod": false,
"typeStyle": "Interface",
"enumStyle": "Enum",
"useLeafType": false,
"classTypes": [],
"extendedClasses": [],
"extensionCode": null,
"generateDefaultValues": true,
"excludedTypeNames": [],
"excludedParameterNames": [],
"handleReferences": false,
"generateTypeCheckFunctions": false,
"importRequiredTypes": true,
"baseUrlTokenName": "API_BASE_URL",
"queryNullValue": "",
"useAbortSignal": true,
"output": "../web/src/api/api-client.ts",
"newLineBehavior": "Auto"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions