Skip to content

Commit

Permalink
feat: integrate [email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
char0n committed Mar 8, 2023
1 parent 187b0e7 commit 0d0e6d9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"build:es:bundle": "webpack --color --config webpack/es-bundle.babel.js",
"build:es:bundle:core": "webpack --color --config webpack/es-bundle-core.babel.js",
"clean": "rimraf ./dist",
"predev": "npm install",
"postinstall": "patch-package",
"dev": "webpack serve --config webpack/dev.babel.js",
"deps-license": "license-checker --production --csv --out $npm_package_config_deps_check_dir/licenses.csv && license-checker --development --csv --out $npm_package_config_deps_check_dir/licenses-dev.csv",
Expand Down
41 changes: 28 additions & 13 deletions src/core/plugins/swagger-js/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import resolve from "swagger-client/es/resolver"
import genericResolveStrategy from "swagger-client/es/resolver/strategies/generic"
import openApi2ResolveStrategy from "swagger-client/es/resolver/strategies/openapi-2"
import openApi30ResolveStrategy from "swagger-client/es/resolver/strategies/openapi-3-0"
import openApi31ApiDOMResolveStrategy from "swagger-client/es/resolver/strategies/openapi-3-1-apidom"
import { makeResolve } 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 { makeResolveSubtree } from "swagger-client/es/subtree-resolver"
import { opId } from "swagger-client/es/helpers"
import { loaded } from "./configs-wrap-actions"

Expand All @@ -11,19 +15,30 @@ export default function({ configs, getConfigs }) {
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
}
resolve: makeResolve({
strategies: [
openApi31ApiDOMResolveStrategy,
openApi30ResolveStrategy,
openApi2ResolveStrategy,
genericResolveStrategy,
],
}),
resolveSubtree: async (obj, path, options = {}) => {
const freshConfigs = getConfigs()
const defaultOptions = {
modelPropertyMacro: freshConfigs.modelPropertyMacro,
parameterMacro: freshConfigs.parameterMacro,
requestInterceptor: freshConfigs.requestInterceptor,
responseInterceptor: freshConfigs.responseInterceptor,
strategies: [
openApi31ApiDOMResolveStrategy,
openApi30ResolveStrategy,
openApi2ResolveStrategy,
genericResolveStrategy,
],
}

return resolveSubtree(obj, path, opts, ...rest)
return makeResolveSubtree(defaultOptions)(obj, path, options)
},
serializeRes,
opId
Expand Down

0 comments on commit 0d0e6d9

Please sign in to comment.