Open hagevvashi opened 4 years ago
@hagevvashi thanks for reporting the issue. Do you mind filing a PR with the suggested fix so that we can review and test more easily?
@wing328
Thank you for your reply.
No, I don't mind filing a PR. I'm going to submit a PR.
@hagevvashi @wing328 are you sure you don't need the url
dependency in the codebase for the request to work? In my petstore example, it generated the following code that depends on the url
package to be available as a dependency.
createPets: async (options: any = {}): Promise<RequestArgs> => {
const localVarPath = `/pets`;
const localVarUrlObj = globalImportUrl.parse(localVarPath, true);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query};
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: globalImportUrl.format(localVarUrlObj),
options: localVarRequestOptions,
};
},
@sahanatroam I don't know why generated code depends on url
package. But I realize that below code resolve the issue.
"typeRoots": [
"node_modules/@types"
+ "node_modules/@types",
+ "../node_modules/@types"
]
Bug Report Checklist
Description
The issue is the build failure of API Clients -
axios-typescript
. The reason why this issue is problem for me is that I cannnot publish api client used in our project.openapi-generator version
I use the latest version of openapi-generator (becasue it happend soon after I execute
yarn add @openapitools/openapi-generator-cli
).OpenAPI declaration file content or url
The issue is not related to api specification.
Command line used for generation
I use npm.
Steps to reproduce
Execute
yarn client:build
and you can see errors below.Related issues/PRs
In order to resolve #2394,
--typeRoots
was introduced.Suggest a fix
I manually changed the generated
tsconfig.json
and then build succeeded.diff is here
https://github.com/OpenAPITools/openapi-generator/blob/28ddad44e57109989b6fd17fffe0fa2403046102/modules/openapi-generator/src/main/resources/typescript-axios/tsconfig.mustache#L15-L17
or how about introducing options that disables the
--typeRoots
or enables the--typeRoots
?