Closed asineath-dbhglobal closed 3 years ago
you can set basePath with axios config?
You're referring to the baseURL property in the axios config, which really refers to the host. 'basePath' is a part of the root structure of swagger spec, which indicates if all endpoint paths start with something like '/api'. (https://swagger.io/docs/specification/2-0/api-host-and-base-path/)
Our API doesn't have a universal basePath, so when I run swagger-axios-codegen with multipleFileMode=false, it sets " const basePath = ''; " in the produced index.ts, and all the methods below have access to that const when building the url, such as " let url = basePath + '/api/AddressCity/GetList'; " So everything works fine in that mode.
But when I run swagger-axios-codegen with multipleFileMode=true, which I would prefer to do in my project, the "basePath" variable is undefined in all service files because it is never declared/imported in the individual service files (see screenshot). The basePath const is declared in index.defs.ts, but it needs to be exported from that file and imported into all the generated service files.
When services are generated with multipleFileMode=true, the 'basePath' variable in each individual service file is undefined. In index.defs.ts, the 'basePath' const is not exported. A solution would be to export 'basePath' in index.defs.ts and include it in the import statement at the top of each individual service file.