如何将AxiosInstance传递给openapi-generator typescript-axios模板生成的类?
我尝试改变BaseAPI类的原型,但它不工作。而且没有地方可以传递我的axios示例
import { HotelsRestServiceApi, Configuration } from '../../generated/openapi';
import { BaseAPI } from '../../generated/openapi/base'; //Base api class generated by openapi
import { axiosClientNoAuth } from '../index'; //My AxiosInstance
const config = new Configuration({
basePath: 'http://localhost:8080',
});
const baseApi = new BaseAPI(config, 'http://localhost:8080', axiosClientNoAuth);
const axios = new RestServiceApi(config);
axios.prototype.__proto__ = baseApi.prototype;
1条答案
按热度按时间qcbq4gxm1#
通过修改模板解决:
.openapi-generator/templates
import { axiosClient as globalAxios } from '../../api';
(My openapi-generator-config.yaml)