Closed xxbld closed 4 years ago
@xxbld
basepath
按 axios
的使用方法,一般设置在request的实例里面。而且加了之后,也不方式实现一些跟切换域名相关的功能。多数的request库都支持拦截器已经全局配置等。
const instance = axios.create({
baseURL: 'https://some-domain.com/api/',
timeout: 1000,
headers: {'X-Custom-Header': 'foobar'}
});
serviceOptions.axios = instance
Or
```js
axios.defaults.timeout = 15000
axios.defaults.baseURL = apiHost
目前是只支持跟 axios
类似结构的库,所以在 axios
上进行了抽象。umi-request
我简单看了下,在Request方向基本类似,Response的话,差一个 error ,觉得你在interceptor包装一下就可以使用。
abp 这个我觉得可以抽出来
你可以说说看你的想法
是swagger里面还有一层basePath,不是指 baseUrl
{"swagger":"2.0","host":"","basePath":"/userkey/pc"}
对的,是我一下短路了,我用一个函数再包装一次umi-request就ok了
是swagger里面还有一层basePath,不是指 baseUrl
{"swagger":"2.0","host":"","basePath":"/userkey/pc"}
那你的想法是
那你的想法是
我不知道这个常遇到不,我现在的做法是为每个生成的ts文件创建了一个baserUrl+basePath的axios实例
@Manweill
apijson 的 basepath 是否要追加到请求前缀 ? {basepath+path}; https://github.com/Manweill/swagger-axios-codegen/blob/0e02b584cc8628fec8dee4b9e886d8af3233ab5c/src/templates/template.ts#L212
第三方 request 接入支持再提升一下?用了umi-request有点对不上;
abpGenericTypeDefinition 我认为不应该内置在生成器里面; https://github.com/Manweill/swagger-axios-codegen/blob/0e02b584cc8628fec8dee4b9e886d8af3233ab5c/src/templates/genericTypeDefinitionTemplate.ts#L8