From 95c3da19cc152cd6bb3c03f7e4237840bca2d0fb Mon Sep 17 00:00:00 2001 From: Vladimir Gorej Date: Sat, 4 Jul 2020 13:50:36 +0200 Subject: [PATCH] refactor(swagger-client): fix import of helpers (#6190) Import of helpers from swagger-client worked because of the fact that commonjs exports are basically an objects that can be destructured. Whenever swagger-client switches to ES6 imports as primary mechanism of webpack consuptions imports like that will fail. This change makes sure that import mechanism is both compatible with ES6 and commonjs import systems. Along with that rename default import of swagger-client to more appropriate SwaggerClient. --- src/core/containers/OperationContainer.jsx | 4 ++-- src/core/plugins/swagger-js/index.js | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core/containers/OperationContainer.jsx b/src/core/containers/OperationContainer.jsx index 4cf009c0..a19cd62a 100644 --- a/src/core/containers/OperationContainer.jsx +++ b/src/core/containers/OperationContainer.jsx @@ -1,10 +1,10 @@ import React, { PureComponent } from "react" import PropTypes from "prop-types" import ImPropTypes from "react-immutable-proptypes" -import { helpers } from "swagger-client" +import SwaggerClient from "swagger-client" import { Iterable, fromJS, Map } from "immutable" -const { opId } = helpers +const { opId } = SwaggerClient.helpers export default class OperationContainer extends PureComponent { constructor(props, context) { diff --git a/src/core/plugins/swagger-js/index.js b/src/core/plugins/swagger-js/index.js index 028700be..32432621 100644 --- a/src/core/plugins/swagger-js/index.js +++ b/src/core/plugins/swagger-js/index.js @@ -1,13 +1,13 @@ -import Swagger from "swagger-client" +import SwaggerClient from "swagger-client" import * as configsWrapActions from "./configs-wrap-actions" export default function({ configs, getConfigs }) { return { fn: { - fetch: Swagger.makeHttp(configs.preFetch, configs.postFetch), - buildRequest: Swagger.buildRequest, - execute: Swagger.execute, - resolve: Swagger.resolve, + fetch: SwaggerClient.makeHttp(configs.preFetch, configs.postFetch), + buildRequest: SwaggerClient.buildRequest, + execute: SwaggerClient.execute, + resolve: SwaggerClient.resolve, resolveSubtree: (obj, path, opts, ...rest) => { if(opts === undefined) { const freshConfigs = getConfigs() @@ -19,10 +19,10 @@ export default function({ configs, getConfigs }) { } } - return Swagger.resolveSubtree(obj, path, opts, ...rest) + return SwaggerClient.resolveSubtree(obj, path, opts, ...rest) }, - serializeRes: Swagger.serializeRes, - opId: Swagger.helpers.opId + serializeRes: SwaggerClient.serializeRes, + opId: SwaggerClient.helpers.opId }, statePlugins: { configs: {