/
index.js
37 lines (35 loc) · 1.15 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import resolve from "swagger-client/es/resolver"
import { execute, buildRequest } from "swagger-client/es/execute"
import Http, { makeHttp, serializeRes } from "swagger-client/es/http"
import resolveSubtree from "swagger-client/es/subtree-resolver"
import { opId } from "swagger-client/es/helpers"
import * as configsWrapActions from "./configs-wrap-actions"
export default function({ configs, getConfigs }) {
return {
fn: {
fetch: makeHttp(Http, configs.preFetch, configs.postFetch),
buildRequest,
execute,
resolve,
resolveSubtree: (obj, path, opts, ...rest) => {
if(opts === undefined) {
const freshConfigs = getConfigs()
opts = {
modelPropertyMacro: freshConfigs.modelPropertyMacro,
parameterMacro: freshConfigs.parameterMacro,
requestInterceptor: freshConfigs.requestInterceptor,
responseInterceptor: freshConfigs.responseInterceptor
}
}
return resolveSubtree(obj, path, opts, ...rest)
},
serializeRes,
opId
},
statePlugins: {
configs: {
wrapActions: configsWrapActions
}
},
}
}