From 0d0e6d9b23983ee7126c09b10c935922e846949b Mon Sep 17 00:00:00 2001 From: Vladimir Gorej Date: Wed, 8 Mar 2023 11:08:49 +0100 Subject: [PATCH] feat: integrate swagger-client@3.19.1 --- package.json | 1 - src/core/plugins/swagger-js/index.js | 41 +++++++++++++++++++--------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index b271236d7ae..e5935087b7e 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/core/plugins/swagger-js/index.js b/src/core/plugins/swagger-js/index.js index cf08cf01df5..55fd70e248b 100644 --- a/src/core/plugins/swagger-js/index.js +++ b/src/core/plugins/swagger-js/index.js @@ -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" @@ -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