swagger-client 3.9.0 → 3.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/browser/index.js +19 -5
- package/dist/index.js +4153 -1
- package/package.json +35 -26
package/dist/index.js
CHANGED
|
@@ -1,2 +1,4154 @@
|
|
|
1
|
-
module.exports=function(e){function t(n){if(r[n])return r[n].exports;var a=r[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=25)}([function(e,t){e.exports=require("babel-runtime/core-js/object/keys")},function(e,t){e.exports=require("babel-runtime/helpers/typeof")},function(e,t){e.exports=require("babel-runtime/core-js/object/assign")},function(e,t){e.exports=require("babel-runtime/helpers/extends")},function(e,t){e.exports=require("babel-runtime/regenerator")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e){var t=e.openapi;return!!t&&(0,x.default)(t,"3")}function u(e){var t=e.swagger;return!!t&&(0,x.default)(t,"2")}function o(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=n.v2OperationIdCompatibilityMode;return e&&"object"===(void 0===e?"undefined":(0,y.default)(e))?(e.operationId||"").replace(/\s/g,"").length?k(e.operationId):i(t,r,{v2OperationIdCompatibilityMode:a}):null}function i(e,t){if((arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).v2OperationIdCompatibilityMode){var r=(t.toLowerCase()+"_"+e).replace(/[\s!@#$%^&*()_+=[{\]};:<>|.\/?,\\'""-]/g,"_");return r=r||e.substring(1)+"_"+t,r.replace(/((_){2,})/g,"_").replace(/^(_)*/g,"").replace(/([_])*$/g,"")}return""+P(t)+k(e)}function s(e,t){return P(t)+"-"+e}function l(e,t){return e&&e.paths?c(e,function(e){var r=e.pathName,n=e.method,a=e.operation;if(!a||"object"!==(void 0===a?"undefined":(0,y.default)(a)))return!1;var u=a.operationId;return[o(a,r,n),s(r,n),u].some(function(e){return e&&e===t})}):null}function c(e,t){return f(e,t,!0)||null}function f(e,t,r){if(!e||"object"!==(void 0===e?"undefined":(0,y.default)(e))||!e.paths||"object"!==(0,y.default)(e.paths))return null;var n=e.paths;for(var a in n)for(var u in n[a])if("PARAMETERS"!==u.toUpperCase()){var o=n[a][u];if(o&&"object"===(void 0===o?"undefined":(0,y.default)(o))){var i={spec:e,pathName:a,method:u.toUpperCase(),operation:o},s=t(i);if(r&&s)return i}}}function p(e){var t=e.spec,r=t.paths,n={};if(!r||t.$$normalized)return e;for(var a in r){var u=r[a];if((0,g.default)(u)){var i=u.parameters;for(var s in u){(function(e){var r=u[e];if(!(0,g.default)(r))return"continue";var s=o(r,a,e);if(s){n[s]?n[s].push(r):n[s]=[r];var l=n[s];if(l.length>1)l.forEach(function(e,t){e.__originalOperationId=e.__originalOperationId||e.operationId,e.operationId=""+s+(t+1)});else if(void 0!==r.operationId){var c=l[0];c.__originalOperationId=c.__originalOperationId||r.operationId,c.operationId=s}}if("parameters"!==e){var f=[],p={};for(var d in t)"produces"!==d&&"consumes"!==d&&"security"!==d||(p[d]=t[d],f.push(p));if(i&&(p.parameters=i,f.push(p)),f.length){var v=!0,y=!1,m=void 0;try{for(var b,x=(0,h.default)(f);!(v=(b=x.next()).done);v=!0){var P=b.value;for(var k in P)if(r[k]){if("parameters"===k){var w=!0,_=!1,O=void 0;try{for(var q,M=(0,h.default)(P[k]);!(w=(q=M.next()).done);w=!0)!function(){var e=q.value;r[k].some(function(t){return t.name&&t.name===e.name||t.$ref&&t.$ref===e.$ref||t.$$ref&&t.$$ref===e.$$ref||t===e})||r[k].push(e)}()}catch(e){_=!0,O=e}finally{try{!w&&M.return&&M.return()}finally{if(_)throw O}}}}else r[k]=P[k]}}catch(e){y=!0,m=e}finally{try{!v&&x.return&&x.return()}finally{if(y)throw m}}}}})(s)}}}return t.$$normalized=!0,e}Object.defineProperty(t,"__esModule",{value:!0});var d=r(20),h=n(d),v=r(1),y=n(v);t.isOAS3=a,t.isSwagger2=u,t.opId=o,t.idFromPathMethod=i,t.legacyIdFromPathMethod=s,t.getOperationRaw=l,t.findOperation=c,t.eachOperation=f,t.normalizeSwagger=p;var m=r(48),g=n(m),b=r(15),x=n(b),P=function(e){return String.prototype.toLowerCase.call(e)},k=function(e){return e.replace(/[^\w]/gi,"_")}},function(e,t){e.exports=require("lodash/assign")},function(e,t){e.exports=require("url")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e,t){return t&&(0===t.indexOf("application/json")||t.indexOf("+json")>0)?JSON.parse(e):M.default.safeLoad(e)}function u(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.loadSpec,u=void 0!==n&&n,i={ok:e.ok,url:e.url||t,status:e.status,statusText:e.statusText,headers:o(e.headers)},s=i.headers["content-type"],l=u||I(s);return(l?e.text:e.blob||e.buffer).call(e).then(function(e){if(i.text=e,i.data=e,l)try{var t=a(e,s);i.body=t,i.obj=t}catch(e){i.parseError=e}return i})}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={};return"function"==typeof e.forEach?(e.forEach(function(e,r){void 0!==t[r]?(t[r]=Array.isArray(t[r])?t[r]:[t[r]],t[r].push(e)):t[r]=e}),t):t}function i(e,t){return t||"undefined"==typeof navigator||(t=navigator),t&&"ReactNative"===t.product?!(!e||"object"!==(void 0===e?"undefined":(0,P.default)(e))||"string"!=typeof e.uri):"undefined"!=typeof File?e instanceof File:null!==e&&"object"===(void 0===e?"undefined":(0,P.default)(e))&&"function"==typeof e.pipe}function s(e,t){var r=e.collectionFormat,n=e.allowEmptyValue,a="object"===(void 0===e?"undefined":(0,P.default)(e))?e.value:e,u={csv:",",ssv:"%20",tsv:"%09",pipes:"|"};if(void 0===a&&n)return"";if(i(a)||"boolean"==typeof a)return a;var o=encodeURIComponent;return t&&(o=(0,A.default)(a)?function(e){return e}:function(e){return(0,m.default)(e)}),"object"!==(void 0===a?"undefined":(0,P.default)(a))||Array.isArray(a)?Array.isArray(a)?Array.isArray(a)&&!r?a.map(o).join(","):"multi"===r?a.map(o):a.map(o).join(u[r]):o(a):""}function l(e){var t=(0,v.default)(e).reduce(function(t,r){var n=e[r],a=!!n.skipEncoding,u=a?r:encodeURIComponent(r),o=function(e){return e&&"object"===(void 0===e?"undefined":(0,P.default)(e))}(n)&&!Array.isArray(n);return t[u]=s(o?n:{value:n},a),t},{});return O.default.stringify(t,{encode:!1,indices:!1})||""}function c(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.url,n=void 0===t?"":t,a=e.query,u=e.form;if(u){var o=(0,v.default)(u).some(function(e){return i(u[e].value)}),c=e.headers["content-type"]||e.headers["Content-Type"];if(o||/multipart\/form-data/i.test(c)){var f=r(31);e.body=new f,(0,v.default)(u).forEach(function(t){e.body.append(t,s(u[t],!0))})}else e.body=l(u);delete e.form}if(a){var p=n.split("?"),h=(0,d.default)(p,2),y=h[0],m=h[1],g="";if(m){var b=O.default.parse(m);(0,v.default)(a).forEach(function(e){return delete b[e]}),g=O.default.stringify(b,{encode:!0})}var x=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=t.filter(function(e){return e}).join("&");return n?"?"+n:""}(g,l(a));e.url=y+x,delete e.query}return e}function f(e,t,r){return r=r||function(e){return e},t=t||function(e){return e},function(n){return"string"==typeof n&&(n={url:n}),C.mergeInQueryOrForm(n),n=t(n),r(e(n))}}Object.defineProperty(t,"__esModule",{value:!0}),t.shouldDownloadAsText=t.self=void 0;var p=r(16),d=n(p),h=r(0),v=n(h),y=r(9),m=n(y),g=r(4),b=n(g),x=r(1),P=n(x),k=r(11),w=n(k);t.serializeRes=u,t.serializeHeaders=o,t.isFile=i,t.encodeFormOrQuery=l,t.mergeInQueryOrForm=c,t.makeHttp=f,r(28);var _=r(29),O=n(_),q=r(17),M=n(q),j=r(30),A=n(j),C=t.self={serializeRes:u,mergeInQueryOrForm:c};t.default=function(){function e(e){return t.apply(this,arguments)}var t=(0,w.default)(b.default.mark(function e(t){var r,n,a,u,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("object"===(void 0===t?"undefined":(0,P.default)(t))&&(o=t,t=o.url),o.headers=o.headers||{},C.mergeInQueryOrForm(o),!o.requestInterceptor){e.next=10;break}return e.next=6,o.requestInterceptor(o);case 6:if(e.t0=e.sent,e.t0){e.next=9;break}e.t0=o;case 9:o=e.t0;case 10:return r=o.headers["content-type"]||o.headers["Content-Type"],/multipart\/form-data/i.test(r)&&(delete o.headers["content-type"],delete o.headers["Content-Type"]),n=void 0,e.prev=13,e.next=16,(o.userFetch||fetch)(o.url,o);case 16:return n=e.sent,e.next=19,C.serializeRes(n,t,o);case 19:if(n=e.sent,!o.responseInterceptor){e.next=27;break}return e.next=23,o.responseInterceptor(n);case 23:if(e.t1=e.sent,e.t1){e.next=26;break}e.t1=n;case 26:n=e.t1;case 27:e.next=37;break;case 29:if(e.prev=29,e.t2=e.catch(13),n){e.next=33;break}throw e.t2;case 33:throw a=new Error(n.statusText),a.statusCode=a.status=n.status,a.responseError=e.t2,a;case 37:if(n.ok){e.next=42;break}throw u=new Error(n.statusText),u.statusCode=u.status=n.status,u.response=n,u;case 42:return e.abrupt("return",n);case 43:case"end":return e.stop()}},e,this,[[13,29]])}));return e}();var I=t.shouldDownloadAsText=function(){return/(json|xml|yaml|text)\b/.test(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")}},function(e,t){e.exports=require("babel-runtime/core-js/json/stringify")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e,t,r){if(r=r||{},t=(0,U.default)({},t,{path:t.path&&u(t.path)}),"merge"===t.op){var n=T(e,t.path);(0,U.default)(n,t.value),V.default.applyPatch(e,[i(t.path,n)])}else if("mergeDeep"===t.op){var a=T(e,t.path);for(var o in t.value){var s=t.value[o],l=Array.isArray(s);if(l){var c=a[o]||[];a[o]=c.concat(s)}else if(w(s)&&!l){var f=(0,U.default)({},a[o]);for(var p in s){if(Object.prototype.hasOwnProperty.call(f,p)){f=(0,W.default)((0,Y.default)({},f),s);break}(0,U.default)(f,(0,B.default)({},p,s[p]))}a[o]=f}else a[o]=s}}else if("add"===t.op&&""===t.path&&w(t.value)){var d=(0,$.default)(t.value).reduce(function(e,r){return e.push({op:"add",path:"/"+u(r),value:t.value[r]}),e},[]);V.default.applyPatch(e,d)}else if("replace"===t.op&&""===t.path){var h=t.value;r.allowMetaPatches&&t.meta&&C(t)&&(Array.isArray(t.value)||w(t.value))&&(h=(0,U.default)({},h,t.meta)),e=h}else if(V.default.applyPatch(e,[t]),r.allowMetaPatches&&t.meta&&C(t)&&(Array.isArray(t.value)||w(t.value))){var v=T(e,t.path),y=(0,U.default)({},v,t.meta);V.default.applyPatch(e,[i(t.path,y)])}return e}function u(e){return Array.isArray(e)?e.length<1?"":"/"+e.map(function(e){return(e+"").replace(/~/g,"~0").replace(/\//g,"~1")}).join("/"):e}function o(e,t){return{op:"add",path:e,value:t}}function i(e,t,r){return{op:"replace",path:e,value:t,meta:r}}function s(e,t){return{op:"remove",path:e}}function l(e,t){return{type:"mutation",op:"merge",path:e,value:t}}function c(e,t){return{type:"mutation",op:"mergeDeep",path:e,value:t}}function f(e,t){return{type:"context",path:e,value:t}}function p(e,t){try{return h(e,y,t)}catch(e){return e}}function d(e,t){try{return h(e,v,t)}catch(e){return e}}function h(e,t,r){return k(P(e.filter(C).map(function(e){return t(e.value,r,e.path)})||[]))}function v(e,t,r){return r=r||[],Array.isArray(e)?e.map(function(e,n){return v(e,t,r.concat(n))}):w(e)?(0,$.default)(e).map(function(n){return v(e[n],t,r.concat(n))}):t(e,r[r.length-1],r)}function y(e,t,r){r=r||[];var n=[];if(r.length>0){var a=t(e,r[r.length-1],r);a&&(n=n.concat(a))}if(Array.isArray(e)){var u=e.map(function(e,n){return y(e,t,r.concat(n))});u&&(n=n.concat(u))}else if(w(e)){var o=(0,$.default)(e).map(function(n){return y(e[n],t,r.concat(n))});o&&(n=n.concat(o))}return n=P(n)}function m(e,t){if(!Array.isArray(t))return!1;for(var r=0,n=t.length;r<n;r++)if(t[r]!==e[r])return!1;return!0}function g(e,t){return t.reduce(function(e,t){return void 0!==t&&e?e[t]:e},e)}function b(e){return k(P(x(e)))}function x(e){return Array.isArray(e)?e:[e]}function P(e){var t;return(t=[]).concat.apply(t,(0,D.default)(e.map(function(e){return Array.isArray(e)?P(e):e})))}function k(e){return e.filter(function(e){return void 0!==e})}function w(e){return e&&"object"===(void 0===e?"undefined":(0,F.default)(e))}function _(e){return w(e)&&O(e.then)}function O(e){return e&&"function"==typeof e}function q(e){return e instanceof Error}function M(e){if(E(e)){var t=e.op;return"add"===t||"remove"===t||"replace"===t}return!1}function j(e){return G.default.isGeneratorFunction(e)}function A(e){return M(e)||E(e)&&"mutation"===e.type}function C(e){return A(e)&&("add"===e.op||"replace"===e.op||"merge"===e.op||"mergeDeep"===e.op)}function I(e){return E(e)&&"context"===e.type}function E(e){return e&&"object"===(void 0===e?"undefined":(0,F.default)(e))}function T(e,t){try{return V.default.getValueByPointer(e,t)}catch(e){return console.error(e),{}}}Object.defineProperty(t,"__esModule",{value:!0});var S=r(1),F=n(S),N=r(12),D=n(N),R=r(0),$=n(R),z=r(35),B=n(z),H=r(2),U=n(H),L=r(36),V=n(L),J=r(4),G=n(J),Q=r(37),W=n(Q),K=r(38),Y=n(K);t.default={add:o,replace:i,remove:s,merge:l,mergeDeep:c,context:f,getIn:g,applyPatch:a,parentPathMatch:m,flatten:P,fullyNormalizeArray:b,normalizeArray:x,isPromise:_,forEachNew:p,forEachNewPrimitive:d,isJsonPatch:M,isContextPatch:I,isPatch:E,isMutation:A,isAdditiveMutation:C,isGenerator:j,isFunction:O,isObject:w,isError:q},e.exports=t.default},function(e,t){e.exports=require("babel-runtime/helpers/asyncToGenerator")},function(e,t){e.exports=require("babel-runtime/helpers/toConsumableArray")},function(e,t){e.exports=require("lodash/get")},function(e,t){e.exports=require("btoa")},function(e,t){e.exports=require("lodash/startsWith")},function(e,t){e.exports=require("babel-runtime/helpers/slicedToArray")},function(e,t){e.exports=require("@kyleshockey/js-yaml")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.requestInterceptor,n=t.responseInterceptor,a=e.withCredentials?"include":"same-origin";return function(t){return e({url:t,loadSpec:!0,requestInterceptor:r,responseInterceptor:n,headers:{Accept:"application/json"},credentials:a}).then(function(e){return e.body})}}function u(){d.plugins.refs.clearCache()}function o(e){function t(e){var t=this;w&&(d.plugins.refs.docCache[w]=e),d.plugins.refs.fetchJSON=a(k,{requestInterceptor:g,responseInterceptor:b});var r=[d.plugins.refs];return"function"==typeof m&&r.push(d.plugins.parameters),"function"==typeof y&&r.push(d.plugins.properties),"strict"!==o&&r.push(d.plugins.allOf),(0,h.default)({spec:e,context:{baseDoc:w},plugins:r,allowMetaPatches:l,pathDiscriminator:f,parameterMacro:m,modelPropertyMacro:y,useCircularStructures:P}).then(x?function(){var e=(0,c.default)(s.default.mark(function e(r){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",r);case 1:case"end":return e.stop()}},e,t)}));return function(t){return e.apply(this,arguments)}}():v.normalizeSwagger)}var r=e.fetch,n=e.spec,u=e.url,o=e.mode,i=e.allowMetaPatches,l=void 0===i||i,f=e.pathDiscriminator,y=e.modelPropertyMacro,m=e.parameterMacro,g=e.requestInterceptor,b=e.responseInterceptor,x=e.skipNormalization,P=e.useCircularStructures,k=e.http,w=e.baseDoc;return w=w||u,k=r||k||p.default,n?t(n):a(k,{requestInterceptor:g,responseInterceptor:b})(w).then(t)}Object.defineProperty(t,"__esModule",{value:!0});var i=r(4),s=n(i),l=r(11),c=n(l);t.makeFetchJSON=a,t.clearCache=u,t.default=o;var f=r(8),p=n(f),d=r(32),h=n(d),v=r(5)},function(e,t){e.exports=require("babel-runtime/core-js/promise")},function(e,t){e.exports=require("babel-runtime/core-js/get-iterator")},function(e,t){e.exports=require("babel-runtime/helpers/classCallCheck")},function(e,t){e.exports=require("babel-runtime/helpers/createClass")},function(e,t,r){"use strict";function n(e,t){function r(){Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack;for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];this.message=r[0],t&&t.apply(this,r)}return r.prototype=new Error,r.prototype.name=e,r.prototype.constructor=r,r}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e){var t=e[e.length-1],r=e[e.length-2],n=e.join("/");return v.indexOf(t)>-1&&-1===y.indexOf(r)||m.indexOf(n)>-1||g.some(function(e){return n.indexOf(e)>-1})}function u(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.specmap,a=r.getBaseUrlForNodePath,u=void 0===a?function(e){return n.getContext([].concat((0,c.default)(t),(0,c.default)(e))).baseDoc}:a,i=r.targetKeys,s=void 0===i?["$ref","$$ref"]:i,l=[];return(0,p.default)(e).forEach(function(){if(s.indexOf(this.key)>-1){var e=this.path,r=t.concat(this.path),a=o(this.node,u(e));l.push(n.replace(r,a))}}),l}function o(e,t){var r=e.split("#"),n=(0,s.default)(r,2),a=n[0],u=n[1],o=h.default.resolve(a||"",t||"");return u?o+"#"+u:o}Object.defineProperty(t,"__esModule",{value:!0});var i=r(16),s=n(i),l=r(12),c=n(l);t.isFreelyNamed=a,t.generateAbsoluteRefPatches=u,t.absolutifyPointer=o;var f=r(43),p=n(f),d=r(7),h=n(d),v=["properties"],y=["properties"],m=["definitions","parameters","responses","securityDefinitions","components/schemas","components/responses","components/parameters","components/securitySchemes"],g=["schema/example","items/example"]},function(e,t,r){e.exports=r(26)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof e?r.url=e:r=e,!(this instanceof a))return new a(r);(0,l.default)(this,r);var n=this.resolve().then(function(){return t.disableInterfaces||(0,l.default)(t,a.makeApisTagOperation(t)),t});return n.client=this,n}Object.defineProperty(t,"__esModule",{value:!0});var u=r(3),o=n(u),i=r(27),s=(n(i),r(6)),l=n(s),c=r(15),f=n(c),p=r(7),d=n(p),h=r(8),v=n(h),y=r(18),m=n(y),g=r(49),b=n(g),x=r(50),P=r(52),k=r(5);a.http=v.default,a.makeHttp=h.makeHttp.bind(null,a.http),a.resolve=m.default,a.resolveSubtree=b.default,a.execute=P.execute,a.serializeRes=h.serializeRes,a.serializeHeaders=h.serializeHeaders,a.clearCache=y.clearCache,a.parameterBuilders=P.PARAMETER_BUILDERS,a.makeApisTagOperation=x.makeApisTagOperation,a.buildRequest=P.buildRequest,a.helpers={opId:k.opId},a.prototype={http:v.default,execute:function(e){return this.applyDefaults(),a.execute((0,o.default)({spec:this.spec,http:this.http,securities:{authorized:this.authorizations},contextUrl:"string"==typeof this.url?this.url:void 0},e))},resolve:function(){var e=this;return a.resolve({spec:this.spec,url:this.url,allowMetaPatches:this.allowMetaPatches,useCircularStructures:this.useCircularStructures,requestInterceptor:this.requestInterceptor||null,responseInterceptor:this.responseInterceptor||null}).then(function(t){return e.originalSpec=e.spec,e.spec=t.spec,e.errors=t.errors,e})}},a.prototype.applyDefaults=function(){var e=this.spec,t=this.url;if(t&&(0,f.default)(t,"http")){var r=d.default.parse(t);e.host||(e.host=r.host),e.schemes||(e.schemes=[r.protocol.replace(":","")]),e.basePath||(e.basePath="/")}},t.default=a,e.exports=t.default},function(e,t){e.exports=require("lodash/cloneDeep")},function(e,t){e.exports=require("cross-fetch/polyfill")},function(e,t){e.exports=require("qs")},function(e,t){e.exports=require("lodash/isString")},function(e,t){e.exports=require("isomorphic-form-data")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e){return new $(e).dispatch()}Object.defineProperty(t,"__esModule",{value:!0}),t.plugins=t.SpecMap=void 0;var u=r(9),o=n(u),i=r(1),s=n(i),l=r(19),c=n(l),f=r(4),p=n(f),d=r(0),h=n(d),v=r(20),y=n(v),m=r(33),g=n(m),b=r(2),x=n(b),P=r(21),k=n(P),w=r(22),_=n(w);t.default=a;var O=r(34),q=n(O),M=r(10),j=n(M),A=r(39),C=n(A),I=r(44),E=n(I),T=r(45),S=n(T),F=r(46),N=n(F),D=r(47),R=n(D),$=function(){function e(t){var r=this;(0,k.default)(this,e),(0,x.default)(this,{spec:"",debugLevel:"info",plugins:[],pluginHistory:{},errors:[],mutations:[],promisedPatches:[],state:{},patches:[],context:{},contextTree:new R.default,showDebug:!1,allPatches:[],pluginProp:"specMap",libMethods:(0,x.default)((0,g.default)(this),j.default,{getInstance:function(){return r}}),allowMetaPatches:!1},t),this.get=this._get.bind(this),this.getContext=this._getContext.bind(this),this.hasRun=this._hasRun.bind(this),this.wrappedPlugins=this.plugins.map(this.wrapPlugin.bind(this)).filter(j.default.isFunction),this.patches.push(j.default.add([],this.spec)),this.patches.push(j.default.context([],this.context)),this.updatePatches(this.patches)}return(0,_.default)(e,[{key:"debug",value:function(e){if(this.debugLevel===e){for(var t,r=arguments.length,n=Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];(t=console).log.apply(t,n)}}},{key:"verbose",value:function(e){if("verbose"===this.debugLevel){for(var t,r=arguments.length,n=Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];(t=console).log.apply(t,["["+e+"] "].concat(n))}}},{key:"wrapPlugin",value:function(e,t){var r=this.pathDiscriminator,n=null,a=void 0;return e[this.pluginProp]?(n=e,a=e[this.pluginProp]):j.default.isFunction(e)?a=e:j.default.isObject(e)&&(a=function(e){var t=function(e,t){return!Array.isArray(e)||e.every(function(e,r){return e===t[r]})};return p.default.mark(function n(a,u){var o,i,s,l,c,f,d,v,m;return p.default.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:m=function n(a,s,l){var c,f,d,v,m,g,b,x,P,k,w,_,O,q,M,A;return p.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(j.default.isObject(a)){o.next=6;break}if(e.key!==s[s.length-1]){o.next=4;break}return o.next=4,e.plugin(a,e.key,s,u);case 4:o.next=48;break;case 6:c=s.length-1,f=s[c],d=s.indexOf("properties"),v="properties"===f&&c===d,m=u.allowMetaPatches&&i[a.$$ref],g=!0,b=!1,x=void 0,o.prev=14,P=(0,y.default)((0,h.default)(a));case 16:if(g=(k=P.next()).done){o.next=34;break}if(w=k.value,_=a[w],O=s.concat(w),q=j.default.isObject(_),M=a.$$ref,m){o.next=26;break}if(!q){o.next=26;break}return u.allowMetaPatches&&M&&(i[M]=!0),o.delegateYield(n(_,O,l),"t0",26);case 26:if(v||w!==e.key){o.next=31;break}if(A=t(r,s),r&&!A){o.next=31;break}return o.next=31,e.plugin(_,w,O,u,l);case 31:g=!0,o.next=16;break;case 34:o.next=40;break;case 36:o.prev=36,o.t1=o.catch(14),b=!0,x=o.t1;case 40:o.prev=40,o.prev=41,!g&&P.return&&P.return();case 43:if(o.prev=43,!b){o.next=46;break}throw x;case 46:return o.finish(43);case 47:return o.finish(40);case 48:case"end":return o.stop()}},o,this,[[14,36,40,48],[41,,43,47]])},o=p.default.mark(m),i={},s=!0,l=!1,c=void 0,n.prev=6,f=(0,y.default)(a.filter(j.default.isAdditiveMutation));case 8:if(s=(d=f.next()).done){n.next=14;break}return v=d.value,n.delegateYield(m(v.value,v.path,v),"t0",11);case 11:s=!0,n.next=8;break;case 14:n.next=20;break;case 16:n.prev=16,n.t1=n.catch(6),l=!0,c=n.t1;case 20:n.prev=20,n.prev=21,!s&&f.return&&f.return();case 23:if(n.prev=23,!l){n.next=26;break}throw c;case 26:return n.finish(23);case 27:return n.finish(20);case 28:case"end":return n.stop()}},n,this,[[6,16,20,28],[21,,23,27]])})}(e)),(0,x.default)(a.bind(n),{pluginName:e.name||t,isGenerator:j.default.isGenerator(a)})}},{key:"nextPlugin",value:function(){var e=this;return(0,q.default)(this.wrappedPlugins,function(t){return e.getMutationsForPlugin(t).length>0})}},{key:"nextPromisedPatch",value:function(){if(this.promisedPatches.length>0)return c.default.race(this.promisedPatches.map(function(e){return e.value}))}},{key:"getPluginHistory",value:function(e){var t=this.getPluginName(e);return this.pluginHistory[t]||[]}},{key:"getPluginRunCount",value:function(e){return this.getPluginHistory(e).length}},{key:"getPluginHistoryTip",value:function(e){var t=this.getPluginHistory(e);return t&&t[t.length-1]||{}}},{key:"getPluginMutationIndex",value:function(e){var t=this.getPluginHistoryTip(e).mutationIndex;return"number"!=typeof t?-1:t}},{key:"getPluginName",value:function(e){return e.pluginName}},{key:"updatePluginHistory",value:function(e,t){var r=this.getPluginName(e);(this.pluginHistory[r]=this.pluginHistory[r]||[]).push(t)}},{key:"updatePatches",value:function(e,t){var r=this;j.default.normalizeArray(e).forEach(function(e){if(e instanceof Error)return void r.errors.push(e);try{if(!j.default.isObject(e))return void r.debug("updatePatches","Got a non-object patch",e);if(r.showDebug&&r.allPatches.push(e),j.default.isPromise(e.value))return r.promisedPatches.push(e),void r.promisedPatchThen(e);if(j.default.isContextPatch(e))return void r.setContext(e.path,e.value);if(j.default.isMutation(e))return void r.updateMutations(e)}catch(e){console.error(e),r.errors.push(e)}})}},{key:"updateMutations",value:function(e){"object"===(0,s.default)(e.value)&&!Array.isArray(e.value)&&this.allowMetaPatches&&(e.value=(0,x.default)({},e.value));var t=j.default.applyPatch(this.state,e,{allowMetaPatches:this.allowMetaPatches});t&&(this.mutations.push(e),this.state=t)}},{key:"removePromisedPatch",value:function(e){var t=this.promisedPatches.indexOf(e);if(t<0)return void this.debug("Tried to remove a promisedPatch that isn't there!");this.promisedPatches.splice(t,1)}},{key:"promisedPatchThen",value:function(e){var t=this;return e.value=e.value.then(function(r){var n=(0,x.default)({},e,{value:r});t.removePromisedPatch(e),t.updatePatches(n)}).catch(function(r){t.removePromisedPatch(e),t.updatePatches(r)})}},{key:"getMutations",value:function(e,t){return e=e||0,"number"!=typeof t&&(t=this.mutations.length),this.mutations.slice(e,t)}},{key:"getCurrentMutations",value:function(){return this.getMutationsForPlugin(this.getCurrentPlugin())}},{key:"getMutationsForPlugin",value:function(e){var t=this.getPluginMutationIndex(e);return this.getMutations(t+1)}},{key:"getCurrentPlugin",value:function(){return this.currentPlugin}},{key:"getPatchesOfType",value:function(e,t){return e.filter(t)}},{key:"getLib",value:function(){return this.libMethods}},{key:"_get",value:function(e){return j.default.getIn(this.state,e)}},{key:"_getContext",value:function(e){return this.contextTree.get(e)}},{key:"setContext",value:function(e,t){return this.contextTree.set(e,t)}},{key:"_hasRun",value:function(e){return this.getPluginRunCount(this.getCurrentPlugin())>(e||0)}},{key:"_clone",value:function(e){return JSON.parse((0,o.default)(e))}},{key:"dispatch",value:function(){function e(e){e&&(e=j.default.fullyNormalizeArray(e),r.updatePatches(e,n))}var t=this,r=this,n=this.nextPlugin();if(!n){var a=this.nextPromisedPatch();if(a)return a.then(function(){return t.dispatch()}).catch(function(){return t.dispatch()});var u={spec:this.state,errors:this.errors};return this.showDebug&&(u.patches=this.allPatches),c.default.resolve(u)}if(r.pluginCount=r.pluginCount||{},r.pluginCount[n]=(r.pluginCount[n]||0)+1,r.pluginCount[n]>100)return c.default.resolve({spec:r.state,errors:r.errors.concat(new Error("We've reached a hard limit of 100 plugin runs"))});if(n!==this.currentPlugin&&this.promisedPatches.length){var o=this.promisedPatches.map(function(e){return e.value});return c.default.all(o.map(function(e){return e.then(Function,Function)})).then(function(){return t.dispatch()})}return function(){r.currentPlugin=n;var t=r.getCurrentMutations(),a=r.mutations.length-1;try{if(n.isGenerator){var u=!0,o=!1,i=void 0;try{for(var s,l=(0,y.default)(n(t,r.getLib()));!(u=(s=l.next()).done);u=!0){e(s.value)}}catch(e){o=!0,i=e}finally{try{!u&&l.return&&l.return()}finally{if(o)throw i}}}else{e(n(t,r.getLib()))}}catch(t){console.error(t),e([(0,x.default)((0,g.default)(t),{plugin:n})])}finally{r.updatePluginHistory(n,{mutationIndex:a})}return r.dispatch()}()}}]),e}(),z={refs:C.default,allOf:E.default,parameters:S.default,properties:N.default};t.SpecMap=$,t.plugins=z},function(e,t){e.exports=require("babel-runtime/core-js/object/create")},function(e,t){e.exports=require("lodash/find")},function(e,t){e.exports=require("babel-runtime/helpers/defineProperty")},function(e,t){e.exports=require("fast-json-patch")},function(e,t){e.exports=require("deep-extend")},function(e,t){e.exports=require("@kyleshockey/object-assign-deep")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!B.test(e)){if(!t)throw new H("Tried to resolve a relative URL, without having a basePath. path: '"+e+"' basePath: '"+t+"'");return F.default.resolve(t,e)}return e}function u(e,t){var r=void 0;return r=e&&e.response&&e.response.body?e.response.body.code+" "+e.response.body.message:e.message,new H("Could not resolve reference: "+r,t,e)}function o(e){return(e+"").split("#")}function i(e,t){var r=U[e];if(r&&!D.default.isPromise(r))try{var n=f(t,r);return(0,j.default)(_.default.resolve(n),{__value:n})}catch(e){return _.default.reject(e)}return l(e).then(function(e){return f(t,e)})}function s(e){void 0!==e?delete U[e]:(0,k.default)(U).forEach(function(e){delete U[e]})}function l(e){var t=U[e];return t?D.default.isPromise(t)?t:_.default.resolve(t):(U[e]=J.fetchJSON(e).then(function(t){return U[e]=t,t}),U[e])}function c(e){return(0,A.fetch)(e,{headers:{Accept:"application/json, application/yaml"},loadSpec:!0}).then(function(e){return e.text()}).then(function(e){return I.default.safeLoad(e)})}function f(e,t){var r=p(e);if(r.length<1)return t;var n=D.default.getIn(t,r);if(void 0===n)throw new H("Could not resolve pointer: "+e+" does not exist in document",{pointer:e});return n}function p(e){if("string"!=typeof e)throw new TypeError("Expected a string, got a "+(void 0===e?"undefined":(0,x.default)(e)));return"/"===e[0]&&(e=e.substr(1)),""===e?[]:e.split("/").map(d)}function d(e){return"string"!=typeof e?e:T.default.unescape(e.replace(/~1/g,"/").replace(/~0/g,"~"))}function h(e){return T.default.escape(e.replace(/~/g,"~0").replace(/\//g,"~1"))}function v(e){return 0===e.length?"":"/"+e.map(h).join("/")}function y(e,t){if(G(t))return!0;var r=e.charAt(t.length),n=t.slice(-1);return 0===e.indexOf(t)&&(!r||"/"===r||"#"===r)&&"#"!==n}function m(e,t,r,n){var a=L.get(n);a||(a={},L.set(n,a));var u=v(r),o=(t||"<specmap-base>")+"#"+e,i=u.replace(/allOf\/\d+\/?/g,"");if(t==n.contextTree.get([]).baseDoc&&y(i,e))return!0;var s="";if(r.some(function(e){return s=s+"/"+h(e),a[s]&&a[s].some(function(e){return y(e,o)||y(o,e)})}))return!0;a[i]=(a[i]||[]).concat(o)}function g(e,t){function r(e){return D.default.isObject(e)&&(n.indexOf(e)>=0||(0,k.default)(e).some(function(t){return r(e[t])}))}var n=[e];return t.path.reduce(function(e,t){return n.push(e[t]),e[t]},e),r(t.value)}Object.defineProperty(t,"__esModule",{value:!0});var b=r(1),x=n(b),P=r(0),k=n(P),w=r(19),_=n(w),O=r(40),q=n(O),M=r(2),j=n(M),A=r(41),C=r(17),I=n(C),E=r(42),T=n(E),S=r(7),F=n(S),N=r(10),D=n(N),R=r(23),$=n(R),z=r(24),B=new RegExp("^([a-z]+://|//)","i"),H=(0,$.default)("JSONRefError",function(e,t,r){this.originalError=r,(0,j.default)(this,t||{})}),U={},L=new q.default,V={key:"$ref",plugin:function(e,t,r,n){var s=n.getInstance(),l=r.slice(0,-1);if(!(0,z.isFreelyNamed)(l)){var c=n.getContext(r).baseDoc;if("string"!=typeof e)return new H("$ref: must be a string (JSON-Ref)",{$ref:e,baseDoc:c,fullPath:r});var f=o(e),d=f[0],h=f[1]||"",v=void 0;try{v=c||d?a(d,c):null}catch(t){return u(t,{pointer:h,$ref:e,basePath:v,fullPath:r})}var y=void 0,b=void 0;if(m(h,v,l,n)&&!s.useCircularStructures){var x=(0,z.absolutifyPointer)(e,v);return e===x?null:D.default.replace(r,x)}if(null==v?(b=p(h),void 0===(y=n.get(b))&&(y=new H("Could not resolve reference: "+e,{pointer:h,$ref:e,baseDoc:c,fullPath:r}))):(y=i(v,h),y=null!=y.__value?y.__value:y.catch(function(t){throw u(t,{pointer:h,$ref:e,baseDoc:c,fullPath:r})})),y instanceof Error)return[D.default.remove(r),y];var P=(0,z.absolutifyPointer)(e,v),k=D.default.replace(l,y,{$$ref:P});if(v&&v!==c)return[k,D.default.context(l,{baseDoc:v})];try{if(!g(n.state,k)||s.useCircularStructures)return k}catch(e){return null}}}},J=(0,j.default)(V,{docCache:U,absoluteify:a,clearCache:s,JSONRefError:H,wrapError:u,getDoc:l,split:o,extractFromDoc:i,fetchJSON:c,extract:f,jsonPointerToArray:p,unescapeJsonPointerToken:d});t.default=J;var G=function(e){return!e||"/"===e||"#"===e};e.exports=t.default},function(e,t){e.exports=require("babel-runtime/core-js/weak-map")},function(e,t){e.exports=require("cross-fetch")},function(e,t){e.exports=require("querystring-browser")},function(e,t){e.exports=require("traverse")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var a=r(12),u=n(a),o=r(2),i=n(o),s=r(24);t.default={key:"allOf",plugin:function(e,t,r,n,a){if(!a.meta||!a.meta.$$ref){var o=r.slice(0,-1);if(!(0,s.isFreelyNamed)(o)){if(!Array.isArray(e)){var l=new TypeError("allOf must be an array");return l.fullPath=r,l}var c=!1,f=a.value;o.forEach(function(e){f&&(f=f[e])}),f=(0,i.default)({},f),delete f.allOf;var p=[];return p.push(n.replace(o,{})),e.forEach(function(e,t){if(!n.isObject(e)){if(c)return null;c=!0;var a=new TypeError("Elements in allOf must be objects");return a.fullPath=r,p.push(a)}p.push(n.mergeDeep(o,e));var i=r.slice(0,-1),l=(0,s.generateAbsoluteRefPatches)(e,i,{getBaseUrlForNodePath:function(e){return n.getContext([].concat((0,u.default)(r),[t],(0,u.default)(e))).baseDoc},specmap:n});p.push.apply(p,(0,u.default)(l))}),p.push(n.mergeDeep(o,f)),f.$$ref||p.push(n.remove([].concat(o,"$$ref"))),p}}}},e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var a=r(2),u=n(a),o=r(10),i=n(o);t.default={key:"parameters",plugin:function(e,t,r,n,a){if(Array.isArray(e)&&e.length){var o=(0,u.default)([],e),s=r.slice(0,-1),l=(0,u.default)({},i.default.getIn(n.spec,s));return e.forEach(function(e,t){try{o[t].default=n.parameterMacro(l,e)}catch(e){var a=new Error(e);return a.fullPath=r,a}}),i.default.replace(r,o)}return i.default.replace(r,e)}},e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var a=r(2),u=n(a),o=r(10),i=n(o);t.default={key:"properties",plugin:function(e,t,r,n){var a=(0,u.default)({},e);for(var o in e)try{a[o].default=n.modelPropertyMacro(a[o])}catch(e){var s=new Error(e);return s.fullPath=r,s}return i.default.replace(r,a)}},e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e,t){return u({children:{}},e,t)}function u(e,t,r){return e.value=t||{},e.protoValue=r?(0,l.default)({},r.protoValue,e.value):e.value,(0,i.default)(e.children).forEach(function(t){var r=e.children[t];e.children[t]=u(r,r.value,e)}),e}Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=n(o),s=r(3),l=n(s),c=r(21),f=n(c),p=r(22),d=n(p),h=function(){function e(t){(0,f.default)(this,e),this.root=a(t||{})}return(0,d.default)(e,[{key:"set",value:function(e,t){var r=this.getParent(e,!0);if(!r)return void u(this.root,t,null);var n=e[e.length-1],o=r.children;if(o[n])return void u(o[n],t,r);o[n]=a(t,r)}},{key:"get",value:function(e){if(e=e||[],e.length<1)return this.root.value;for(var t=this.root,r=void 0,n=void 0,a=0;a<e.length&&(n=e[a],r=t.children,r[n]);a++)t=r[n];return t&&t.protoValue}},{key:"getParent",value:function(e,t){return!e||e.length<1?null:e.length<2?this.root:e.slice(0,-1).reduce(function(e,r){if(!e)return e;var n=e.children;return!n[r]&&t&&(n[r]=a(null,e)),n[r]},this.root)}}]),e}();t.default=h,e.exports=t.default},function(e,t){e.exports=require("lodash/isObject")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var a=r(4),u=n(a),o=r(3),i=n(o),s=r(11),l=n(s),c=r(13),f=n(c),p=r(18),d=n(p),h=r(5);t.default=function(){function e(e,r){return t.apply(this,arguments)}var t=(0,l.default)(u.default.mark(function e(t,r){var n,a,o,s,l,c,p,v,y,m,g,b=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=b.returnEntireTree,a=b.baseDoc,o=b.requestInterceptor,s=b.responseInterceptor,l=b.parameterMacro,c=b.modelPropertyMacro,p=b.useCircularStructures,v={pathDiscriminator:r,baseDoc:a,requestInterceptor:o,responseInterceptor:s,parameterMacro:l,modelPropertyMacro:c,useCircularStructures:p},y=(0,h.normalizeSwagger)({spec:t}),m=y.spec,e.next=5,(0,d.default)((0,i.default)({},v,{spec:m,allowMetaPatches:!0,skipNormalization:!0}));case 5:return g=e.sent,!n&&Array.isArray(r)&&r.length&&(g.spec=(0,f.default)(g.spec,r)||null),e.abrupt("return",g);case 8:case"end":return e.stop()}},e,this)}));return e}(),e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t){var r=t.pathName,n=t.method,a=t.operationId;return function(t){var u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.execute((0,l.default)({spec:e.spec},(0,f.default)(e,"requestInterceptor","responseInterceptor","userFetch"),{pathName:r,method:n,parameters:t,operationId:a},u))}}}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=v.makeExecute(e),r=v.mapTagOperations({v2OperationIdCompatibilityMode:e.v2OperationIdCompatibilityMode,spec:e.spec,cb:t}),n={};for(var a in r){n[a]={operations:{}};for(var u in r[a])n[a].operations[u]={execute:r[a][u]}}return{apis:n}}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=v.makeExecute(e);return{apis:v.mapTagOperations({v2OperationIdCompatibilityMode:e.v2OperationIdCompatibilityMode,spec:e.spec,cb:t})}}function i(e){var t=e.spec,r=e.cb,n=void 0===r?d:r,a=e.defaultTag,u=void 0===a?"default":a,o=e.v2OperationIdCompatibilityMode,i={},s={};return(0,p.eachOperation)(t,function(e){var r=e.pathName,a=e.method,l=e.operation;(l.tags?h(l.tags):[u]).forEach(function(e){if("string"==typeof e){var u=s[e]=s[e]||{},c=(0,p.opId)(l,r,a,{v2OperationIdCompatibilityMode:o}),f=n({spec:t,pathName:r,method:a,operation:l,operationId:c});if(i[c])i[c]++,u[""+c+i[c]]=f;else if(void 0!==u[c]){var d=i[c]||1;i[c]=d+1,u[""+c+i[c]]=f;var h=u[c];delete u[c],u[""+c+d]=h}else u[c]=f}})}),s}Object.defineProperty(t,"__esModule",{value:!0}),t.self=void 0;var s=r(3),l=n(s);t.makeExecute=a,t.makeApisTagOperationsOperationExecute=u,t.makeApisTagOperation=o,t.mapTagOperations=i;var c=r(51),f=n(c),p=r(5),d=function(){return null},h=function(e){return Array.isArray(e)?e:[e]},v=t.self={mapTagOperations:i,makeExecute:a}},function(e,t){e.exports=require("lodash/pick")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e){var t=e.http,r=e.fetch,n=e.spec,a=e.operationId,u=e.pathName,o=e.method,i=e.parameters,s=e.securities,l=(0,y.default)(e,["http","fetch","spec","operationId","pathName","method","parameters","securities"]),c=t||r||S.default;u&&o&&!a&&(a=(0,V.legacyIdFromPathMethod)(u,o));var f=K.buildRequest((0,h.default)({spec:n,operationId:a,parameters:i,securities:s,http:c},l));return f.body&&((0,O.default)(f.body)||(0,M.default)(f.body))&&(f.body=(0,p.default)(f.body)),c(f)}function u(e){var t=e.spec,r=e.operationId,n=(e.securities,e.requestContentType,e.responseContentType),a=e.scheme,u=e.requestInterceptor,i=e.responseInterceptor,s=e.contextUrl,l=e.userFetch,c=(e.requestBody,e.server),f=e.serverVariables,p=e.http,d=e.parameters,v=e.parameterBuilders,y=(0,V.isOAS3)(t);v||(v=y?z.default:R.default);var m=p&&p.withCredentials?"include":"same-origin",b={url:"",credentials:m,headers:{},cookies:{}};u&&(b.requestInterceptor=u),i&&(b.responseInterceptor=i),l&&(b.userFetch=l);var x=(0,V.getOperationRaw)(t,r);if(!x)throw new G("Operation "+r+" not found");var P=x.operation,k=void 0===P?{}:P,w=x.method,_=x.pathName;if(b.url+=o({spec:t,scheme:a,contextUrl:s,server:c,serverVariables:f,pathName:_,method:w}),!r)return delete b.cookies,b;b.url+=_,b.method=(""+w).toUpperCase(),d=d||{};var O=t.paths[_]||{};n&&(b.headers.accept=n);var q=W([].concat(J(k.parameters)).concat(J(O.parameters)));q.forEach(function(e){var r=v[e.in],n=void 0;if("body"===e.in&&e.schema&&e.schema.properties&&(n=d),n=e&&e.name&&d[e.name],void 0===n?n=e&&e.name&&d[e.in+"."+e.name]:Q(e.name,q).length>1&&console.warn("Parameter '"+e.name+"' is ambiguous because the defined spec has more than one parameter with the name: '"+e.name+"' and the passed-in parameter values did not define an 'in' value."),null!==n){if(void 0!==e.default&&void 0===n&&(n=e.default),void 0===n&&e.required&&!e.allowEmptyValue)throw new Error("Required parameter "+e.name+" is not provided");if(y&&e.schema&&"object"===e.schema.type&&"string"==typeof n)try{n=JSON.parse(n)}catch(e){throw new Error("Could not parse object parameter value string as JSON")}r&&r({req:b,parameter:e,value:n,operation:k,spec:t})}});var M=(0,h.default)({},e,{operation:k});if(b=y?(0,H.default)(M,b):(0,L.default)(M,b),b.cookies&&(0,g.default)(b.cookies).length){var j=(0,g.default)(b.cookies).reduce(function(e,t){var r=b.cookies[t];return e+(e?"&":"")+E.default.serialize(t,r)},"");b.headers.Cookie=j}return b.cookies&&delete b.cookies,(0,T.mergeInQueryOrForm)(b),b}function o(e){return(0,V.isOAS3)(e.spec)?i(e):c(e)}function i(e){var t=e.spec,r=e.pathName,n=e.method,a=e.server,u=e.contextUrl,o=e.serverVariables,i=void 0===o?{}:o,c=(0,w.default)(t,["paths",r,(n||"").toLowerCase(),"servers"])||(0,w.default)(t,["paths",r,"servers"])||(0,w.default)(t,["servers"]),f="",p=null;if(a&&c&&c.length){var d=c.map(function(e){return e.url});d.indexOf(a)>-1&&(f=a,p=c[d.indexOf(a)])}if(!f&&c&&c.length&&(f=c[0].url,p=c[0]),f.indexOf("{")>-1){l(f).forEach(function(e){if(p.variables&&p.variables[e]){var t=p.variables[e],r=i[e]||t.default,n=new RegExp("{"+e+"}","g");f=f.replace(n,r)}})}return s(f,u)}function s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=C.default.parse(e),n=C.default.parse(t),a=Y(r.protocol)||Y(n.protocol)||"",u=r.host||n.host,o=r.pathname||"",i=void 0;return i=a&&u?a+"://"+(u+o):o,"/"===i[i.length-1]?i.slice(0,-1):i}function l(e){for(var t=[],r=/{([^}]+)}/g,n=void 0;n=r.exec(e);)t.push(n[1]);return t}function c(e){var t=e.spec,r=e.scheme,n=e.contextUrl,a=void 0===n?"":n,u=C.default.parse(a),o=Array.isArray(t.schemes)?t.schemes[0]:null,i=r||o||Y(u.protocol)||"http",s=t.host||u.host||"",l=t.basePath||"",c=void 0;return c=i&&s?i+"://"+(s+l):l,"/"===c[c.length-1]?c.slice(0,-1):c}Object.defineProperty(t,"__esModule",{value:!0}),t.self=void 0;var f=r(9),p=n(f),d=r(3),h=n(d),v=r(53),y=n(v),m=r(0),g=n(m),b=r(2),x=n(b);t.execute=a,t.buildRequest=u,t.baseUrl=o;var P=r(6),k=(n(P),r(13)),w=n(k),_=r(54),O=n(_),q=r(55),M=n(q),j=r(14),A=(n(j),r(7)),C=n(A),I=r(56),E=n(I),T=r(8),S=n(T),F=r(23),N=n(F),D=r(57),R=n(D),$=r(58),z=n($),B=r(63),H=n(B),U=r(65),L=n(U),V=r(5),J=function(e){return Array.isArray(e)?e:[]},G=(0,N.default)("OperationNotFoundError",function(e,t,r){this.originalError=r,(0,x.default)(this,t||{})}),Q=function(e,t){return t.filter(function(t){return t.name===e})},W=function(e){var t={};e.forEach(function(e){t[e.in]||(t[e.in]={}),t[e.in][e.name]=e});var r=[];return(0,g.default)(t).forEach(function(e){(0,g.default)(t[e]).forEach(function(n){r.push(t[e][n])})}),r},K=t.self={buildRequest:u},Y=function(e){return e?e.replace(/\W/g,""):null}},function(e,t){e.exports=require("babel-runtime/helpers/objectWithoutProperties")},function(e,t){e.exports=require("lodash/isPlainObject")},function(e,t){e.exports=require("lodash/isArray")},function(e,t){e.exports=require("cookie")},function(e,t,r){"use strict";function n(e){var t=e.req,r=e.value;t.body=r}function a(e){var t=e.req,r=e.value,n=e.parameter;(r||n.allowEmptyValue)&&(t.form=t.form||{},t.form[n.name]={value:r,allowEmptyValue:n.allowEmptyValue,collectionFormat:n.collectionFormat})}function u(e){var t=e.req,r=e.parameter,n=e.value;t.headers=t.headers||{},void 0!==n&&(t.headers[r.name]=n)}function o(e){var t=e.req,r=e.value,n=e.parameter;t.url=t.url.split("{"+n.name+"}").join(encodeURIComponent(r))}function i(e){var t=e.req,r=e.value,n=e.parameter;if(t.query=t.query||{},!1===r&&"boolean"===n.type&&(r="false"),0===r&&["number","integer"].indexOf(n.type)>-1&&(r="0"),r)t.query[n.name]={collectionFormat:n.collectionFormat,value:r};else if(n.allowEmptyValue&&void 0!==r){var a=n.name;t.query[a]=t.query[a]||{},t.query[a].allowEmptyValue=!0}}Object.defineProperty(t,"__esModule",{value:!0}),t.default={body:n,header:u,query:i,path:o,formData:a},e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e){var t=e.req,r=e.value,n=e.parameter,a=n.name,u=n.style,o=n.explode,i=(0,d.default)({key:n.name,value:r,style:u||"simple",explode:o||!1,escape:!0});t.url=t.url.split("{"+a+"}").join(i)}function u(e){var t=e.req,r=e.value,n=e.parameter;if(t.query=t.query||{},!1===r&&(r="false"),0===r&&(r="0"),r){var a=void 0===r?"undefined":(0,f.default)(r);if("deepObject"===n.style){(0,l.default)(r).forEach(function(e){var a=r[e];t.query[n.name+"["+e+"]"]={value:(0,d.default)({key:e,value:a,style:"deepObject",escape:n.allowReserved?"unsafe":"reserved"}),skipEncoding:!0}})}else if("object"!==a||Array.isArray(r)||"form"!==n.style&&n.style||!n.explode&&void 0!==n.explode)t.query[n.name]={value:(0,d.default)({key:n.name,value:r,style:n.style||"form",explode:void 0===n.explode||n.explode,escape:n.allowReserved?"unsafe":"reserved"}),skipEncoding:!0};else{var u=(0,l.default)(r);u.forEach(function(e){var a=r[e];t.query[e]={value:(0,d.default)({key:e,value:a,style:n.style||"form",escape:n.allowReserved?"unsafe":"reserved"}),skipEncoding:!0}})}}else if(n.allowEmptyValue&&void 0!==r){var o=n.name;t.query[o]=t.query[o]||{},t.query[o].allowEmptyValue=!0}}function o(e){var t=e.req,r=e.parameter,n=e.value;t.headers=t.headers||{},h.indexOf(r.name.toLowerCase())>-1||void 0!==n&&(t.headers[r.name]=(0,d.default)({key:r.name,value:n,style:r.style||"simple",explode:void 0!==r.explode&&r.explode,escape:!1}))}function i(e){var t=e.req,r=e.parameter,n=e.value;t.headers=t.headers||{};var a=void 0===n?"undefined":(0,f.default)(n);if("undefined"!==a){var u="object"===a&&!Array.isArray(n)&&r.explode?"":r.name+"=";t.headers.Cookie=u+(0,d.default)({key:r.name,value:n,escape:!1,style:r.style||"form",explode:void 0!==r.explode&&r.explode})}}Object.defineProperty(t,"__esModule",{value:!0});var s=r(0),l=n(s),c=r(1),f=n(c),p=r(59),d=n(p);t.default={path:a,query:u,header:o,cookie:i};var h=["accept","authorization","content-type"];e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.escape,n=arguments[2];return"number"==typeof e&&(e=e.toString()),"string"==typeof e&&e.length&&r?n?JSON.parse(e):(0,v.stringToCharArray)(e).map(function(e){return m(e)?e:y(e)&&"unsafe"===r?e:((0,h.default)(e)||[]).map(function(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}).map(function(e){return"%"+e}).join("")}).join(""):e}function u(e){var t=e.key,r=e.value,n=e.style,u=e.explode,o=e.escape,i=function(e){return a(e,{escape:o})};if("simple"===n)return r.map(function(e){return i(e)}).join(",");if("label"===n)return"."+r.map(function(e){return i(e)}).join(".");if("matrix"===n)return r.map(function(e){return i(e)}).reduce(function(e,r){return!e||u?(e||"")+";"+t+"="+r:e+","+r},"");if("form"===n){var s=u?"&"+t+"=":",";return r.map(function(e){return i(e)}).join(s)}if("spaceDelimited"===n){var l=u?t+"=":"";return r.map(function(e){return i(e)}).join(" "+l)}if("pipeDelimited"===n){var c=u?t+"=":"";return r.map(function(e){return i(e)}).join("|"+c)}}function o(e){var t=e.key,r=e.value,n=e.style,u=e.explode,o=e.escape,i=function(e){return a(e,{escape:o})},s=(0,l.default)(r);return"simple"===n?s.reduce(function(e,t){var n=i(r[t]),a=u?"=":",";return(e?e+",":"")+t+a+n},""):"label"===n?s.reduce(function(e,t){var n=i(r[t]),a=u?"=":".";return(e?e+".":".")+t+a+n},""):"matrix"===n&&u?s.reduce(function(e,t){var n=i(r[t]);return(e?e+";":";")+t+"="+n},""):"matrix"===n?s.reduce(function(e,n){var a=i(r[n]);return(e?e+",":";"+t+"=")+n+","+a},""):"form"===n?s.reduce(function(e,t){var n=i(r[t]);return(e?e+(u?"&":","):"")+t+(u?"=":",")+n},""):void 0}function i(e){var t=e.key,r=e.value,n=e.style,u=e.escape,o=function(e){return a(e,{escape:u})};return"simple"===n?o(r):"label"===n?"."+o(r):"matrix"===n?";"+t+"="+o(r):"form"===n?o(r):"deepObject"===n?o(r):void 0}Object.defineProperty(t,"__esModule",{value:!0});var s=r(0),l=n(s),c=r(1),f=n(c);t.encodeDisallowedCharacters=a,t.default=function(e){var t=e.value;return Array.isArray(t)?u(e):"object"===(void 0===t?"undefined":(0,f.default)(t))?o(e):i(e)};var p=r(60),d=(n(p),r(61)),h=n(d),v=r(62),y=function(e){return":/?#[]@!$&'()*+,;=".indexOf(e)>-1},m=function(e){return/^[a-z0-9\-._~]+$/i.test(e)}},function(e,t){e.exports=require("encode-3986")},function(e,t){e.exports=require("utf8-bytes")},function(e,t){e.exports=require("utfstring")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e){var t=e.request,r=e.securities,n=void 0===r?{}:r,a=e.operation,u=void 0===a?{}:a,o=e.spec,i=(0,p.default)({},t),s=n.authorized,l=void 0===s?{}:s,f=u.security||o.security||[],d=l&&!!(0,c.default)(l).length,v=(0,h.default)(o,["components","securitySchemes"])||{};return i.headers=i.headers||{},i.query=i.query||{},(0,c.default)(n).length&&d&&f&&(!Array.isArray(u.security)||u.security.length)?(f.forEach(function(e,t){for(var r in e){var n=l[r],a=v[r];if(n){var u=n.value||n,o=a.type;if(n)if("apiKey"===o)"query"===a.in&&(i.query[a.name]=u),"header"===a.in&&(i.headers[a.name]=u),"cookie"===a.in&&(i.cookies[a.name]=u);else if("http"===o){if("basic"===a.scheme){var s=u.username,c=u.password,f=(0,y.default)(s+":"+c);i.headers.Authorization="Basic "+f}"bearer"===a.scheme&&(i.headers.Authorization="Bearer "+u)}else if("oauth2"===o){var p=n.token||{},d=p.access_token,h=p.token_type;h&&"bearer"!==h.toLowerCase()||(h="Bearer"),i.headers.Authorization=h+" "+d}}}}),i):t}Object.defineProperty(t,"__esModule",{value:!0});var u=r(9),o=n(u),i=r(1),s=n(i),l=r(0),c=n(l);t.default=function(e,t){var r=e.operation,n=e.requestBody,u=e.securities,i=e.spec,l=e.attachContentTypeForEmptyPayload,f=e.requestContentType;t=a({request:t,securities:u,operation:r,spec:i});var p=r.requestBody||{},d=(0,c.default)(p.content||{}),h=f&&d.indexOf(f)>-1;if(n||l){if(f&&h)t.headers["Content-Type"]=f;else if(!f){var v=d[0];v&&(t.headers["Content-Type"]=v,f=v)}}else f&&h&&(t.headers["Content-Type"]=f);return n&&(f?d.indexOf(f)>-1&&("application/x-www-form-urlencoded"===f||0===f.indexOf("multipart/")?"object"===(void 0===n?"undefined":(0,s.default)(n))?(t.form={},(0,c.default)(n).forEach(function(e){var r=n[e],a=void 0,u=void 0;"undefined"!=typeof File&&(u=r instanceof File),"undefined"!=typeof Blob&&(u=u||r instanceof Blob),void 0!==m.Buffer&&(u=u||m.Buffer.isBuffer(r)),a="object"!==(void 0===r?"undefined":(0,s.default)(r))||u?r:Array.isArray(r)?r.toString():(0,o.default)(r),t.form[e]={value:a}})):t.form=n:t.body=n):t.body=n),t},t.applySecurities=a;var f=r(6),p=n(f),d=r(13),h=n(d),v=r(14),y=n(v),m=r(64)},function(e,t){e.exports=require("buffer/")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e){var t=e.request,r=e.securities,n=void 0===r?{}:r,a=e.operation,u=void 0===a?{}:a,i=e.spec,l=(0,c.default)({},t),f=n.authorized,p=void 0===f?{}:f,d=n.specSecurity,h=void 0===d?[]:d,v=u.security||h,y=p&&!!(0,o.default)(p).length,m=i.securityDefinitions;return l.headers=l.headers||{},l.query=l.query||{},(0,o.default)(n).length&&y&&v&&(!Array.isArray(u.security)||u.security.length)?(v.forEach(function(e,t){for(var r in e){var n=p[r];if(n){var a=n.token,u=n.value||n,o=m[r],i=o.type,c=o["x-tokenName"]||"access_token",f=a&&a[c],d=a&&a.token_type;if(n)if("apiKey"===i){var h="query"===o.in?"query":"headers";l[h]=l[h]||{},l[h][o.name]=u}else"basic"===i?u.header?l.headers.authorization=u.header:(u.base64=(0,s.default)(u.username+":"+u.password),l.headers.authorization="Basic "+u.base64):"oauth2"===i&&f&&(d=d&&"bearer"!==d.toLowerCase()?d:"Bearer",l.headers.authorization=d+" "+f)}}}),l):t}Object.defineProperty(t,"__esModule",{value:!0});var u=r(0),o=n(u);t.default=function(e,t){var r=e.spec,n=e.operation,u=e.securities,o=e.requestContentType,i=e.attachContentTypeForEmptyPayload;if(t=a({request:t,securities:u,operation:n,spec:r}),t.body||t.form||i)o?t.headers["Content-Type"]=o:Array.isArray(n.consumes)?t.headers["Content-Type"]=n.consumes[0]:Array.isArray(r.consumes)?t.headers["Content-Type"]=r.consumes[0]:n.parameters&&n.parameters.filter(function(e){return"file"===e.type}).length?t.headers["Content-Type"]="multipart/form-data":n.parameters&&n.parameters.filter(function(e){return"formData"===e.in}).length&&(t.headers["Content-Type"]="application/x-www-form-urlencoded");else if(o){var s=n.parameters&&n.parameters.filter(function(e){return"body"===e.in}).length>0,l=n.parameters&&n.parameters.filter(function(e){return"formData"===e.in}).length>0;(s||l)&&(t.headers["Content-Type"]=o)}return t},t.applySecurities=a;var i=r(14),s=n(i),l=r(6),c=n(l),f=r(8);n(f)}]);
|
|
1
|
+
module.exports =
|
|
2
|
+
/******/ (function(modules) { // webpackBootstrap
|
|
3
|
+
/******/ // The module cache
|
|
4
|
+
/******/ var installedModules = {};
|
|
5
|
+
/******/
|
|
6
|
+
/******/ // The require function
|
|
7
|
+
/******/ function __webpack_require__(moduleId) {
|
|
8
|
+
/******/
|
|
9
|
+
/******/ // Check if module is in cache
|
|
10
|
+
/******/ if(installedModules[moduleId]) {
|
|
11
|
+
/******/ return installedModules[moduleId].exports;
|
|
12
|
+
/******/ }
|
|
13
|
+
/******/ // Create a new module (and put it into the cache)
|
|
14
|
+
/******/ var module = installedModules[moduleId] = {
|
|
15
|
+
/******/ i: moduleId,
|
|
16
|
+
/******/ l: false,
|
|
17
|
+
/******/ exports: {}
|
|
18
|
+
/******/ };
|
|
19
|
+
/******/
|
|
20
|
+
/******/ // Execute the module function
|
|
21
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
22
|
+
/******/
|
|
23
|
+
/******/ // Flag the module as loaded
|
|
24
|
+
/******/ module.l = true;
|
|
25
|
+
/******/
|
|
26
|
+
/******/ // Return the exports of the module
|
|
27
|
+
/******/ return module.exports;
|
|
28
|
+
/******/ }
|
|
29
|
+
/******/
|
|
30
|
+
/******/
|
|
31
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
32
|
+
/******/ __webpack_require__.m = modules;
|
|
33
|
+
/******/
|
|
34
|
+
/******/ // expose the module cache
|
|
35
|
+
/******/ __webpack_require__.c = installedModules;
|
|
36
|
+
/******/
|
|
37
|
+
/******/ // define getter function for harmony exports
|
|
38
|
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
39
|
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
40
|
+
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
41
|
+
/******/ }
|
|
42
|
+
/******/ };
|
|
43
|
+
/******/
|
|
44
|
+
/******/ // define __esModule on exports
|
|
45
|
+
/******/ __webpack_require__.r = function(exports) {
|
|
46
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
47
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
48
|
+
/******/ }
|
|
49
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
50
|
+
/******/ };
|
|
51
|
+
/******/
|
|
52
|
+
/******/ // create a fake namespace object
|
|
53
|
+
/******/ // mode & 1: value is a module id, require it
|
|
54
|
+
/******/ // mode & 2: merge all properties of value into the ns
|
|
55
|
+
/******/ // mode & 4: return value when already ns object
|
|
56
|
+
/******/ // mode & 8|1: behave like require
|
|
57
|
+
/******/ __webpack_require__.t = function(value, mode) {
|
|
58
|
+
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
59
|
+
/******/ if(mode & 8) return value;
|
|
60
|
+
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
61
|
+
/******/ var ns = Object.create(null);
|
|
62
|
+
/******/ __webpack_require__.r(ns);
|
|
63
|
+
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
64
|
+
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
65
|
+
/******/ return ns;
|
|
66
|
+
/******/ };
|
|
67
|
+
/******/
|
|
68
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
69
|
+
/******/ __webpack_require__.n = function(module) {
|
|
70
|
+
/******/ var getter = module && module.__esModule ?
|
|
71
|
+
/******/ function getDefault() { return module['default']; } :
|
|
72
|
+
/******/ function getModuleExports() { return module; };
|
|
73
|
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
74
|
+
/******/ return getter;
|
|
75
|
+
/******/ };
|
|
76
|
+
/******/
|
|
77
|
+
/******/ // Object.prototype.hasOwnProperty.call
|
|
78
|
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
79
|
+
/******/
|
|
80
|
+
/******/ // __webpack_public_path__
|
|
81
|
+
/******/ __webpack_require__.p = "";
|
|
82
|
+
/******/
|
|
83
|
+
/******/
|
|
84
|
+
/******/ // Load entry module and return exports
|
|
85
|
+
/******/ return __webpack_require__(__webpack_require__.s = 45);
|
|
86
|
+
/******/ })
|
|
87
|
+
/************************************************************************/
|
|
88
|
+
/******/ ([
|
|
89
|
+
/* 0 */
|
|
90
|
+
/***/ (function(module, exports) {
|
|
91
|
+
|
|
92
|
+
module.exports = require("@babel/runtime-corejs2/core-js/object/keys");
|
|
93
|
+
|
|
94
|
+
/***/ }),
|
|
95
|
+
/* 1 */
|
|
96
|
+
/***/ (function(module, exports) {
|
|
97
|
+
|
|
98
|
+
module.exports = require("@babel/runtime-corejs2/core-js/array/is-array");
|
|
99
|
+
|
|
100
|
+
/***/ }),
|
|
101
|
+
/* 2 */
|
|
102
|
+
/***/ (function(module, exports) {
|
|
103
|
+
|
|
104
|
+
module.exports = require("@babel/runtime-corejs2/helpers/typeof");
|
|
105
|
+
|
|
106
|
+
/***/ }),
|
|
107
|
+
/* 3 */
|
|
108
|
+
/***/ (function(module, exports) {
|
|
109
|
+
|
|
110
|
+
module.exports = require("@babel/runtime-corejs2/core-js/object/assign");
|
|
111
|
+
|
|
112
|
+
/***/ }),
|
|
113
|
+
/* 4 */
|
|
114
|
+
/***/ (function(module, exports) {
|
|
115
|
+
|
|
116
|
+
module.exports = require("@babel/runtime-corejs2/regenerator");
|
|
117
|
+
|
|
118
|
+
/***/ }),
|
|
119
|
+
/* 5 */
|
|
120
|
+
/***/ (function(module, exports) {
|
|
121
|
+
|
|
122
|
+
module.exports = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
|
|
123
|
+
|
|
124
|
+
/***/ }),
|
|
125
|
+
/* 6 */
|
|
126
|
+
/***/ (function(module, exports) {
|
|
127
|
+
|
|
128
|
+
module.exports = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
129
|
+
|
|
130
|
+
/***/ }),
|
|
131
|
+
/* 7 */
|
|
132
|
+
/***/ (function(module, exports) {
|
|
133
|
+
|
|
134
|
+
module.exports = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
|
|
135
|
+
|
|
136
|
+
/***/ }),
|
|
137
|
+
/* 8 */
|
|
138
|
+
/***/ (function(module, exports) {
|
|
139
|
+
|
|
140
|
+
module.exports = require("@babel/runtime-corejs2/helpers/defineProperty");
|
|
141
|
+
|
|
142
|
+
/***/ }),
|
|
143
|
+
/* 9 */
|
|
144
|
+
/***/ (function(module, exports) {
|
|
145
|
+
|
|
146
|
+
module.exports = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
147
|
+
|
|
148
|
+
/***/ }),
|
|
149
|
+
/* 10 */
|
|
150
|
+
/***/ (function(module, exports) {
|
|
151
|
+
|
|
152
|
+
module.exports = require("@babel/runtime-corejs2/core-js/object/define-properties");
|
|
153
|
+
|
|
154
|
+
/***/ }),
|
|
155
|
+
/* 11 */
|
|
156
|
+
/***/ (function(module, exports) {
|
|
157
|
+
|
|
158
|
+
module.exports = require("@babel/runtime-corejs2/core-js/json/stringify");
|
|
159
|
+
|
|
160
|
+
/***/ }),
|
|
161
|
+
/* 12 */
|
|
162
|
+
/***/ (function(module, exports) {
|
|
163
|
+
|
|
164
|
+
module.exports = require("url");
|
|
165
|
+
|
|
166
|
+
/***/ }),
|
|
167
|
+
/* 13 */
|
|
168
|
+
/***/ (function(module, exports) {
|
|
169
|
+
|
|
170
|
+
module.exports = require("@babel/runtime-corejs2/helpers/toConsumableArray");
|
|
171
|
+
|
|
172
|
+
/***/ }),
|
|
173
|
+
/* 14 */
|
|
174
|
+
/***/ (function(module, exports) {
|
|
175
|
+
|
|
176
|
+
module.exports = require("@babel/runtime-corejs2/core-js/promise");
|
|
177
|
+
|
|
178
|
+
/***/ }),
|
|
179
|
+
/* 15 */
|
|
180
|
+
/***/ (function(module, exports) {
|
|
181
|
+
|
|
182
|
+
module.exports = require("lodash/assign");
|
|
183
|
+
|
|
184
|
+
/***/ }),
|
|
185
|
+
/* 16 */
|
|
186
|
+
/***/ (function(module, exports) {
|
|
187
|
+
|
|
188
|
+
module.exports = require("lodash/get");
|
|
189
|
+
|
|
190
|
+
/***/ }),
|
|
191
|
+
/* 17 */
|
|
192
|
+
/***/ (function(module, exports) {
|
|
193
|
+
|
|
194
|
+
module.exports = require("@babel/runtime-corejs2/helpers/asyncToGenerator");
|
|
195
|
+
|
|
196
|
+
/***/ }),
|
|
197
|
+
/* 18 */
|
|
198
|
+
/***/ (function(module, exports) {
|
|
199
|
+
|
|
200
|
+
module.exports = require("fast-json-patch");
|
|
201
|
+
|
|
202
|
+
/***/ }),
|
|
203
|
+
/* 19 */
|
|
204
|
+
/***/ (function(module, exports) {
|
|
205
|
+
|
|
206
|
+
module.exports = require("btoa");
|
|
207
|
+
|
|
208
|
+
/***/ }),
|
|
209
|
+
/* 20 */
|
|
210
|
+
/***/ (function(module, exports) {
|
|
211
|
+
|
|
212
|
+
module.exports = require("lodash/startsWith");
|
|
213
|
+
|
|
214
|
+
/***/ }),
|
|
215
|
+
/* 21 */
|
|
216
|
+
/***/ (function(module, exports) {
|
|
217
|
+
|
|
218
|
+
module.exports = require("@babel/runtime-corejs2/core-js/get-iterator");
|
|
219
|
+
|
|
220
|
+
/***/ }),
|
|
221
|
+
/* 22 */
|
|
222
|
+
/***/ (function(module, exports) {
|
|
223
|
+
|
|
224
|
+
module.exports = require("@babel/runtime-corejs2/helpers/slicedToArray");
|
|
225
|
+
|
|
226
|
+
/***/ }),
|
|
227
|
+
/* 23 */
|
|
228
|
+
/***/ (function(module, exports) {
|
|
229
|
+
|
|
230
|
+
module.exports = require("js-yaml");
|
|
231
|
+
|
|
232
|
+
/***/ }),
|
|
233
|
+
/* 24 */
|
|
234
|
+
/***/ (function(module, exports) {
|
|
235
|
+
|
|
236
|
+
module.exports = require("@babel/runtime-corejs2/helpers/classCallCheck");
|
|
237
|
+
|
|
238
|
+
/***/ }),
|
|
239
|
+
/* 25 */
|
|
240
|
+
/***/ (function(module, exports) {
|
|
241
|
+
|
|
242
|
+
module.exports = require("@babel/runtime-corejs2/helpers/createClass");
|
|
243
|
+
|
|
244
|
+
/***/ }),
|
|
245
|
+
/* 26 */
|
|
246
|
+
/***/ (function(module, exports) {
|
|
247
|
+
|
|
248
|
+
module.exports = require("qs");
|
|
249
|
+
|
|
250
|
+
/***/ }),
|
|
251
|
+
/* 27 */
|
|
252
|
+
/***/ (function(module, exports) {
|
|
253
|
+
|
|
254
|
+
module.exports = require("@babel/runtime-corejs2/core-js/object/create");
|
|
255
|
+
|
|
256
|
+
/***/ }),
|
|
257
|
+
/* 28 */
|
|
258
|
+
/***/ (function(module, exports) {
|
|
259
|
+
|
|
260
|
+
module.exports = require("querystring-browser");
|
|
261
|
+
|
|
262
|
+
/***/ }),
|
|
263
|
+
/* 29 */
|
|
264
|
+
/***/ (function(module, exports) {
|
|
265
|
+
|
|
266
|
+
module.exports = require("lodash/isObject");
|
|
267
|
+
|
|
268
|
+
/***/ }),
|
|
269
|
+
/* 30 */
|
|
270
|
+
/***/ (function(module, exports) {
|
|
271
|
+
|
|
272
|
+
module.exports = require("buffer/");
|
|
273
|
+
|
|
274
|
+
/***/ }),
|
|
275
|
+
/* 31 */
|
|
276
|
+
/***/ (function(module, exports) {
|
|
277
|
+
|
|
278
|
+
module.exports = require("lodash/isString");
|
|
279
|
+
|
|
280
|
+
/***/ }),
|
|
281
|
+
/* 32 */
|
|
282
|
+
/***/ (function(module, exports) {
|
|
283
|
+
|
|
284
|
+
module.exports = require("lodash/find");
|
|
285
|
+
|
|
286
|
+
/***/ }),
|
|
287
|
+
/* 33 */
|
|
288
|
+
/***/ (function(module, exports) {
|
|
289
|
+
|
|
290
|
+
module.exports = require("deep-extend");
|
|
291
|
+
|
|
292
|
+
/***/ }),
|
|
293
|
+
/* 34 */
|
|
294
|
+
/***/ (function(module, exports) {
|
|
295
|
+
|
|
296
|
+
module.exports = require("@kyleshockey/object-assign-deep");
|
|
297
|
+
|
|
298
|
+
/***/ }),
|
|
299
|
+
/* 35 */
|
|
300
|
+
/***/ (function(module, exports) {
|
|
301
|
+
|
|
302
|
+
module.exports = require("@babel/runtime-corejs2/core-js/weak-map");
|
|
303
|
+
|
|
304
|
+
/***/ }),
|
|
305
|
+
/* 36 */
|
|
306
|
+
/***/ (function(module, exports) {
|
|
307
|
+
|
|
308
|
+
module.exports = require("cross-fetch");
|
|
309
|
+
|
|
310
|
+
/***/ }),
|
|
311
|
+
/* 37 */
|
|
312
|
+
/***/ (function(module, exports) {
|
|
313
|
+
|
|
314
|
+
module.exports = require("traverse");
|
|
315
|
+
|
|
316
|
+
/***/ }),
|
|
317
|
+
/* 38 */
|
|
318
|
+
/***/ (function(module, exports) {
|
|
319
|
+
|
|
320
|
+
module.exports = require("lodash/pick");
|
|
321
|
+
|
|
322
|
+
/***/ }),
|
|
323
|
+
/* 39 */
|
|
324
|
+
/***/ (function(module, exports) {
|
|
325
|
+
|
|
326
|
+
module.exports = require("@babel/runtime-corejs2/helpers/objectWithoutProperties");
|
|
327
|
+
|
|
328
|
+
/***/ }),
|
|
329
|
+
/* 40 */
|
|
330
|
+
/***/ (function(module, exports) {
|
|
331
|
+
|
|
332
|
+
module.exports = require("lodash/isPlainObject");
|
|
333
|
+
|
|
334
|
+
/***/ }),
|
|
335
|
+
/* 41 */
|
|
336
|
+
/***/ (function(module, exports) {
|
|
337
|
+
|
|
338
|
+
module.exports = require("lodash/isArray");
|
|
339
|
+
|
|
340
|
+
/***/ }),
|
|
341
|
+
/* 42 */
|
|
342
|
+
/***/ (function(module, exports) {
|
|
343
|
+
|
|
344
|
+
module.exports = require("cookie");
|
|
345
|
+
|
|
346
|
+
/***/ }),
|
|
347
|
+
/* 43 */
|
|
348
|
+
/***/ (function(module, exports) {
|
|
349
|
+
|
|
350
|
+
module.exports = require("utf8-bytes");
|
|
351
|
+
|
|
352
|
+
/***/ }),
|
|
353
|
+
/* 44 */
|
|
354
|
+
/***/ (function(module, exports) {
|
|
355
|
+
|
|
356
|
+
module.exports = require("utfstring");
|
|
357
|
+
|
|
358
|
+
/***/ }),
|
|
359
|
+
/* 45 */
|
|
360
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
361
|
+
|
|
362
|
+
module.exports = __webpack_require__(50);
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
/***/ }),
|
|
366
|
+
/* 46 */
|
|
367
|
+
/***/ (function(module, exports) {
|
|
368
|
+
|
|
369
|
+
module.exports = require("lodash/cloneDeep");
|
|
370
|
+
|
|
371
|
+
/***/ }),
|
|
372
|
+
/* 47 */
|
|
373
|
+
/***/ (function(module, exports) {
|
|
374
|
+
|
|
375
|
+
module.exports = require("cross-fetch/polyfill");
|
|
376
|
+
|
|
377
|
+
/***/ }),
|
|
378
|
+
/* 48 */
|
|
379
|
+
/***/ (function(module, exports) {
|
|
380
|
+
|
|
381
|
+
module.exports = require("isomorphic-form-data");
|
|
382
|
+
|
|
383
|
+
/***/ }),
|
|
384
|
+
/* 49 */
|
|
385
|
+
/***/ (function(module, exports) {
|
|
386
|
+
|
|
387
|
+
module.exports = require("encode-3986");
|
|
388
|
+
|
|
389
|
+
/***/ }),
|
|
390
|
+
/* 50 */
|
|
391
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
392
|
+
|
|
393
|
+
"use strict";
|
|
394
|
+
__webpack_require__.r(__webpack_exports__);
|
|
395
|
+
var oas3_parameter_builders_namespaceObject = {};
|
|
396
|
+
__webpack_require__.r(oas3_parameter_builders_namespaceObject);
|
|
397
|
+
__webpack_require__.d(oas3_parameter_builders_namespaceObject, "path", function() { return parameter_builders_path; });
|
|
398
|
+
__webpack_require__.d(oas3_parameter_builders_namespaceObject, "query", function() { return parameter_builders_query; });
|
|
399
|
+
__webpack_require__.d(oas3_parameter_builders_namespaceObject, "header", function() { return parameter_builders_header; });
|
|
400
|
+
__webpack_require__.d(oas3_parameter_builders_namespaceObject, "cookie", function() { return cookie; });
|
|
401
|
+
|
|
402
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/object/define-property"
|
|
403
|
+
var define_property_ = __webpack_require__(9);
|
|
404
|
+
var define_property_default = /*#__PURE__*/__webpack_require__.n(define_property_);
|
|
405
|
+
|
|
406
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/object/define-properties"
|
|
407
|
+
var define_properties_ = __webpack_require__(10);
|
|
408
|
+
var define_properties_default = /*#__PURE__*/__webpack_require__.n(define_properties_);
|
|
409
|
+
|
|
410
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/object/get-own-property-descriptors"
|
|
411
|
+
var get_own_property_descriptors_ = __webpack_require__(5);
|
|
412
|
+
var get_own_property_descriptors_default = /*#__PURE__*/__webpack_require__.n(get_own_property_descriptors_);
|
|
413
|
+
|
|
414
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/object/get-own-property-descriptor"
|
|
415
|
+
var get_own_property_descriptor_ = __webpack_require__(6);
|
|
416
|
+
var get_own_property_descriptor_default = /*#__PURE__*/__webpack_require__.n(get_own_property_descriptor_);
|
|
417
|
+
|
|
418
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/object/get-own-property-symbols"
|
|
419
|
+
var get_own_property_symbols_ = __webpack_require__(7);
|
|
420
|
+
var get_own_property_symbols_default = /*#__PURE__*/__webpack_require__.n(get_own_property_symbols_);
|
|
421
|
+
|
|
422
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/object/keys"
|
|
423
|
+
var keys_ = __webpack_require__(0);
|
|
424
|
+
var keys_default = /*#__PURE__*/__webpack_require__.n(keys_);
|
|
425
|
+
|
|
426
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/defineProperty"
|
|
427
|
+
var defineProperty_ = __webpack_require__(8);
|
|
428
|
+
var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty_);
|
|
429
|
+
|
|
430
|
+
// EXTERNAL MODULE: external "lodash/cloneDeep"
|
|
431
|
+
var cloneDeep_ = __webpack_require__(46);
|
|
432
|
+
|
|
433
|
+
// EXTERNAL MODULE: external "lodash/assign"
|
|
434
|
+
var assign_ = __webpack_require__(15);
|
|
435
|
+
var assign_default = /*#__PURE__*/__webpack_require__.n(assign_);
|
|
436
|
+
|
|
437
|
+
// EXTERNAL MODULE: external "lodash/startsWith"
|
|
438
|
+
var startsWith_ = __webpack_require__(20);
|
|
439
|
+
var startsWith_default = /*#__PURE__*/__webpack_require__.n(startsWith_);
|
|
440
|
+
|
|
441
|
+
// EXTERNAL MODULE: external "url"
|
|
442
|
+
var external_url_ = __webpack_require__(12);
|
|
443
|
+
var external_url_default = /*#__PURE__*/__webpack_require__.n(external_url_);
|
|
444
|
+
|
|
445
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/regenerator"
|
|
446
|
+
var regenerator_ = __webpack_require__(4);
|
|
447
|
+
var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator_);
|
|
448
|
+
|
|
449
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/slicedToArray"
|
|
450
|
+
var slicedToArray_ = __webpack_require__(22);
|
|
451
|
+
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray_);
|
|
452
|
+
|
|
453
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/json/stringify"
|
|
454
|
+
var stringify_ = __webpack_require__(11);
|
|
455
|
+
var stringify_default = /*#__PURE__*/__webpack_require__.n(stringify_);
|
|
456
|
+
|
|
457
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/typeof"
|
|
458
|
+
var typeof_ = __webpack_require__(2);
|
|
459
|
+
var typeof_default = /*#__PURE__*/__webpack_require__.n(typeof_);
|
|
460
|
+
|
|
461
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/array/is-array"
|
|
462
|
+
var is_array_ = __webpack_require__(1);
|
|
463
|
+
var is_array_default = /*#__PURE__*/__webpack_require__.n(is_array_);
|
|
464
|
+
|
|
465
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/asyncToGenerator"
|
|
466
|
+
var asyncToGenerator_ = __webpack_require__(17);
|
|
467
|
+
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator_);
|
|
468
|
+
|
|
469
|
+
// EXTERNAL MODULE: external "cross-fetch/polyfill"
|
|
470
|
+
var polyfill_ = __webpack_require__(47);
|
|
471
|
+
|
|
472
|
+
// EXTERNAL MODULE: external "qs"
|
|
473
|
+
var external_qs_ = __webpack_require__(26);
|
|
474
|
+
var external_qs_default = /*#__PURE__*/__webpack_require__.n(external_qs_);
|
|
475
|
+
|
|
476
|
+
// EXTERNAL MODULE: external "js-yaml"
|
|
477
|
+
var external_js_yaml_ = __webpack_require__(23);
|
|
478
|
+
var external_js_yaml_default = /*#__PURE__*/__webpack_require__.n(external_js_yaml_);
|
|
479
|
+
|
|
480
|
+
// EXTERNAL MODULE: external "lodash/isString"
|
|
481
|
+
var isString_ = __webpack_require__(31);
|
|
482
|
+
var isString_default = /*#__PURE__*/__webpack_require__.n(isString_);
|
|
483
|
+
|
|
484
|
+
// CONCATENATED MODULE: ./src/http.js
|
|
485
|
+
/* global fetch */
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
// For testing
|
|
491
|
+
var http_self = {
|
|
492
|
+
serializeRes: serializeRes,
|
|
493
|
+
mergeInQueryOrForm: mergeInQueryOrForm
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
// Handles fetch-like syntax and the case where there is only one object passed-in
|
|
497
|
+
// (which will have the URL as a property). Also serilizes the response.
|
|
498
|
+
};function http_http(_x) {return _http.apply(this, arguments);}
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
// exported for testing
|
|
569
|
+
function _http() {_http = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee(url) {var request,contentType,res,error,_error,_args = arguments;return regenerator_default.a.wrap(function _callee$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:request = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};if (typeof_default()(url) === 'object') {request = url;url = request.url;}request.headers = request.headers || {}; // Serializes query, for convenience
|
|
570
|
+
// Should be the last thing we do, as its hard to mutate the URL with
|
|
571
|
+
// the search string, but much easier to manipulate the req.query object
|
|
572
|
+
http_self.mergeInQueryOrForm(request); // Newlines in header values cause weird error messages from `window.fetch`,
|
|
573
|
+
// so let's massage them out.
|
|
574
|
+
// Context: https://stackoverflow.com/a/50709178
|
|
575
|
+
if (request.headers) {keys_default()(request.headers).forEach(function (headerName) {var value = request.headers[headerName];if (typeof value === 'string') {request.headers[headerName] = value.replace(/\n+/g, ' ');}});} // Wait for the request interceptor, if it was provided
|
|
576
|
+
// WARNING: don't put anything between this and the request firing unless
|
|
577
|
+
// you have a good reason!
|
|
578
|
+
if (!request.requestInterceptor) {_context.next = 12;break;}_context.next = 8;return request.requestInterceptor(request);case 8:_context.t0 = _context.sent;if (_context.t0) {_context.next = 11;break;}_context.t0 = request;case 11:request = _context.t0;case 12: // for content-type=multipart\/form-data remove content-type from request before fetch
|
|
579
|
+
// so that correct one with `boundary` is set
|
|
580
|
+
contentType = request.headers['content-type'] || request.headers['Content-Type'];if (/multipart\/form-data/i.test(contentType)) {delete request.headers['content-type'];delete request.headers['Content-Type'];} // eslint-disable-next-line no-undef
|
|
581
|
+
_context.prev = 14;_context.next = 17;return (request.userFetch || fetch)(request.url, request);case 17:res = _context.sent;_context.next = 20;return http_self.serializeRes(res, url, request);case 20:res = _context.sent;if (!request.responseInterceptor) {_context.next = 28;break;}_context.next = 24;return request.responseInterceptor(res);case 24:_context.t1 = _context.sent;if (_context.t1) {_context.next = 27;break;}_context.t1 = res;case 27:res = _context.t1;case 28:_context.next = 38;break;case 30:_context.prev = 30;_context.t2 = _context["catch"](14);if (res) {_context.next = 34;break;}throw _context.t2;case 34:error = new Error(res.statusText);error.statusCode = error.status = res.status;error.responseError = _context.t2;throw error;case 38:if (res.ok) {_context.next = 43;break;}_error = new Error(res.statusText);_error.statusCode = _error.status = res.status;_error.response = res;throw _error;case 43:return _context.abrupt("return", res);case 44:case "end":return _context.stop();}}}, _callee, null, [[14, 30]]);}));return _http.apply(this, arguments);}var shouldDownloadAsText = function shouldDownloadAsText() {var contentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';return /(json|xml|yaml|text)\b/.test(contentType);};function parseBody(body, contentType) {if (contentType && (contentType.indexOf('application/json') === 0 || contentType.indexOf('+json') > 0)) {return JSON.parse(body);}return external_js_yaml_default.a.safeLoad(body);} // Serialize the response, returns a promise with headers and the body part of the hash
|
|
582
|
+
function serializeRes(oriRes, url) {var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},_ref$loadSpec = _ref.loadSpec,loadSpec = _ref$loadSpec === void 0 ? false : _ref$loadSpec;var res = { ok: oriRes.ok, url: oriRes.url || url,
|
|
583
|
+
status: oriRes.status,
|
|
584
|
+
statusText: oriRes.statusText,
|
|
585
|
+
headers: serializeHeaders(oriRes.headers) };
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
var contentType = res.headers['content-type'];
|
|
589
|
+
var useText = loadSpec || shouldDownloadAsText(contentType);
|
|
590
|
+
|
|
591
|
+
// Note: Response.blob not implemented in node-fetch 1. Use buffer instead.
|
|
592
|
+
var getBody = useText ? oriRes.text : oriRes.blob || oriRes.buffer;
|
|
593
|
+
|
|
594
|
+
return getBody.call(oriRes).then(function (body) {
|
|
595
|
+
res.text = body;
|
|
596
|
+
res.data = body;
|
|
597
|
+
|
|
598
|
+
if (useText) {
|
|
599
|
+
try {
|
|
600
|
+
var obj = parseBody(body, contentType);
|
|
601
|
+
res.body = obj;
|
|
602
|
+
res.obj = obj;
|
|
603
|
+
}
|
|
604
|
+
catch (e) {
|
|
605
|
+
res.parseError = e;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
return res;
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// Serialize headers into a hash, where mutliple-headers result in an array.
|
|
613
|
+
//
|
|
614
|
+
// eg: Cookie: one
|
|
615
|
+
// Cookie: two
|
|
616
|
+
// = { Cookie: [ "one", "two" ]
|
|
617
|
+
function serializeHeaders() {var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
618
|
+
var obj = {};
|
|
619
|
+
|
|
620
|
+
// Iterate over headers, making multiple-headers into an array
|
|
621
|
+
if (typeof headers.forEach === 'function') {
|
|
622
|
+
headers.forEach(function (headerValue, header) {
|
|
623
|
+
if (obj[header] !== undefined) {
|
|
624
|
+
obj[header] = is_array_default()(obj[header]) ? obj[header] : [obj[header]];
|
|
625
|
+
obj[header].push(headerValue);
|
|
626
|
+
} else
|
|
627
|
+
{
|
|
628
|
+
obj[header] = headerValue;
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
return obj;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
return obj;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
function http_isFile(obj, navigatorObj) {
|
|
638
|
+
if (!navigatorObj && typeof navigator !== 'undefined') {
|
|
639
|
+
// eslint-disable-next-line no-undef
|
|
640
|
+
navigatorObj = navigator;
|
|
641
|
+
}
|
|
642
|
+
if (navigatorObj && navigatorObj.product === 'ReactNative') {
|
|
643
|
+
if (obj && typeof_default()(obj) === 'object' && typeof obj.uri === 'string') {
|
|
644
|
+
return true;
|
|
645
|
+
}
|
|
646
|
+
return false;
|
|
647
|
+
}
|
|
648
|
+
if (typeof File !== 'undefined') {
|
|
649
|
+
// eslint-disable-next-line no-undef
|
|
650
|
+
return obj instanceof File;
|
|
651
|
+
}
|
|
652
|
+
return obj !== null && typeof_default()(obj) === 'object' && typeof obj.pipe === 'function';
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
function formatValue(input, skipEncoding) {var
|
|
656
|
+
collectionFormat = input.collectionFormat,allowEmptyValue = input.allowEmptyValue;
|
|
657
|
+
|
|
658
|
+
// `input` can be string in OAS3 contexts
|
|
659
|
+
var value = typeof_default()(input) === 'object' ? input.value : input;
|
|
660
|
+
|
|
661
|
+
var SEPARATORS = {
|
|
662
|
+
csv: ',',
|
|
663
|
+
ssv: '%20',
|
|
664
|
+
tsv: '%09',
|
|
665
|
+
pipes: '|' };
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
if (typeof value === 'undefined' && allowEmptyValue) {
|
|
669
|
+
return '';
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
if (http_isFile(value) || typeof value === 'boolean') {
|
|
673
|
+
return value;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
var encodeFn = encodeURIComponent;
|
|
677
|
+
if (skipEncoding) {
|
|
678
|
+
if (isString_default()(value)) encodeFn = function encodeFn(str) {return str;};else
|
|
679
|
+
encodeFn = function encodeFn(obj) {return stringify_default()(obj);};
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
if (typeof_default()(value) === 'object' && !is_array_default()(value)) {
|
|
683
|
+
return '';
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
if (!is_array_default()(value)) {
|
|
687
|
+
return encodeFn(value);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
if (is_array_default()(value) && !collectionFormat) {
|
|
691
|
+
return value.map(encodeFn).join(',');
|
|
692
|
+
}
|
|
693
|
+
if (collectionFormat === 'multi') {
|
|
694
|
+
return value.map(encodeFn);
|
|
695
|
+
}
|
|
696
|
+
return value.map(encodeFn).join(SEPARATORS[collectionFormat]);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
// Encodes an object using appropriate serializer.
|
|
700
|
+
function encodeFormOrQuery(data) {
|
|
701
|
+
/**
|
|
702
|
+
* Encode parameter names and values
|
|
703
|
+
* @param {Object} result - parameter names and values
|
|
704
|
+
* @param {string} parameterName - Parameter name
|
|
705
|
+
* @return {object} encoded parameter names and values
|
|
706
|
+
*/
|
|
707
|
+
var encodedQuery = keys_default()(data).reduce(function (result, parameterName) {
|
|
708
|
+
var isObject = function isObject(a) {return a && typeof_default()(a) === 'object';};
|
|
709
|
+
var paramValue = data[parameterName];
|
|
710
|
+
var skipEncoding = !!paramValue.skipEncoding;
|
|
711
|
+
var encodedParameterName = skipEncoding ? parameterName : encodeURIComponent(parameterName);
|
|
712
|
+
var notArray = isObject(paramValue) && !is_array_default()(paramValue);
|
|
713
|
+
result[encodedParameterName] = formatValue(
|
|
714
|
+
notArray ? paramValue : { value: paramValue }, skipEncoding);
|
|
715
|
+
|
|
716
|
+
return result;
|
|
717
|
+
}, {});
|
|
718
|
+
return external_qs_default.a.stringify(encodedQuery, { encode: false, indices: false }) || '';
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
// If the request has a `query` object, merge it into the request.url, and delete the object
|
|
722
|
+
function mergeInQueryOrForm() {var req = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};var _req$url =
|
|
723
|
+
req.url,url = _req$url === void 0 ? '' : _req$url,query = req.query,form = req.form;
|
|
724
|
+
|
|
725
|
+
var joinSearch = function joinSearch() {for (var _len = arguments.length, strs = new Array(_len), _key = 0; _key < _len; _key++) {strs[_key] = arguments[_key];}
|
|
726
|
+
var search = strs.filter(function (a) {return a;}).join('&'); // Only truthy value
|
|
727
|
+
return search ? "?".concat(search) : ''; // Only add '?' if there is a str
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
if (form) {
|
|
731
|
+
var hasFile = keys_default()(form).some(function (key) {
|
|
732
|
+
return http_isFile(form[key].value);
|
|
733
|
+
});
|
|
734
|
+
|
|
735
|
+
var contentType = req.headers['content-type'] || req.headers['Content-Type'];
|
|
736
|
+
|
|
737
|
+
if (hasFile || /multipart\/form-data/i.test(contentType)) {
|
|
738
|
+
var FormData = __webpack_require__(48); // eslint-disable-line global-require
|
|
739
|
+
req.body = new FormData();
|
|
740
|
+
keys_default()(form).forEach(function (key) {
|
|
741
|
+
req.body.append(key, formatValue(form[key], true));
|
|
742
|
+
});
|
|
743
|
+
} else
|
|
744
|
+
{
|
|
745
|
+
req.body = encodeFormOrQuery(form);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
delete req.form;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
if (query) {var _url$split =
|
|
752
|
+
url.split('?'),_url$split2 = slicedToArray_default()(_url$split, 2),baseUrl = _url$split2[0],oriSearch = _url$split2[1];
|
|
753
|
+
var newStr = '';
|
|
754
|
+
|
|
755
|
+
if (oriSearch) {
|
|
756
|
+
var oriQuery = external_qs_default.a.parse(oriSearch);
|
|
757
|
+
var keysToRemove = keys_default()(query);
|
|
758
|
+
keysToRemove.forEach(function (key) {return delete oriQuery[key];});
|
|
759
|
+
newStr = external_qs_default.a.stringify(oriQuery, { encode: true });
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
var finalStr = joinSearch(newStr, encodeFormOrQuery(query));
|
|
763
|
+
req.url = baseUrl + finalStr;
|
|
764
|
+
delete req.query;
|
|
765
|
+
}
|
|
766
|
+
return req;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
// Wrap a http function ( there are otherways to do this, conisder this deprecated )
|
|
770
|
+
function makeHttp(httpFn, preFetch, postFetch) {
|
|
771
|
+
postFetch = postFetch || function (a) {return a;};
|
|
772
|
+
preFetch = preFetch || function (a) {return a;};
|
|
773
|
+
|
|
774
|
+
return function (req) {
|
|
775
|
+
if (typeof req === 'string') {
|
|
776
|
+
req = { url: req };
|
|
777
|
+
}
|
|
778
|
+
http_self.mergeInQueryOrForm(req);
|
|
779
|
+
req = preFetch(req);
|
|
780
|
+
return postFetch(httpFn(req));
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/promise"
|
|
784
|
+
var promise_ = __webpack_require__(14);
|
|
785
|
+
var promise_default = /*#__PURE__*/__webpack_require__.n(promise_);
|
|
786
|
+
|
|
787
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/get-iterator"
|
|
788
|
+
var get_iterator_ = __webpack_require__(21);
|
|
789
|
+
var get_iterator_default = /*#__PURE__*/__webpack_require__.n(get_iterator_);
|
|
790
|
+
|
|
791
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/object/create"
|
|
792
|
+
var create_ = __webpack_require__(27);
|
|
793
|
+
var create_default = /*#__PURE__*/__webpack_require__.n(create_);
|
|
794
|
+
|
|
795
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/object/assign"
|
|
796
|
+
var object_assign_ = __webpack_require__(3);
|
|
797
|
+
var object_assign_default = /*#__PURE__*/__webpack_require__.n(object_assign_);
|
|
798
|
+
|
|
799
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/classCallCheck"
|
|
800
|
+
var classCallCheck_ = __webpack_require__(24);
|
|
801
|
+
var classCallCheck_default = /*#__PURE__*/__webpack_require__.n(classCallCheck_);
|
|
802
|
+
|
|
803
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/createClass"
|
|
804
|
+
var createClass_ = __webpack_require__(25);
|
|
805
|
+
var createClass_default = /*#__PURE__*/__webpack_require__.n(createClass_);
|
|
806
|
+
|
|
807
|
+
// EXTERNAL MODULE: external "lodash/find"
|
|
808
|
+
var find_ = __webpack_require__(32);
|
|
809
|
+
var find_default = /*#__PURE__*/__webpack_require__.n(find_);
|
|
810
|
+
|
|
811
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/toConsumableArray"
|
|
812
|
+
var toConsumableArray_ = __webpack_require__(13);
|
|
813
|
+
var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray_);
|
|
814
|
+
|
|
815
|
+
// EXTERNAL MODULE: external "fast-json-patch"
|
|
816
|
+
var external_fast_json_patch_ = __webpack_require__(18);
|
|
817
|
+
var external_fast_json_patch_default = /*#__PURE__*/__webpack_require__.n(external_fast_json_patch_);
|
|
818
|
+
|
|
819
|
+
// EXTERNAL MODULE: external "deep-extend"
|
|
820
|
+
var external_deep_extend_ = __webpack_require__(33);
|
|
821
|
+
var external_deep_extend_default = /*#__PURE__*/__webpack_require__.n(external_deep_extend_);
|
|
822
|
+
|
|
823
|
+
// EXTERNAL MODULE: external "@kyleshockey/object-assign-deep"
|
|
824
|
+
var object_assign_deep_ = __webpack_require__(34);
|
|
825
|
+
var object_assign_deep_default = /*#__PURE__*/__webpack_require__.n(object_assign_deep_);
|
|
826
|
+
|
|
827
|
+
// CONCATENATED MODULE: ./src/specmap/lib/index.js
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
/* harmony default export */ var lib = ({
|
|
834
|
+
add: add,
|
|
835
|
+
replace: replace,
|
|
836
|
+
remove: remove,
|
|
837
|
+
merge: merge,
|
|
838
|
+
mergeDeep: mergeDeep,
|
|
839
|
+
context: context,
|
|
840
|
+
getIn: getIn,
|
|
841
|
+
applyPatch: applyPatch,
|
|
842
|
+
parentPathMatch: parentPathMatch,
|
|
843
|
+
flatten: flatten,
|
|
844
|
+
fullyNormalizeArray: fullyNormalizeArray,
|
|
845
|
+
normalizeArray: lib_normalizeArray,
|
|
846
|
+
isPromise: isPromise,
|
|
847
|
+
forEachNew: forEachNew,
|
|
848
|
+
forEachNewPrimitive: forEachNewPrimitive,
|
|
849
|
+
isJsonPatch: isJsonPatch,
|
|
850
|
+
isContextPatch: isContextPatch,
|
|
851
|
+
isPatch: isPatch,
|
|
852
|
+
isMutation: isMutation,
|
|
853
|
+
isAdditiveMutation: isAdditiveMutation,
|
|
854
|
+
isGenerator: isGenerator,
|
|
855
|
+
isFunction: isFunction,
|
|
856
|
+
isObject: lib_isObject,
|
|
857
|
+
isError: isError });
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
function applyPatch(obj, patch, opts) {
|
|
861
|
+
opts = opts || {};
|
|
862
|
+
|
|
863
|
+
patch = object_assign_default()({}, patch, {
|
|
864
|
+
path: patch.path && normalizeJSONPath(patch.path) });
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
if (patch.op === 'merge') {
|
|
868
|
+
var newValue = getInByJsonPath(obj, patch.path);
|
|
869
|
+
object_assign_default()(newValue, patch.value);
|
|
870
|
+
external_fast_json_patch_default.a.applyPatch(obj, [replace(patch.path, newValue)]);
|
|
871
|
+
} else
|
|
872
|
+
if (patch.op === 'mergeDeep') {
|
|
873
|
+
var currentValue = getInByJsonPath(obj, patch.path);
|
|
874
|
+
|
|
875
|
+
// Iterate the properties of the patch
|
|
876
|
+
for (var prop in patch.value) {
|
|
877
|
+
var propVal = patch.value[prop];
|
|
878
|
+
var isArray = is_array_default()(propVal);
|
|
879
|
+
if (isArray) {
|
|
880
|
+
// deepExtend doesn't merge arrays, so we will do it manually
|
|
881
|
+
var existing = currentValue[prop] || [];
|
|
882
|
+
currentValue[prop] = existing.concat(propVal);
|
|
883
|
+
} else
|
|
884
|
+
if (lib_isObject(propVal) && !isArray) {
|
|
885
|
+
// If it's an object, iterate it's keys and merge
|
|
886
|
+
// if there are conflicting keys, merge deep, otherwise shallow merge
|
|
887
|
+
var currentObj = object_assign_default()({}, currentValue[prop]);
|
|
888
|
+
for (var key in propVal) {
|
|
889
|
+
if (Object.prototype.hasOwnProperty.call(currentObj, key)) {
|
|
890
|
+
// if there is a single conflicting key, just deepExtend the entire value
|
|
891
|
+
// and break from the loop (since all future keys are also merged)
|
|
892
|
+
// We do this because we can't deepExtend two primitives
|
|
893
|
+
// (currentObj[key] & propVal[key] may be primitives).
|
|
894
|
+
//
|
|
895
|
+
// we also deeply assign here, since we aren't in control of
|
|
896
|
+
// how deepExtend affects existing nested objects
|
|
897
|
+
currentObj = external_deep_extend_default()(object_assign_deep_default()({}, currentObj), propVal);
|
|
898
|
+
break;
|
|
899
|
+
} else
|
|
900
|
+
{
|
|
901
|
+
object_assign_default()(currentObj, defineProperty_default()({}, key, propVal[key]));
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
currentValue[prop] = currentObj;
|
|
905
|
+
} else
|
|
906
|
+
{
|
|
907
|
+
// It's a primitive, just replace existing
|
|
908
|
+
currentValue[prop] = propVal;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
} else
|
|
912
|
+
if (patch.op === 'add' && patch.path === '' && lib_isObject(patch.value)) {
|
|
913
|
+
// { op: 'add', path: '', value: { a: 1, b: 2 }}
|
|
914
|
+
// has no effect: json patch refuses to do anything.
|
|
915
|
+
// so let's break that patch down into a set of patches,
|
|
916
|
+
// one for each key in the intended root value.
|
|
917
|
+
|
|
918
|
+
var patches = keys_default()(patch.value).
|
|
919
|
+
reduce(function (arr, key) {
|
|
920
|
+
arr.push({
|
|
921
|
+
op: 'add',
|
|
922
|
+
path: "/".concat(normalizeJSONPath(key)),
|
|
923
|
+
value: patch.value[key] });
|
|
924
|
+
|
|
925
|
+
return arr;
|
|
926
|
+
}, []);
|
|
927
|
+
|
|
928
|
+
external_fast_json_patch_default.a.applyPatch(obj, patches);
|
|
929
|
+
} else
|
|
930
|
+
if (patch.op === 'replace' && patch.path === '') {
|
|
931
|
+
var value = patch.value;
|
|
932
|
+
|
|
933
|
+
if (opts.allowMetaPatches && patch.meta && isAdditiveMutation(patch) && (
|
|
934
|
+
is_array_default()(patch.value) || lib_isObject(patch.value))) {
|
|
935
|
+
value = object_assign_default()({}, value, patch.meta);
|
|
936
|
+
}
|
|
937
|
+
obj = value;
|
|
938
|
+
} else
|
|
939
|
+
{
|
|
940
|
+
external_fast_json_patch_default.a.applyPatch(obj, [patch]);
|
|
941
|
+
|
|
942
|
+
// Attach metadata to the resulting value.
|
|
943
|
+
if (opts.allowMetaPatches && patch.meta && isAdditiveMutation(patch) && (
|
|
944
|
+
is_array_default()(patch.value) || lib_isObject(patch.value))) {
|
|
945
|
+
var _currentValue = getInByJsonPath(obj, patch.path);
|
|
946
|
+
var _newValue = object_assign_default()({}, _currentValue, patch.meta);
|
|
947
|
+
external_fast_json_patch_default.a.applyPatch(obj, [replace(patch.path, _newValue)]);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
return obj;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
function normalizeJSONPath(path) {
|
|
955
|
+
if (is_array_default()(path)) {
|
|
956
|
+
if (path.length < 1) {
|
|
957
|
+
return '';
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
return '/' + path.map(function (item) {// eslint-disable-line prefer-template
|
|
961
|
+
return (item + '').replace(/~/g, '~0').replace(/\//g, '~1'); // eslint-disable-line prefer-template
|
|
962
|
+
}).join('/');
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
return path;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
// =========================
|
|
970
|
+
// JSON-Patch Wrappers
|
|
971
|
+
// =========================
|
|
972
|
+
|
|
973
|
+
function add(path, value) {
|
|
974
|
+
return { op: 'add', path: path, value: value };
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
function lib_get(path) {
|
|
978
|
+
return { op: '_get', path: path };
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
function replace(path, value, meta) {
|
|
982
|
+
return { op: 'replace', path: path, value: value, meta: meta };
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
function remove(path, value) {
|
|
986
|
+
return { op: 'remove', path: path };
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
// Custom wrappers
|
|
990
|
+
function merge(path, value) {
|
|
991
|
+
return { type: 'mutation', op: 'merge', path: path, value: value };
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
// Custom wrappers
|
|
995
|
+
function mergeDeep(path, value) {
|
|
996
|
+
return { type: 'mutation', op: 'mergeDeep', path: path, value: value };
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
function context(path, value) {
|
|
1000
|
+
return { type: 'context', path: path, value: value };
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
|
|
1004
|
+
// =========================
|
|
1005
|
+
// Iterators
|
|
1006
|
+
// =========================
|
|
1007
|
+
|
|
1008
|
+
function forEachNew(mutations, fn) {
|
|
1009
|
+
try {
|
|
1010
|
+
return forEachNewPatch(mutations, forEach, fn);
|
|
1011
|
+
}
|
|
1012
|
+
catch (e) {
|
|
1013
|
+
return e;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
function forEachNewPrimitive(mutations, fn) {
|
|
1018
|
+
try {
|
|
1019
|
+
return forEachNewPatch(mutations, forEachPrimitive, fn);
|
|
1020
|
+
}
|
|
1021
|
+
catch (e) {
|
|
1022
|
+
return e;
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
function forEachNewPatch(mutations, fn, callback) {
|
|
1027
|
+
var res = mutations.filter(isAdditiveMutation).map(function (mutation) {
|
|
1028
|
+
return fn(mutation.value, callback, mutation.path);
|
|
1029
|
+
}) || [];
|
|
1030
|
+
var flat = flatten(res);
|
|
1031
|
+
var clean = cleanArray(flat);
|
|
1032
|
+
return clean;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
function forEachPrimitive(obj, fn, basePath) {
|
|
1036
|
+
basePath = basePath || [];
|
|
1037
|
+
|
|
1038
|
+
if (is_array_default()(obj)) {
|
|
1039
|
+
return obj.map(function (val, key) {
|
|
1040
|
+
return forEachPrimitive(val, fn, basePath.concat(key));
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
if (lib_isObject(obj)) {
|
|
1045
|
+
return keys_default()(obj).map(function (key) {
|
|
1046
|
+
return forEachPrimitive(obj[key], fn, basePath.concat(key));
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
return fn(obj, basePath[basePath.length - 1], basePath);
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
function forEach(obj, fn, basePath) {
|
|
1054
|
+
basePath = basePath || [];
|
|
1055
|
+
|
|
1056
|
+
var results = [];
|
|
1057
|
+
if (basePath.length > 0) {
|
|
1058
|
+
var newResults = fn(obj, basePath[basePath.length - 1], basePath);
|
|
1059
|
+
if (newResults) {
|
|
1060
|
+
results = results.concat(newResults);
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
if (is_array_default()(obj)) {
|
|
1065
|
+
var arrayResults = obj.map(function (val, key) {
|
|
1066
|
+
return forEach(val, fn, basePath.concat(key));
|
|
1067
|
+
});
|
|
1068
|
+
if (arrayResults) {
|
|
1069
|
+
results = results.concat(arrayResults);
|
|
1070
|
+
}
|
|
1071
|
+
} else
|
|
1072
|
+
if (lib_isObject(obj)) {
|
|
1073
|
+
var moreResults = keys_default()(obj).map(function (key) {
|
|
1074
|
+
return forEach(obj[key], fn, basePath.concat(key));
|
|
1075
|
+
});
|
|
1076
|
+
if (moreResults) {
|
|
1077
|
+
results = results.concat(moreResults);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
results = flatten(results);
|
|
1082
|
+
return results;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
// =========================
|
|
1087
|
+
// Paths
|
|
1088
|
+
// =========================
|
|
1089
|
+
|
|
1090
|
+
function parentPathMatch(path, arr) {
|
|
1091
|
+
if (!is_array_default()(arr)) {
|
|
1092
|
+
return false;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
for (var i = 0, len = arr.length; i < len; i++) {
|
|
1096
|
+
if (arr[i] !== path[i]) {
|
|
1097
|
+
return false;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
return true;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
function getIn(obj, path) {
|
|
1105
|
+
return path.reduce(function (val, token) {
|
|
1106
|
+
if (typeof token !== 'undefined' && val) {
|
|
1107
|
+
return val[token];
|
|
1108
|
+
}
|
|
1109
|
+
return val;
|
|
1110
|
+
}, obj);
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
// =========================
|
|
1114
|
+
// Array
|
|
1115
|
+
// =========================
|
|
1116
|
+
|
|
1117
|
+
function fullyNormalizeArray(arr) {
|
|
1118
|
+
return cleanArray(flatten(lib_normalizeArray(arr)));
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
function lib_normalizeArray(arr) {
|
|
1122
|
+
return is_array_default()(arr) ? arr : [arr];
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
function flatten(arr) {var _ref;
|
|
1126
|
+
return (_ref = []).concat.apply(_ref, toConsumableArray_default()(arr.map(function (val) {
|
|
1127
|
+
return is_array_default()(val) ? flatten(val) : val;
|
|
1128
|
+
})));
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
function cleanArray(arr) {
|
|
1132
|
+
return arr.filter(function (elm) {return typeof elm !== 'undefined';});
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
// =========================
|
|
1137
|
+
// Is-Thing.
|
|
1138
|
+
// =========================
|
|
1139
|
+
|
|
1140
|
+
function lib_isObject(val) {
|
|
1141
|
+
return val && typeof_default()(val) === 'object';
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
function isPromise(val) {
|
|
1145
|
+
return lib_isObject(val) && isFunction(val.then);
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
function isFunction(val) {
|
|
1149
|
+
return val && typeof val === 'function';
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
function isError(patch) {
|
|
1153
|
+
return patch instanceof Error;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
function isJsonPatch(patch) {
|
|
1157
|
+
if (isPatch(patch)) {
|
|
1158
|
+
var op = patch.op;
|
|
1159
|
+
return op === 'add' || op === 'remove' || op === 'replace';
|
|
1160
|
+
}
|
|
1161
|
+
return false;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
function isGenerator(thing) {
|
|
1165
|
+
return regenerator_default.a.isGeneratorFunction(thing);
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
function isMutation(patch) {
|
|
1169
|
+
return isJsonPatch(patch) || isPatch(patch) && patch.type === 'mutation';
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
function isAdditiveMutation(patch) {
|
|
1173
|
+
return isMutation(patch) && (patch.op === 'add' || patch.op === 'replace' || patch.op === 'merge' || patch.op === 'mergeDeep');
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
function isContextPatch(patch) {
|
|
1177
|
+
return isPatch(patch) && patch.type === 'context';
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
function isPatch(patch) {
|
|
1181
|
+
return patch && typeof_default()(patch) === 'object';
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
function getInByJsonPath(obj, jsonPath) {
|
|
1185
|
+
try {
|
|
1186
|
+
return external_fast_json_patch_default.a.getValueByPointer(obj, jsonPath);
|
|
1187
|
+
}
|
|
1188
|
+
catch (e) {
|
|
1189
|
+
console.error(e); // eslint-disable-line no-console
|
|
1190
|
+
return {};
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/weak-map"
|
|
1194
|
+
var weak_map_ = __webpack_require__(35);
|
|
1195
|
+
var weak_map_default = /*#__PURE__*/__webpack_require__.n(weak_map_);
|
|
1196
|
+
|
|
1197
|
+
// EXTERNAL MODULE: external "cross-fetch"
|
|
1198
|
+
var external_cross_fetch_ = __webpack_require__(36);
|
|
1199
|
+
|
|
1200
|
+
// EXTERNAL MODULE: external "querystring-browser"
|
|
1201
|
+
var external_querystring_browser_ = __webpack_require__(28);
|
|
1202
|
+
var external_querystring_browser_default = /*#__PURE__*/__webpack_require__.n(external_querystring_browser_);
|
|
1203
|
+
|
|
1204
|
+
// CONCATENATED MODULE: ./src/specmap/lib/create-error.js
|
|
1205
|
+
function createErrorType(name, init) {
|
|
1206
|
+
function E() {
|
|
1207
|
+
if (!Error.captureStackTrace) {
|
|
1208
|
+
this.stack = new Error().stack;
|
|
1209
|
+
} else
|
|
1210
|
+
{
|
|
1211
|
+
Error.captureStackTrace(this, this.constructor);
|
|
1212
|
+
}for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {args[_key] = arguments[_key];}
|
|
1213
|
+
this.message = args[0];
|
|
1214
|
+
init && init.apply(this, args);
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
E.prototype = new Error();
|
|
1218
|
+
E.prototype.name = name;
|
|
1219
|
+
E.prototype.constructor = E;
|
|
1220
|
+
|
|
1221
|
+
return E;
|
|
1222
|
+
}
|
|
1223
|
+
// EXTERNAL MODULE: external "traverse"
|
|
1224
|
+
var external_traverse_ = __webpack_require__(37);
|
|
1225
|
+
var external_traverse_default = /*#__PURE__*/__webpack_require__.n(external_traverse_);
|
|
1226
|
+
|
|
1227
|
+
// CONCATENATED MODULE: ./src/specmap/helpers.js
|
|
1228
|
+
|
|
1229
|
+
|
|
1230
|
+
|
|
1231
|
+
// This will match if the direct parent's key exactly matches an item.
|
|
1232
|
+
var freelyNamedKeyParents = [
|
|
1233
|
+
'properties'];
|
|
1234
|
+
|
|
1235
|
+
|
|
1236
|
+
// This will match if the grandparent's key exactly matches an item.
|
|
1237
|
+
// NOTE that this is for finding non-free paths!
|
|
1238
|
+
var nonFreelyNamedKeyGrandparents = [
|
|
1239
|
+
'properties'];
|
|
1240
|
+
|
|
1241
|
+
|
|
1242
|
+
// This will match if the joined parent path exactly matches an item.
|
|
1243
|
+
//
|
|
1244
|
+
// This is mostly useful for filtering out root-level reusable item names,
|
|
1245
|
+
// for example `["definitions", "$ref"]`
|
|
1246
|
+
var freelyNamedPaths = [
|
|
1247
|
+
// Swagger 2.0
|
|
1248
|
+
'definitions',
|
|
1249
|
+
'parameters',
|
|
1250
|
+
'responses',
|
|
1251
|
+
'securityDefinitions',
|
|
1252
|
+
|
|
1253
|
+
// OpenAPI 3.0
|
|
1254
|
+
'components/schemas',
|
|
1255
|
+
'components/responses',
|
|
1256
|
+
'components/parameters',
|
|
1257
|
+
'components/securitySchemes'];
|
|
1258
|
+
|
|
1259
|
+
|
|
1260
|
+
// This will match if any of these items are substrings of the joined
|
|
1261
|
+
// parent path.
|
|
1262
|
+
//
|
|
1263
|
+
// Warning! These are powerful. Beware of edge cases.
|
|
1264
|
+
var freelyNamedAncestors = [
|
|
1265
|
+
'schema/example',
|
|
1266
|
+
'items/example'];
|
|
1267
|
+
|
|
1268
|
+
|
|
1269
|
+
function isFreelyNamed(parentPath) {
|
|
1270
|
+
var parentKey = parentPath[parentPath.length - 1];
|
|
1271
|
+
var grandparentKey = parentPath[parentPath.length - 2];
|
|
1272
|
+
var parentStr = parentPath.join('/');
|
|
1273
|
+
|
|
1274
|
+
return (
|
|
1275
|
+
// eslint-disable-next-line max-len
|
|
1276
|
+
freelyNamedKeyParents.indexOf(parentKey) > -1 && nonFreelyNamedKeyGrandparents.indexOf(grandparentKey) === -1 ||
|
|
1277
|
+
freelyNamedPaths.indexOf(parentStr) > -1 ||
|
|
1278
|
+
freelyNamedAncestors.some(function (el) {return parentStr.indexOf(el) > -1;}));
|
|
1279
|
+
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
function generateAbsoluteRefPatches(obj, basePath)
|
|
1283
|
+
|
|
1284
|
+
|
|
1285
|
+
|
|
1286
|
+
{var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},specmap = _ref.specmap,_ref$getBaseUrlForNod = _ref.getBaseUrlForNodePath,getBaseUrlForNodePath = _ref$getBaseUrlForNod === void 0 ? function (path) {return specmap.getContext([].concat(toConsumableArray_default()(basePath), toConsumableArray_default()(path))).baseDoc;} : _ref$getBaseUrlForNod,_ref$targetKeys = _ref.targetKeys,targetKeys = _ref$targetKeys === void 0 ? ['$ref', '$$ref'] : _ref$targetKeys;
|
|
1287
|
+
var patches = [];
|
|
1288
|
+
|
|
1289
|
+
external_traverse_default()(obj).forEach(function () {
|
|
1290
|
+
if (targetKeys.indexOf(this.key) > -1) {
|
|
1291
|
+
var nodePath = this.path; // this node's path, relative to `obj`
|
|
1292
|
+
var fullPath = basePath.concat(this.path);
|
|
1293
|
+
|
|
1294
|
+
var absolutifiedRefValue = absolutifyPointer(this.node, getBaseUrlForNodePath(nodePath));
|
|
1295
|
+
|
|
1296
|
+
patches.push(specmap.replace(fullPath, absolutifiedRefValue));
|
|
1297
|
+
}
|
|
1298
|
+
});
|
|
1299
|
+
|
|
1300
|
+
return patches;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
function absolutifyPointer(pointer, baseUrl) {var _pointer$split =
|
|
1304
|
+
pointer.split('#'),_pointer$split2 = slicedToArray_default()(_pointer$split, 2),urlPart = _pointer$split2[0],fragmentPart = _pointer$split2[1];
|
|
1305
|
+
var newRefUrlPart = external_url_default.a.resolve(urlPart || '', baseUrl || '');
|
|
1306
|
+
|
|
1307
|
+
return fragmentPart ? "".concat(newRefUrlPart, "#").concat(fragmentPart) : newRefUrlPart;
|
|
1308
|
+
}
|
|
1309
|
+
// CONCATENATED MODULE: ./src/specmap/lib/refs.js
|
|
1310
|
+
|
|
1311
|
+
|
|
1312
|
+
|
|
1313
|
+
|
|
1314
|
+
|
|
1315
|
+
|
|
1316
|
+
|
|
1317
|
+
|
|
1318
|
+
var ABSOLUTE_URL_REGEXP = new RegExp('^([a-z]+://|//)', 'i');
|
|
1319
|
+
|
|
1320
|
+
var JSONRefError = createErrorType('JSONRefError', function (message, extra, oriError) {
|
|
1321
|
+
this.originalError = oriError;
|
|
1322
|
+
object_assign_default()(this, extra || {});
|
|
1323
|
+
});
|
|
1324
|
+
|
|
1325
|
+
var docCache = {};
|
|
1326
|
+
var specmapRefs = new weak_map_default.a();
|
|
1327
|
+
|
|
1328
|
+
var skipResolutionTestFns = [
|
|
1329
|
+
function (path) {return (
|
|
1330
|
+
// OpenAPI 3.0 Response Media Type Example
|
|
1331
|
+
// ["paths", *, *, "responses", *, "content", *, "example"]
|
|
1332
|
+
path[0] === 'paths' &&
|
|
1333
|
+
path[3] === 'responses' &&
|
|
1334
|
+
path[5] === 'content' &&
|
|
1335
|
+
path[7] === 'example');},
|
|
1336
|
+
|
|
1337
|
+
function (path) {return (
|
|
1338
|
+
// OpenAPI 3.0 Request Body Media Type Example
|
|
1339
|
+
// ["paths", *, *, "responses", *, "content", *, "example"]
|
|
1340
|
+
path[0] === 'paths' &&
|
|
1341
|
+
path[3] === 'requestBody' &&
|
|
1342
|
+
path[4] === 'content' &&
|
|
1343
|
+
path[6] === 'example');}];
|
|
1344
|
+
|
|
1345
|
+
|
|
1346
|
+
|
|
1347
|
+
var shouldSkipResolution = function shouldSkipResolution(path) {return skipResolutionTestFns.some(function (fn) {return fn(path);});};
|
|
1348
|
+
|
|
1349
|
+
// =========================
|
|
1350
|
+
// Core
|
|
1351
|
+
// =========================
|
|
1352
|
+
|
|
1353
|
+
/**
|
|
1354
|
+
* This plugin resolves the JSON pointers.
|
|
1355
|
+
* A major part of this plugin deals with cyclic references via 2 mechanisms.
|
|
1356
|
+
* 1. If a pointer was already resolved before in this path, halt.
|
|
1357
|
+
* 2. If the patch value points to one of the ancestors in this path, halt.
|
|
1358
|
+
*
|
|
1359
|
+
* Note that either one of these mechanism is sufficient, both must be in place.
|
|
1360
|
+
* For examples:
|
|
1361
|
+
*
|
|
1362
|
+
* Given the following spec, #1 alone is insufficient because after the 2nd
|
|
1363
|
+
* application, there will be a cyclic object reference.
|
|
1364
|
+
* a.b.c: $ref-d
|
|
1365
|
+
* d.e.f: $ref-a (per #1, safe to return patch as no immediate cycle)
|
|
1366
|
+
*
|
|
1367
|
+
* Given the following spec, #2 alone is insufficient because although there will
|
|
1368
|
+
* never be any cyclic object reference, the plugin will keep producing patches.
|
|
1369
|
+
* a: $ref-b
|
|
1370
|
+
* b: $ref-a
|
|
1371
|
+
*/
|
|
1372
|
+
var refs_plugin = {
|
|
1373
|
+
key: '$ref',
|
|
1374
|
+
plugin: function plugin(ref, key, fullPath, specmap) {
|
|
1375
|
+
var specmapInstance = specmap.getInstance();
|
|
1376
|
+
var parent = fullPath.slice(0, -1);
|
|
1377
|
+
|
|
1378
|
+
if (isFreelyNamed(parent) || shouldSkipResolution(parent)) {
|
|
1379
|
+
return;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
var baseDoc = specmap.getContext(fullPath).baseDoc;
|
|
1383
|
+
if (typeof ref !== 'string') {
|
|
1384
|
+
return new JSONRefError('$ref: must be a string (JSON-Ref)', {
|
|
1385
|
+
$ref: ref,
|
|
1386
|
+
baseDoc: baseDoc,
|
|
1387
|
+
fullPath: fullPath });
|
|
1388
|
+
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
var splitString = split(ref);
|
|
1392
|
+
var refPath = splitString[0];
|
|
1393
|
+
var pointer = splitString[1] || '';
|
|
1394
|
+
|
|
1395
|
+
var basePath;
|
|
1396
|
+
try {
|
|
1397
|
+
basePath = baseDoc || refPath ? absoluteify(refPath, baseDoc) : null;
|
|
1398
|
+
}
|
|
1399
|
+
catch (e) {
|
|
1400
|
+
return wrapError(e, {
|
|
1401
|
+
pointer: pointer,
|
|
1402
|
+
$ref: ref,
|
|
1403
|
+
basePath: basePath,
|
|
1404
|
+
fullPath: fullPath });
|
|
1405
|
+
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
var promOrVal;
|
|
1409
|
+
var tokens;
|
|
1410
|
+
|
|
1411
|
+
if (pointerAlreadyInPath(pointer, basePath, parent, specmap)) {
|
|
1412
|
+
// Cyclic reference!
|
|
1413
|
+
// if `useCircularStructures` is not set, just leave the reference
|
|
1414
|
+
// unresolved, but absolutify it so that we don't leave an invalid $ref
|
|
1415
|
+
// path in the content
|
|
1416
|
+
if (!specmapInstance.useCircularStructures) {
|
|
1417
|
+
var _absolutifiedRef = absolutifyPointer(ref, basePath);
|
|
1418
|
+
|
|
1419
|
+
if (ref === _absolutifiedRef) {
|
|
1420
|
+
// avoids endless looping
|
|
1421
|
+
// without this, the ref plugin never stops seeing this $ref
|
|
1422
|
+
return null;
|
|
1423
|
+
}
|
|
1424
|
+
return lib.replace(fullPath, _absolutifiedRef);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
if (basePath == null) {
|
|
1429
|
+
tokens = jsonPointerToArray(pointer);
|
|
1430
|
+
promOrVal = specmap.get(tokens);
|
|
1431
|
+
|
|
1432
|
+
if (typeof promOrVal === 'undefined') {
|
|
1433
|
+
promOrVal = new JSONRefError("Could not resolve reference: ".concat(ref), {
|
|
1434
|
+
pointer: pointer,
|
|
1435
|
+
$ref: ref,
|
|
1436
|
+
baseDoc: baseDoc,
|
|
1437
|
+
fullPath: fullPath });
|
|
1438
|
+
|
|
1439
|
+
}
|
|
1440
|
+
} else
|
|
1441
|
+
{
|
|
1442
|
+
promOrVal = extractFromDoc(basePath, pointer);
|
|
1443
|
+
if (promOrVal.__value != null) {
|
|
1444
|
+
promOrVal = promOrVal.__value;
|
|
1445
|
+
} else
|
|
1446
|
+
{
|
|
1447
|
+
promOrVal = promOrVal.catch(function (e) {
|
|
1448
|
+
throw wrapError(e, {
|
|
1449
|
+
pointer: pointer,
|
|
1450
|
+
$ref: ref,
|
|
1451
|
+
baseDoc: baseDoc,
|
|
1452
|
+
fullPath: fullPath });
|
|
1453
|
+
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
if (promOrVal instanceof Error) {
|
|
1459
|
+
return [lib.remove(fullPath), promOrVal];
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
var absolutifiedRef = absolutifyPointer(ref, basePath);
|
|
1463
|
+
|
|
1464
|
+
var patch = lib.replace(parent, promOrVal, { $$ref: absolutifiedRef });
|
|
1465
|
+
if (basePath && basePath !== baseDoc) {
|
|
1466
|
+
return [patch, lib.context(parent, { baseDoc: basePath })];
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
try {
|
|
1470
|
+
// prevents circular values from being constructed, unless we specifically
|
|
1471
|
+
// want that to happen
|
|
1472
|
+
if (!patchValueAlreadyInPath(specmap.state, patch) || specmapInstance.useCircularStructures) {
|
|
1473
|
+
return patch;
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
catch (e) {
|
|
1477
|
+
// if we're catching here, path traversal failed, so we should
|
|
1478
|
+
// ditch without sending any patches back up.
|
|
1479
|
+
//
|
|
1480
|
+
// this is a narrow fix for the larger problem of patches being queued
|
|
1481
|
+
// and then having the state they were generated against be modified
|
|
1482
|
+
// before they are applied.
|
|
1483
|
+
//
|
|
1484
|
+
// TODO: re-engineer specmap patch/state management to avoid this
|
|
1485
|
+
return null;
|
|
1486
|
+
}
|
|
1487
|
+
} };
|
|
1488
|
+
|
|
1489
|
+
|
|
1490
|
+
|
|
1491
|
+
var mod = object_assign_default()(refs_plugin, {
|
|
1492
|
+
docCache: docCache,
|
|
1493
|
+
absoluteify: absoluteify,
|
|
1494
|
+
clearCache: clearCache,
|
|
1495
|
+
JSONRefError: JSONRefError,
|
|
1496
|
+
wrapError: wrapError,
|
|
1497
|
+
getDoc: getDoc,
|
|
1498
|
+
split: split,
|
|
1499
|
+
extractFromDoc: extractFromDoc,
|
|
1500
|
+
fetchJSON: fetchJSON,
|
|
1501
|
+
extract: extract,
|
|
1502
|
+
jsonPointerToArray: jsonPointerToArray,
|
|
1503
|
+
unescapeJsonPointerToken: unescapeJsonPointerToken });
|
|
1504
|
+
|
|
1505
|
+
|
|
1506
|
+
/* harmony default export */ var refs = (mod);
|
|
1507
|
+
|
|
1508
|
+
|
|
1509
|
+
// =========================
|
|
1510
|
+
// Utilities
|
|
1511
|
+
// =========================
|
|
1512
|
+
|
|
1513
|
+
/**
|
|
1514
|
+
* Resolves a path and its base to an abolute URL.
|
|
1515
|
+
* @api public
|
|
1516
|
+
*/
|
|
1517
|
+
function absoluteify(path, basePath) {
|
|
1518
|
+
if (!ABSOLUTE_URL_REGEXP.test(path)) {
|
|
1519
|
+
if (!basePath) {
|
|
1520
|
+
throw new JSONRefError("Tried to resolve a relative URL, without having a basePath. path: '".concat(path, "' basePath: '").concat(basePath, "'"));
|
|
1521
|
+
}
|
|
1522
|
+
return external_url_default.a.resolve(basePath, path);
|
|
1523
|
+
}
|
|
1524
|
+
return path;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
/**
|
|
1528
|
+
* Wraps an error as JSONRefError.
|
|
1529
|
+
* @param {Error} e the error.
|
|
1530
|
+
* @param {Object} extra (optional) optional data.
|
|
1531
|
+
* @return {Error} an instance of JSONRefError.
|
|
1532
|
+
* @api public
|
|
1533
|
+
*/
|
|
1534
|
+
function wrapError(e, extra) {
|
|
1535
|
+
var message;
|
|
1536
|
+
|
|
1537
|
+
if (e && e.response && e.response.body) {
|
|
1538
|
+
message = "".concat(e.response.body.code, " ").concat(e.response.body.message);
|
|
1539
|
+
} else
|
|
1540
|
+
{
|
|
1541
|
+
message = e.message;
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
return new JSONRefError("Could not resolve reference: ".concat(message), extra, e);
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
/**
|
|
1548
|
+
* Splits a pointer by the hash delimiter.
|
|
1549
|
+
* @api public
|
|
1550
|
+
*/
|
|
1551
|
+
function split(ref) {
|
|
1552
|
+
return (ref + '').split('#'); // eslint-disable-line prefer-template
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
/**
|
|
1556
|
+
* Extracts a pointer from its document.
|
|
1557
|
+
* @param {String} docPath the absolute document URL.
|
|
1558
|
+
* @param {String} pointer the pointer whose value is to be extracted.
|
|
1559
|
+
* @return {Promise} a promise of the pointer value.
|
|
1560
|
+
* @api public
|
|
1561
|
+
*/
|
|
1562
|
+
function extractFromDoc(docPath, pointer) {
|
|
1563
|
+
var doc = docCache[docPath];
|
|
1564
|
+
if (doc && !lib.isPromise(doc)) {
|
|
1565
|
+
// If doc is already available, return __value together with the promise.
|
|
1566
|
+
// __value is for special handling in cycle check:
|
|
1567
|
+
// pointerAlreadyInPath() won't work if patch.value is a promise,
|
|
1568
|
+
// thus when that promise is finally resolved, cycle might happen (because
|
|
1569
|
+
// `spec` and `docCache[basePath]` refer to the exact same object).
|
|
1570
|
+
// See test "should resolve a cyclic spec when baseDoc is specified".
|
|
1571
|
+
try {
|
|
1572
|
+
var v = extract(pointer, doc);
|
|
1573
|
+
return object_assign_default()(promise_default.a.resolve(v), { __value: v });
|
|
1574
|
+
}
|
|
1575
|
+
catch (e) {
|
|
1576
|
+
return promise_default.a.reject(e);
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
return getDoc(docPath).then(function (_doc) {return extract(pointer, _doc);});
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
/**
|
|
1584
|
+
* Clears all document caches.
|
|
1585
|
+
* @param {String} item (optional) the name of the cache item to be cleared.
|
|
1586
|
+
* @api public
|
|
1587
|
+
*/
|
|
1588
|
+
function clearCache(item) {
|
|
1589
|
+
if (typeof item !== 'undefined') {
|
|
1590
|
+
delete docCache[item];
|
|
1591
|
+
} else
|
|
1592
|
+
{
|
|
1593
|
+
keys_default()(docCache).forEach(function (key) {
|
|
1594
|
+
delete docCache[key];
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
/**
|
|
1600
|
+
* Fetches and caches a document.
|
|
1601
|
+
* @param {String} docPath the absolute URL of the document.
|
|
1602
|
+
* @return {Promise} a promise of the document content.
|
|
1603
|
+
* @api public
|
|
1604
|
+
*/
|
|
1605
|
+
function getDoc(docPath) {
|
|
1606
|
+
var val = docCache[docPath];
|
|
1607
|
+
if (val) {
|
|
1608
|
+
return lib.isPromise(val) ? val : promise_default.a.resolve(val);
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
// NOTE: we need to use `mod.fetchJSON` in order to be able to overwrite it.
|
|
1612
|
+
// Any tips on how to make this cleaner, please ping!
|
|
1613
|
+
docCache[docPath] = mod.fetchJSON(docPath).then(function (doc) {
|
|
1614
|
+
docCache[docPath] = doc;
|
|
1615
|
+
return doc;
|
|
1616
|
+
});
|
|
1617
|
+
return docCache[docPath];
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
/**
|
|
1621
|
+
* Fetches a document.
|
|
1622
|
+
* @param {String} docPath the absolute URL of the document.
|
|
1623
|
+
* @return {Promise} a promise of the document content.
|
|
1624
|
+
* @api public
|
|
1625
|
+
*/
|
|
1626
|
+
function fetchJSON(docPath) {
|
|
1627
|
+
return Object(external_cross_fetch_["fetch"])(docPath, { headers: { Accept: 'application/json, application/yaml' }, loadSpec: true }).
|
|
1628
|
+
then(function (res) {return res.text();}).
|
|
1629
|
+
then(function (text) {return external_js_yaml_default.a.safeLoad(text);});
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
/**
|
|
1633
|
+
* Extracts a pointer from an object.
|
|
1634
|
+
* @param {String[]} pointer the JSON pointer.
|
|
1635
|
+
* @param {Object} obj an object whose value is to be extracted.
|
|
1636
|
+
* @return {Object} the value to be extracted.
|
|
1637
|
+
* @api public
|
|
1638
|
+
*/
|
|
1639
|
+
function extract(pointer, obj) {
|
|
1640
|
+
var tokens = jsonPointerToArray(pointer);
|
|
1641
|
+
if (tokens.length < 1) {
|
|
1642
|
+
return obj;
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
var val = lib.getIn(obj, tokens);
|
|
1646
|
+
if (typeof val === 'undefined') {
|
|
1647
|
+
throw new JSONRefError("Could not resolve pointer: ".concat(pointer, " does not exist in document"), { pointer: pointer });
|
|
1648
|
+
}
|
|
1649
|
+
return val;
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
/**
|
|
1653
|
+
* Converts a JSON pointer to array.
|
|
1654
|
+
* @api public
|
|
1655
|
+
*/
|
|
1656
|
+
function jsonPointerToArray(pointer) {
|
|
1657
|
+
if (typeof pointer !== 'string') {
|
|
1658
|
+
throw new TypeError("Expected a string, got a ".concat(typeof_default()(pointer)));
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
if (pointer[0] === '/') {
|
|
1662
|
+
pointer = pointer.substr(1);
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
if (pointer === '') {
|
|
1666
|
+
return [];
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
return pointer.split('/').map(unescapeJsonPointerToken);
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
/**
|
|
1673
|
+
* Unescapes a JSON pointer.
|
|
1674
|
+
* @api public
|
|
1675
|
+
*/
|
|
1676
|
+
function unescapeJsonPointerToken(token) {
|
|
1677
|
+
if (typeof token !== 'string') {
|
|
1678
|
+
return token;
|
|
1679
|
+
}
|
|
1680
|
+
return external_querystring_browser_default.a.unescape(token.replace(/~1/g, '/').replace(/~0/g, '~'));
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
/**
|
|
1684
|
+
* Escapes a JSON pointer.
|
|
1685
|
+
* @api public
|
|
1686
|
+
*/
|
|
1687
|
+
function escapeJsonPointerToken(token) {
|
|
1688
|
+
return external_querystring_browser_default.a.escape(token.replace(/~/g, '~0').replace(/\//g, '~1'));
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
function arrayToJsonPointer(arr) {
|
|
1692
|
+
if (arr.length === 0) {
|
|
1693
|
+
return '';
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
return "/".concat(arr.map(escapeJsonPointerToken).join('/'));
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
var pointerBoundaryChar = function pointerBoundaryChar(c) {return !c || c === '/' || c === '#';};
|
|
1700
|
+
|
|
1701
|
+
function pointerIsAParent(pointer, parentPointer) {
|
|
1702
|
+
if (pointerBoundaryChar(parentPointer)) {
|
|
1703
|
+
// This is the root of the document, so its naturally a parent
|
|
1704
|
+
return true;
|
|
1705
|
+
}
|
|
1706
|
+
var nextChar = pointer.charAt(parentPointer.length);
|
|
1707
|
+
var lastParentChar = parentPointer.slice(-1);
|
|
1708
|
+
|
|
1709
|
+
return pointer.indexOf(parentPointer) === 0 && (
|
|
1710
|
+
!nextChar || nextChar === '/' || nextChar === '#') &&
|
|
1711
|
+
lastParentChar !== '#';
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
|
|
1715
|
+
// =========================
|
|
1716
|
+
// Private
|
|
1717
|
+
// =========================
|
|
1718
|
+
|
|
1719
|
+
/**
|
|
1720
|
+
* Checks if this pointer points back to one or more pointers along the path.
|
|
1721
|
+
*/
|
|
1722
|
+
function pointerAlreadyInPath(pointer, basePath, parent, specmap) {
|
|
1723
|
+
var refs = specmapRefs.get(specmap);
|
|
1724
|
+
if (!refs) {
|
|
1725
|
+
// Stores all resolved references of a specmap instance.
|
|
1726
|
+
// Schema: path -> pointer (path's $ref value).
|
|
1727
|
+
refs = {};
|
|
1728
|
+
specmapRefs.set(specmap, refs);
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
var parentPointer = arrayToJsonPointer(parent);
|
|
1732
|
+
var fullyQualifiedPointer = "".concat(basePath || '<specmap-base>', "#").concat(pointer);
|
|
1733
|
+
|
|
1734
|
+
// dirty hack to strip `allof/[index]` from the path, in order to avoid cases
|
|
1735
|
+
// where we get false negatives because:
|
|
1736
|
+
// - we resolve a path, then
|
|
1737
|
+
// - allOf plugin collapsed `allOf/[index]` out of the path, then
|
|
1738
|
+
// - we try to work on a child $ref within that collapsed path.
|
|
1739
|
+
//
|
|
1740
|
+
// because of the path collapse, we lose track of it in our specmapRefs hash
|
|
1741
|
+
// solution: always throw the allOf constructs out of paths we store
|
|
1742
|
+
// TODO: solve this with a global register, or by writing more metadata in
|
|
1743
|
+
// either allOf or refs plugin
|
|
1744
|
+
var safeParentPointer = parentPointer.replace(/allOf\/\d+\/?/g, '');
|
|
1745
|
+
|
|
1746
|
+
// Case 1: direct cycle, e.g. a.b.c.$ref: '/a.b'
|
|
1747
|
+
// Detect by checking that the parent path doesn't start with pointer.
|
|
1748
|
+
// This only applies if the pointer is internal, i.e. basePath === rootPath (could be null)
|
|
1749
|
+
var rootDoc = specmap.contextTree.get([]).baseDoc;
|
|
1750
|
+
if (basePath == rootDoc && pointerIsAParent(safeParentPointer, pointer)) {// eslint-disable-line
|
|
1751
|
+
return true;
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
|
|
1755
|
+
// Case 2: indirect cycle
|
|
1756
|
+
// ex1: a.$ref: '/b' & b.c.$ref: '/b/c'
|
|
1757
|
+
// ex2: a.$ref: '/b/c' & b.c.$ref: '/b'
|
|
1758
|
+
// Detect by retrieving all the $refs along the path of parent
|
|
1759
|
+
// and checking if any starts with pointer or vice versa.
|
|
1760
|
+
var currPath = '';
|
|
1761
|
+
var hasIndirectCycle = parent.some(function (token) {
|
|
1762
|
+
currPath = "".concat(currPath, "/").concat(escapeJsonPointerToken(token));
|
|
1763
|
+
return refs[currPath] && refs[currPath].some(function (ref) {
|
|
1764
|
+
return (
|
|
1765
|
+
pointerIsAParent(ref, fullyQualifiedPointer) ||
|
|
1766
|
+
pointerIsAParent(fullyQualifiedPointer, ref));
|
|
1767
|
+
|
|
1768
|
+
});
|
|
1769
|
+
});
|
|
1770
|
+
if (hasIndirectCycle) {
|
|
1771
|
+
return true;
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
// No cycle, this ref will be resolved, so stores it now for future detection.
|
|
1775
|
+
// No need to store if has cycle, as parent path is a dead-end and won't be checked again.
|
|
1776
|
+
|
|
1777
|
+
refs[safeParentPointer] = (refs[safeParentPointer] || []).concat(fullyQualifiedPointer);
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
/**
|
|
1781
|
+
* Checks if the value of this patch ends up pointing to an ancestor along the path.
|
|
1782
|
+
*/
|
|
1783
|
+
function patchValueAlreadyInPath(root, patch) {
|
|
1784
|
+
var ancestors = [root];
|
|
1785
|
+
patch.path.reduce(function (parent, p) {
|
|
1786
|
+
ancestors.push(parent[p]);
|
|
1787
|
+
return parent[p];
|
|
1788
|
+
}, root);
|
|
1789
|
+
return pointToAncestor(patch.value);
|
|
1790
|
+
|
|
1791
|
+
function pointToAncestor(obj) {
|
|
1792
|
+
return lib.isObject(obj) && (ancestors.indexOf(obj) >= 0 || keys_default()(obj).some(function (k) {
|
|
1793
|
+
return pointToAncestor(obj[k]);
|
|
1794
|
+
}));
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
// CONCATENATED MODULE: ./src/specmap/lib/all-of.js
|
|
1798
|
+
|
|
1799
|
+
|
|
1800
|
+
/* harmony default export */ var all_of = ({
|
|
1801
|
+
key: 'allOf',
|
|
1802
|
+
plugin: function plugin(val, key, fullPath, specmap, patch) {
|
|
1803
|
+
// Ignore replace patches created by $ref because the changes will
|
|
1804
|
+
// occur in the original "add" patch and we don't want this plugin
|
|
1805
|
+
// to redundantly processes those "relace" patches.
|
|
1806
|
+
if (patch.meta && patch.meta.$$ref) {
|
|
1807
|
+
return;
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
var parent = fullPath.slice(0, -1);
|
|
1811
|
+
if (isFreelyNamed(parent)) {
|
|
1812
|
+
return;
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
if (!is_array_default()(val)) {
|
|
1816
|
+
var err = new TypeError('allOf must be an array');
|
|
1817
|
+
err.fullPath = fullPath; // This is an array
|
|
1818
|
+
return err;
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
|
|
1822
|
+
var alreadyAddError = false;
|
|
1823
|
+
|
|
1824
|
+
// Find the original definition from the `patch.value` object
|
|
1825
|
+
// Remove the `allOf` property so it doesn't get added to the result of the `allOf` plugin
|
|
1826
|
+
var originalDefinitionObj = patch.value;
|
|
1827
|
+
parent.forEach(function (part) {
|
|
1828
|
+
if (!originalDefinitionObj) return; // bail out if we've lost sight of our target
|
|
1829
|
+
originalDefinitionObj = originalDefinitionObj[part];
|
|
1830
|
+
});
|
|
1831
|
+
originalDefinitionObj = object_assign_default()({}, originalDefinitionObj);
|
|
1832
|
+
delete originalDefinitionObj.allOf;
|
|
1833
|
+
|
|
1834
|
+
var patches = [];
|
|
1835
|
+
|
|
1836
|
+
// remove existing content
|
|
1837
|
+
patches.push(specmap.replace(parent, {}));
|
|
1838
|
+
|
|
1839
|
+
val.forEach(function (toMerge, i) {
|
|
1840
|
+
if (!specmap.isObject(toMerge)) {
|
|
1841
|
+
if (alreadyAddError) {
|
|
1842
|
+
return null;
|
|
1843
|
+
}
|
|
1844
|
+
alreadyAddError = true;
|
|
1845
|
+
|
|
1846
|
+
var _err = new TypeError('Elements in allOf must be objects');
|
|
1847
|
+
_err.fullPath = fullPath; // This is an array
|
|
1848
|
+
return patches.push(_err);
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
// Deeply merge the member's contents onto the parent location
|
|
1852
|
+
patches.push(specmap.mergeDeep(parent, toMerge));
|
|
1853
|
+
|
|
1854
|
+
// Generate patches that migrate $ref values based on ContextTree information
|
|
1855
|
+
|
|
1856
|
+
// remove ["allOf"], which will not be present when these patches are applied
|
|
1857
|
+
var collapsedFullPath = fullPath.slice(0, -1);
|
|
1858
|
+
|
|
1859
|
+
var absoluteRefPatches = generateAbsoluteRefPatches(toMerge, collapsedFullPath, {
|
|
1860
|
+
getBaseUrlForNodePath: function getBaseUrlForNodePath(nodePath) {
|
|
1861
|
+
return specmap.getContext([].concat(toConsumableArray_default()(fullPath), [i], toConsumableArray_default()(nodePath))).baseDoc;
|
|
1862
|
+
},
|
|
1863
|
+
specmap: specmap });
|
|
1864
|
+
|
|
1865
|
+
|
|
1866
|
+
patches.push.apply(patches, toConsumableArray_default()(absoluteRefPatches));
|
|
1867
|
+
});
|
|
1868
|
+
|
|
1869
|
+
// Merge back the values from the original definition
|
|
1870
|
+
patches.push(specmap.mergeDeep(parent, originalDefinitionObj));
|
|
1871
|
+
|
|
1872
|
+
// If there was not an original $$ref value, make sure to remove
|
|
1873
|
+
// any $$ref value that may exist from the result of `allOf` merges
|
|
1874
|
+
if (!originalDefinitionObj.$$ref) {
|
|
1875
|
+
patches.push(specmap.remove([].concat(parent, '$$ref')));
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
return patches;
|
|
1879
|
+
} });
|
|
1880
|
+
// CONCATENATED MODULE: ./src/specmap/lib/parameters.js
|
|
1881
|
+
|
|
1882
|
+
|
|
1883
|
+
/* harmony default export */ var lib_parameters = ({
|
|
1884
|
+
key: 'parameters',
|
|
1885
|
+
plugin: function plugin(parameters, key, fullPath, specmap, patch) {
|
|
1886
|
+
if (is_array_default()(parameters) && parameters.length) {
|
|
1887
|
+
var val = object_assign_default()([], parameters);
|
|
1888
|
+
var opPath = fullPath.slice(0, -1);
|
|
1889
|
+
var op = object_assign_default()({}, lib.getIn(specmap.spec, opPath));
|
|
1890
|
+
|
|
1891
|
+
parameters.forEach(function (param, i) {
|
|
1892
|
+
try {
|
|
1893
|
+
val[i].default = specmap.parameterMacro(op, param);
|
|
1894
|
+
}
|
|
1895
|
+
catch (e) {
|
|
1896
|
+
var err = new Error(e);
|
|
1897
|
+
err.fullPath = fullPath;
|
|
1898
|
+
return err;
|
|
1899
|
+
}
|
|
1900
|
+
});
|
|
1901
|
+
|
|
1902
|
+
return lib.replace(fullPath, val);
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
return lib.replace(fullPath, parameters);
|
|
1906
|
+
} });
|
|
1907
|
+
// CONCATENATED MODULE: ./src/specmap/lib/properties.js
|
|
1908
|
+
|
|
1909
|
+
|
|
1910
|
+
/* harmony default export */ var lib_properties = ({
|
|
1911
|
+
key: 'properties',
|
|
1912
|
+
plugin: function plugin(properties, key, fullPath, specmap) {
|
|
1913
|
+
var val = object_assign_default()({}, properties);
|
|
1914
|
+
|
|
1915
|
+
for (var k in properties) {
|
|
1916
|
+
try {
|
|
1917
|
+
val[k].default = specmap.modelPropertyMacro(val[k]);
|
|
1918
|
+
}
|
|
1919
|
+
catch (e) {
|
|
1920
|
+
var err = new Error(e);
|
|
1921
|
+
err.fullPath = fullPath; // This is an array
|
|
1922
|
+
return err;
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
var patch = lib.replace(fullPath, val);
|
|
1927
|
+
|
|
1928
|
+
return patch;
|
|
1929
|
+
} });
|
|
1930
|
+
// CONCATENATED MODULE: ./src/specmap/lib/context-tree.js
|
|
1931
|
+
function ownKeys(object, enumerableOnly) {var keys = keys_default()(object);if (get_own_property_symbols_default.a) {var symbols = get_own_property_symbols_default()(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {return get_own_property_descriptor_default()(object, sym).enumerable;});keys.push.apply(keys, symbols);}return keys;}function _objectSpread(target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {ownKeys(source, true).forEach(function (key) {defineProperty_default()(target, key, source[key]);});} else if (get_own_property_descriptors_default.a) {define_properties_default()(target, get_own_property_descriptors_default()(source));} else {ownKeys(source).forEach(function (key) {define_property_default()(target, key, get_own_property_descriptor_default()(source, key));});}}return target;}var context_tree_ContextTree = /*#__PURE__*/function () {
|
|
1932
|
+
function ContextTree(value) {classCallCheck_default()(this, ContextTree);
|
|
1933
|
+
this.root = createNode(value || {});
|
|
1934
|
+
}createClass_default()(ContextTree, [{ key: "set", value: function set(
|
|
1935
|
+
|
|
1936
|
+
path, value) {
|
|
1937
|
+
var parent = this.getParent(path, true);
|
|
1938
|
+
if (!parent) {
|
|
1939
|
+
updateNode(this.root, value, null);
|
|
1940
|
+
return;
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
var key = path[path.length - 1];
|
|
1944
|
+
var children = parent.children;
|
|
1945
|
+
if (children[key]) {
|
|
1946
|
+
updateNode(children[key], value, parent);
|
|
1947
|
+
return;
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
children[key] = createNode(value, parent);
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
// Get the "best" node (node or nearest parent) and return its value.
|
|
1954
|
+
}, { key: "get", value: function get(path) {
|
|
1955
|
+
path = path || [];
|
|
1956
|
+
|
|
1957
|
+
if (path.length < 1) {
|
|
1958
|
+
return this.root.value;
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
var branch = this.root;
|
|
1962
|
+
var child;
|
|
1963
|
+
var token;
|
|
1964
|
+
for (var i = 0; i < path.length; i++) {
|
|
1965
|
+
token = path[i];
|
|
1966
|
+
child = branch.children;
|
|
1967
|
+
if (!child[token]) {
|
|
1968
|
+
break;
|
|
1969
|
+
}
|
|
1970
|
+
branch = child[token];
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
return branch && branch.protoValue;
|
|
1974
|
+
} }, { key: "getParent", value: function getParent(
|
|
1975
|
+
|
|
1976
|
+
path, ensureExists) {
|
|
1977
|
+
if (!path || path.length < 1) {
|
|
1978
|
+
return null;
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
if (path.length < 2) {
|
|
1982
|
+
return this.root;
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
return path.slice(0, -1).reduce(function (branch, token) {
|
|
1986
|
+
if (!branch) {
|
|
1987
|
+
return branch;
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
var children = branch.children;
|
|
1991
|
+
|
|
1992
|
+
if (!children[token] && ensureExists) {
|
|
1993
|
+
children[token] = createNode(null, branch);
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
return children[token];
|
|
1997
|
+
}, this.root);
|
|
1998
|
+
} }]);return ContextTree;}();
|
|
1999
|
+
|
|
2000
|
+
|
|
2001
|
+
// =========================
|
|
2002
|
+
// Utilities
|
|
2003
|
+
// =========================
|
|
2004
|
+
|
|
2005
|
+
function createNode(value, parent) {
|
|
2006
|
+
return updateNode({ children: {} }, value, parent);
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
function updateNode(node, value, parent) {
|
|
2010
|
+
node.value = value || {};
|
|
2011
|
+
node.protoValue = parent ? _objectSpread({},
|
|
2012
|
+
parent.protoValue, {}, node.value) :
|
|
2013
|
+
node.value;
|
|
2014
|
+
|
|
2015
|
+
keys_default()(node.children).forEach(function (prop) {
|
|
2016
|
+
var child = node.children[prop];
|
|
2017
|
+
node.children[prop] = updateNode(child, child.value, node);
|
|
2018
|
+
});
|
|
2019
|
+
|
|
2020
|
+
return node;
|
|
2021
|
+
}
|
|
2022
|
+
// CONCATENATED MODULE: ./src/specmap/index.js
|
|
2023
|
+
|
|
2024
|
+
|
|
2025
|
+
|
|
2026
|
+
|
|
2027
|
+
|
|
2028
|
+
|
|
2029
|
+
|
|
2030
|
+
|
|
2031
|
+
|
|
2032
|
+
var HARD_LIMIT = 100;var
|
|
2033
|
+
|
|
2034
|
+
specmap_SpecMap = /*#__PURE__*/function () {
|
|
2035
|
+
function SpecMap(opts) {var _this = this;classCallCheck_default()(this, SpecMap);
|
|
2036
|
+
object_assign_default()(this, {
|
|
2037
|
+
spec: '',
|
|
2038
|
+
debugLevel: 'info',
|
|
2039
|
+
plugins: [],
|
|
2040
|
+
pluginHistory: {},
|
|
2041
|
+
errors: [],
|
|
2042
|
+
mutations: [],
|
|
2043
|
+
promisedPatches: [],
|
|
2044
|
+
state: {},
|
|
2045
|
+
patches: [],
|
|
2046
|
+
context: {},
|
|
2047
|
+
contextTree: new context_tree_ContextTree(),
|
|
2048
|
+
showDebug: false,
|
|
2049
|
+
allPatches: [], // only populated if showDebug is true
|
|
2050
|
+
pluginProp: 'specMap',
|
|
2051
|
+
libMethods: object_assign_default()(create_default()(this), lib, {
|
|
2052
|
+
getInstance: function getInstance() {return _this;} }),
|
|
2053
|
+
|
|
2054
|
+
allowMetaPatches: false },
|
|
2055
|
+
opts);
|
|
2056
|
+
|
|
2057
|
+
// Lib methods bound
|
|
2058
|
+
this.get = this._get.bind(this);
|
|
2059
|
+
this.getContext = this._getContext.bind(this);
|
|
2060
|
+
this.hasRun = this._hasRun.bind(this);
|
|
2061
|
+
|
|
2062
|
+
this.wrappedPlugins = this.plugins.
|
|
2063
|
+
map(this.wrapPlugin.bind(this)).
|
|
2064
|
+
filter(lib.isFunction);
|
|
2065
|
+
|
|
2066
|
+
// Initial patch(s)
|
|
2067
|
+
this.patches.push(lib.add([], this.spec));
|
|
2068
|
+
this.patches.push(lib.context([], this.context));
|
|
2069
|
+
this.updatePatches(this.patches);
|
|
2070
|
+
}createClass_default()(SpecMap, [{ key: "debug", value: function debug(
|
|
2071
|
+
|
|
2072
|
+
level) {
|
|
2073
|
+
if (this.debugLevel === level) {var _console;for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {args[_key - 1] = arguments[_key];}
|
|
2074
|
+
(_console = console).log.apply(_console, args); // eslint-disable-line no-console
|
|
2075
|
+
}
|
|
2076
|
+
} }, { key: "verbose", value: function verbose(
|
|
2077
|
+
|
|
2078
|
+
header) {
|
|
2079
|
+
if (this.debugLevel === 'verbose') {var _console2;for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {args[_key2 - 1] = arguments[_key2];}
|
|
2080
|
+
(_console2 = console).log.apply(_console2, ["[".concat(header, "] ")].concat(args)); // eslint-disable-line no-console
|
|
2081
|
+
}
|
|
2082
|
+
} }, { key: "wrapPlugin", value: function wrapPlugin(
|
|
2083
|
+
|
|
2084
|
+
plugin, name) {
|
|
2085
|
+
var pathDiscriminator = this.pathDiscriminator;
|
|
2086
|
+
var ctx = null;
|
|
2087
|
+
var fn;
|
|
2088
|
+
|
|
2089
|
+
if (plugin[this.pluginProp]) {
|
|
2090
|
+
ctx = plugin;
|
|
2091
|
+
fn = plugin[this.pluginProp];
|
|
2092
|
+
} else
|
|
2093
|
+
if (lib.isFunction(plugin)) {
|
|
2094
|
+
fn = plugin;
|
|
2095
|
+
} else
|
|
2096
|
+
if (lib.isObject(plugin)) {
|
|
2097
|
+
fn = createKeyBasedPlugin(plugin);
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
return object_assign_default()(fn.bind(ctx), {
|
|
2101
|
+
pluginName: plugin.name || name,
|
|
2102
|
+
isGenerator: lib.isGenerator(fn) });
|
|
2103
|
+
|
|
2104
|
+
|
|
2105
|
+
// Expected plugin interface: {key: string, plugin: fn*}
|
|
2106
|
+
// This traverses depth-first and immediately applies yielded patches.
|
|
2107
|
+
// This strategy should work well for most plugins (including the built-ins).
|
|
2108
|
+
// We might consider making this (traversing & application) configurable later.
|
|
2109
|
+
function createKeyBasedPlugin(pluginObj) {
|
|
2110
|
+
var isSubPath = function isSubPath(path, tested) {
|
|
2111
|
+
if (!is_array_default()(path)) {
|
|
2112
|
+
return true;
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
return path.every(function (val, i) {
|
|
2116
|
+
return val === tested[i];
|
|
2117
|
+
});
|
|
2118
|
+
};
|
|
2119
|
+
|
|
2120
|
+
return (/*#__PURE__*/regenerator_default.a.mark(function _callee(patches, specmap) {var _marked, refCache, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, patch,
|
|
2121
|
+
|
|
2122
|
+
|
|
2123
|
+
|
|
2124
|
+
|
|
2125
|
+
|
|
2126
|
+
|
|
2127
|
+
traverse;return regenerator_default.a.wrap(function _callee$(_context2) {while (1) {switch (_context2.prev = _context2.next) {case 0:traverse = function _ref(obj, path, patch) {var parentIndex, parent, indexOfFirstProperties, isRootProperties, traversed, _i, _Object$keys, key, val, updatedPath, isObj, objRef, isWithinPathDiscriminator;return regenerator_default.a.wrap(function traverse$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:if (
|
|
2128
|
+
lib.isObject(obj)) {_context.next = 6;break;}if (!(
|
|
2129
|
+
pluginObj.key === path[path.length - 1])) {_context.next = 4;break;}_context.next = 4;
|
|
2130
|
+
return pluginObj.plugin(obj, pluginObj.key, path, specmap);case 4:_context.next = 30;break;case 6:
|
|
2131
|
+
|
|
2132
|
+
|
|
2133
|
+
|
|
2134
|
+
parentIndex = path.length - 1;
|
|
2135
|
+
parent = path[parentIndex];
|
|
2136
|
+
indexOfFirstProperties = path.indexOf('properties');
|
|
2137
|
+
isRootProperties = parent === 'properties' && parentIndex === indexOfFirstProperties;
|
|
2138
|
+
traversed = specmap.allowMetaPatches && refCache[obj.$$ref];_i = 0, _Object$keys =
|
|
2139
|
+
|
|
2140
|
+
keys_default()(obj);case 12:if (!(_i < _Object$keys.length)) {_context.next = 30;break;}key = _Object$keys[_i];
|
|
2141
|
+
val = obj[key];
|
|
2142
|
+
updatedPath = path.concat(key);
|
|
2143
|
+
isObj = lib.isObject(val);
|
|
2144
|
+
objRef = obj.$$ref;if (
|
|
2145
|
+
|
|
2146
|
+
traversed) {_context.next = 22;break;}if (!
|
|
2147
|
+
isObj) {_context.next = 22;break;}
|
|
2148
|
+
// Only store the ref if it exists
|
|
2149
|
+
if (specmap.allowMetaPatches && objRef) {
|
|
2150
|
+
refCache[objRef] = true;
|
|
2151
|
+
}
|
|
2152
|
+
return _context.delegateYield(traverse(val, updatedPath, patch), "t0", 22);case 22:if (!(
|
|
2153
|
+
|
|
2154
|
+
|
|
2155
|
+
|
|
2156
|
+
!isRootProperties && key === pluginObj.key)) {_context.next = 27;break;}
|
|
2157
|
+
isWithinPathDiscriminator = isSubPath(pathDiscriminator, path);if (!(
|
|
2158
|
+
!pathDiscriminator || isWithinPathDiscriminator)) {_context.next = 27;break;}_context.next = 27;
|
|
2159
|
+
return pluginObj.plugin(val, key, updatedPath, specmap, patch);case 27:_i++;_context.next = 12;break;case 30:case "end":return _context.stop();}}}, _marked);};_marked = /*#__PURE__*/regenerator_default.a.mark(traverse);refCache = {};_iteratorNormalCompletion = true;_didIteratorError = false;_iteratorError = undefined;_context2.prev = 6;_iterator = get_iterator_default()(patches.filter(lib.isAdditiveMutation));case 8:if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {_context2.next = 14;break;}patch = _step.value;return _context2.delegateYield(traverse(patch.value, patch.path, patch), "t0", 11);case 11:_iteratorNormalCompletion = true;_context2.next = 8;break;case 14:_context2.next = 20;break;case 16:_context2.prev = 16;_context2.t1 = _context2["catch"](6);_didIteratorError = true;_iteratorError = _context2.t1;case 20:_context2.prev = 20;_context2.prev = 21;if (!_iteratorNormalCompletion && _iterator.return != null) {_iterator.return();}case 23:_context2.prev = 23;if (!_didIteratorError) {_context2.next = 26;break;}throw _iteratorError;case 26:return _context2.finish(23);case 27:return _context2.finish(20);case 28:case "end":return _context2.stop();}}}, _callee, null, [[6, 16, 20, 28], [21,, 23, 27]]);}));
|
|
2160
|
+
|
|
2161
|
+
|
|
2162
|
+
|
|
2163
|
+
|
|
2164
|
+
|
|
2165
|
+
|
|
2166
|
+
}
|
|
2167
|
+
} }, { key: "nextPlugin", value: function nextPlugin()
|
|
2168
|
+
|
|
2169
|
+
{var _this2 = this;
|
|
2170
|
+
// Array.prototype.find doesn't work in IE 11 :(
|
|
2171
|
+
return find_default()(this.wrappedPlugins, function (plugin) {
|
|
2172
|
+
var mutations = _this2.getMutationsForPlugin(plugin);
|
|
2173
|
+
return mutations.length > 0;
|
|
2174
|
+
});
|
|
2175
|
+
} }, { key: "nextPromisedPatch", value: function nextPromisedPatch()
|
|
2176
|
+
|
|
2177
|
+
{
|
|
2178
|
+
if (this.promisedPatches.length > 0) {
|
|
2179
|
+
return promise_default.a.race(this.promisedPatches.map(function (patch) {return patch.value;}));
|
|
2180
|
+
}
|
|
2181
|
+
} }, { key: "getPluginHistory", value: function getPluginHistory(
|
|
2182
|
+
|
|
2183
|
+
plugin) {
|
|
2184
|
+
var name = this.getPluginName(plugin);
|
|
2185
|
+
return this.pluginHistory[name] || [];
|
|
2186
|
+
} }, { key: "getPluginRunCount", value: function getPluginRunCount(
|
|
2187
|
+
|
|
2188
|
+
plugin) {
|
|
2189
|
+
return this.getPluginHistory(plugin).length;
|
|
2190
|
+
} }, { key: "getPluginHistoryTip", value: function getPluginHistoryTip(
|
|
2191
|
+
|
|
2192
|
+
plugin) {
|
|
2193
|
+
var history = this.getPluginHistory(plugin);
|
|
2194
|
+
var val = history && history[history.length - 1];
|
|
2195
|
+
return val || {};
|
|
2196
|
+
} }, { key: "getPluginMutationIndex", value: function getPluginMutationIndex(
|
|
2197
|
+
|
|
2198
|
+
plugin) {
|
|
2199
|
+
var mi = this.getPluginHistoryTip(plugin).mutationIndex;
|
|
2200
|
+
return typeof mi !== 'number' ? -1 : mi;
|
|
2201
|
+
} }, { key: "getPluginName", value: function getPluginName(
|
|
2202
|
+
|
|
2203
|
+
plugin) {
|
|
2204
|
+
return plugin.pluginName;
|
|
2205
|
+
} }, { key: "updatePluginHistory", value: function updatePluginHistory(
|
|
2206
|
+
|
|
2207
|
+
plugin, val) {
|
|
2208
|
+
var name = this.getPluginName(plugin);
|
|
2209
|
+
var history = this.pluginHistory[name] = this.pluginHistory[name] || [];
|
|
2210
|
+
history.push(val);
|
|
2211
|
+
} }, { key: "updatePatches", value: function updatePatches(
|
|
2212
|
+
|
|
2213
|
+
patches, plugin) {var _this3 = this;
|
|
2214
|
+
lib.normalizeArray(patches).forEach(function (patch) {
|
|
2215
|
+
if (patch instanceof Error) {
|
|
2216
|
+
_this3.errors.push(patch);
|
|
2217
|
+
return;
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
try {
|
|
2221
|
+
if (!lib.isObject(patch)) {
|
|
2222
|
+
_this3.debug('updatePatches', 'Got a non-object patch', patch);
|
|
2223
|
+
return;
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
if (_this3.showDebug) {
|
|
2227
|
+
_this3.allPatches.push(patch);
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
if (lib.isPromise(patch.value)) {
|
|
2231
|
+
_this3.promisedPatches.push(patch);
|
|
2232
|
+
_this3.promisedPatchThen(patch);
|
|
2233
|
+
return;
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
if (lib.isContextPatch(patch)) {
|
|
2237
|
+
_this3.setContext(patch.path, patch.value);
|
|
2238
|
+
return;
|
|
2239
|
+
}
|
|
2240
|
+
|
|
2241
|
+
if (lib.isMutation(patch)) {
|
|
2242
|
+
_this3.updateMutations(patch);
|
|
2243
|
+
return;
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
catch (e) {
|
|
2247
|
+
console.error(e); // eslint-disable-line no-console
|
|
2248
|
+
_this3.errors.push(e);
|
|
2249
|
+
}
|
|
2250
|
+
});
|
|
2251
|
+
} }, { key: "updateMutations", value: function updateMutations(
|
|
2252
|
+
|
|
2253
|
+
patch) {
|
|
2254
|
+
if (typeof_default()(patch.value) === 'object' && !is_array_default()(patch.value) && this.allowMetaPatches) {
|
|
2255
|
+
patch.value = object_assign_default()({}, patch.value);
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
var result = lib.applyPatch(this.state, patch, { allowMetaPatches: this.allowMetaPatches });
|
|
2259
|
+
if (result) {
|
|
2260
|
+
this.mutations.push(patch);
|
|
2261
|
+
this.state = result;
|
|
2262
|
+
}
|
|
2263
|
+
} }, { key: "removePromisedPatch", value: function removePromisedPatch(
|
|
2264
|
+
|
|
2265
|
+
patch) {
|
|
2266
|
+
var index = this.promisedPatches.indexOf(patch);
|
|
2267
|
+
if (index < 0) {
|
|
2268
|
+
this.debug('Tried to remove a promisedPatch that isn\'t there!');
|
|
2269
|
+
return;
|
|
2270
|
+
}
|
|
2271
|
+
this.promisedPatches.splice(index, 1);
|
|
2272
|
+
} }, { key: "promisedPatchThen", value: function promisedPatchThen(
|
|
2273
|
+
|
|
2274
|
+
patch) {var _this4 = this;
|
|
2275
|
+
var value = patch.value = patch.value.
|
|
2276
|
+
then(function (val) {
|
|
2277
|
+
var promisedPatch = object_assign_default()({}, patch, { value: val });
|
|
2278
|
+
_this4.removePromisedPatch(patch);
|
|
2279
|
+
_this4.updatePatches(promisedPatch);
|
|
2280
|
+
}).
|
|
2281
|
+
catch(function (e) {
|
|
2282
|
+
_this4.removePromisedPatch(patch);
|
|
2283
|
+
_this4.updatePatches(e);
|
|
2284
|
+
});
|
|
2285
|
+
return value;
|
|
2286
|
+
} }, { key: "getMutations", value: function getMutations(
|
|
2287
|
+
|
|
2288
|
+
from, to) {
|
|
2289
|
+
from = from || 0;
|
|
2290
|
+
if (typeof to !== 'number') {
|
|
2291
|
+
to = this.mutations.length;
|
|
2292
|
+
}
|
|
2293
|
+
return this.mutations.slice(from, to);
|
|
2294
|
+
} }, { key: "getCurrentMutations", value: function getCurrentMutations()
|
|
2295
|
+
|
|
2296
|
+
{
|
|
2297
|
+
return this.getMutationsForPlugin(this.getCurrentPlugin());
|
|
2298
|
+
} }, { key: "getMutationsForPlugin", value: function getMutationsForPlugin(
|
|
2299
|
+
|
|
2300
|
+
plugin) {
|
|
2301
|
+
var tip = this.getPluginMutationIndex(plugin);
|
|
2302
|
+
return this.getMutations(tip + 1);
|
|
2303
|
+
} }, { key: "getCurrentPlugin", value: function getCurrentPlugin()
|
|
2304
|
+
|
|
2305
|
+
{
|
|
2306
|
+
return this.currentPlugin;
|
|
2307
|
+
} }, { key: "getPatchesOfType", value: function getPatchesOfType(
|
|
2308
|
+
|
|
2309
|
+
patches, fn) {
|
|
2310
|
+
return patches.filter(fn);
|
|
2311
|
+
} }, { key: "getLib", value: function getLib()
|
|
2312
|
+
|
|
2313
|
+
{
|
|
2314
|
+
return this.libMethods;
|
|
2315
|
+
} }, { key: "_get", value: function _get(
|
|
2316
|
+
|
|
2317
|
+
path) {
|
|
2318
|
+
return lib.getIn(this.state, path);
|
|
2319
|
+
} }, { key: "_getContext", value: function _getContext(
|
|
2320
|
+
|
|
2321
|
+
path) {
|
|
2322
|
+
return this.contextTree.get(path);
|
|
2323
|
+
} }, { key: "setContext", value: function setContext(
|
|
2324
|
+
|
|
2325
|
+
path, value) {
|
|
2326
|
+
return this.contextTree.set(path, value);
|
|
2327
|
+
} }, { key: "_hasRun", value: function _hasRun(
|
|
2328
|
+
|
|
2329
|
+
count) {
|
|
2330
|
+
var times = this.getPluginRunCount(this.getCurrentPlugin());
|
|
2331
|
+
return times > (count || 0);
|
|
2332
|
+
} }, { key: "_clone", value: function _clone(
|
|
2333
|
+
|
|
2334
|
+
obj) {
|
|
2335
|
+
// For debugging only
|
|
2336
|
+
return JSON.parse(stringify_default()(obj));
|
|
2337
|
+
} }, { key: "dispatch", value: function dispatch()
|
|
2338
|
+
|
|
2339
|
+
{var _this5 = this;
|
|
2340
|
+
var that = this;
|
|
2341
|
+
var plugin = this.nextPlugin();
|
|
2342
|
+
|
|
2343
|
+
if (!plugin) {
|
|
2344
|
+
var nextPromise = this.nextPromisedPatch();
|
|
2345
|
+
if (nextPromise) {
|
|
2346
|
+
return nextPromise.
|
|
2347
|
+
then(function () {return _this5.dispatch();}).
|
|
2348
|
+
catch(function () {return _this5.dispatch();});
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
// We're done!
|
|
2352
|
+
var result = { spec: this.state, errors: this.errors };
|
|
2353
|
+
if (this.showDebug) {
|
|
2354
|
+
result.patches = this.allPatches;
|
|
2355
|
+
}
|
|
2356
|
+
return promise_default.a.resolve(result);
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
// Makes sure plugin isn't running an endless loop
|
|
2360
|
+
that.pluginCount = that.pluginCount || {};
|
|
2361
|
+
that.pluginCount[plugin] = (that.pluginCount[plugin] || 0) + 1;
|
|
2362
|
+
if (that.pluginCount[plugin] > HARD_LIMIT) {
|
|
2363
|
+
return promise_default.a.resolve({
|
|
2364
|
+
spec: that.state,
|
|
2365
|
+
errors: that.errors.concat(new Error("We've reached a hard limit of ".concat(HARD_LIMIT, " plugin runs"))) });
|
|
2366
|
+
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
// A different plugin runs, wait for all promises to resolve, then retry
|
|
2370
|
+
if (plugin !== this.currentPlugin && this.promisedPatches.length) {
|
|
2371
|
+
var promises = this.promisedPatches.map(function (p) {return p.value;});
|
|
2372
|
+
|
|
2373
|
+
// Waits for all to settle instead of Promise.all which stops on rejection
|
|
2374
|
+
return promise_default.a.all(promises.map(function (promise) {
|
|
2375
|
+
return promise.then(Function, Function);
|
|
2376
|
+
})).then(function () {return _this5.dispatch();});
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
// Ok, run the plugin
|
|
2380
|
+
return executePlugin();
|
|
2381
|
+
|
|
2382
|
+
function executePlugin() {
|
|
2383
|
+
that.currentPlugin = plugin;
|
|
2384
|
+
var mutations = that.getCurrentMutations();
|
|
2385
|
+
var lastMutationIndex = that.mutations.length - 1;
|
|
2386
|
+
|
|
2387
|
+
try {
|
|
2388
|
+
if (plugin.isGenerator) {var _iteratorNormalCompletion2 = true;var _didIteratorError2 = false;var _iteratorError2 = undefined;try {
|
|
2389
|
+
for (var _iterator2 = get_iterator_default()(plugin(mutations, that.getLib())), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {var yieldedPatches = _step2.value;
|
|
2390
|
+
updatePatches(yieldedPatches);
|
|
2391
|
+
}} catch (err) {_didIteratorError2 = true;_iteratorError2 = err;} finally {try {if (!_iteratorNormalCompletion2 && _iterator2.return != null) {_iterator2.return();}} finally {if (_didIteratorError2) {throw _iteratorError2;}}}
|
|
2392
|
+
} else
|
|
2393
|
+
{
|
|
2394
|
+
var newPatches = plugin(mutations, that.getLib());
|
|
2395
|
+
updatePatches(newPatches);
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
catch (e) {
|
|
2399
|
+
console.error(e); // eslint-disable-line no-console
|
|
2400
|
+
updatePatches([object_assign_default()(create_default()(e), { plugin: plugin })]);
|
|
2401
|
+
} finally
|
|
2402
|
+
{
|
|
2403
|
+
that.updatePluginHistory(plugin, { mutationIndex: lastMutationIndex });
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2406
|
+
return that.dispatch();
|
|
2407
|
+
}
|
|
2408
|
+
|
|
2409
|
+
function updatePatches(patches) {
|
|
2410
|
+
if (patches) {
|
|
2411
|
+
patches = lib.fullyNormalizeArray(patches);
|
|
2412
|
+
that.updatePatches(patches, plugin);
|
|
2413
|
+
}
|
|
2414
|
+
}
|
|
2415
|
+
} }]);return SpecMap;}();
|
|
2416
|
+
|
|
2417
|
+
|
|
2418
|
+
function mapSpec(opts) {
|
|
2419
|
+
return new specmap_SpecMap(opts).dispatch();
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
var plugins = { refs: refs, allOf: all_of, parameters: lib_parameters, properties: lib_properties };
|
|
2423
|
+
|
|
2424
|
+
// EXTERNAL MODULE: external "lodash/isObject"
|
|
2425
|
+
var isObject_ = __webpack_require__(29);
|
|
2426
|
+
var isObject_default = /*#__PURE__*/__webpack_require__.n(isObject_);
|
|
2427
|
+
|
|
2428
|
+
// CONCATENATED MODULE: ./src/helpers.js
|
|
2429
|
+
|
|
2430
|
+
|
|
2431
|
+
|
|
2432
|
+
var toLower = function toLower(str) {return String.prototype.toLowerCase.call(str);};
|
|
2433
|
+
var escapeString = function escapeString(str) {
|
|
2434
|
+
return str.replace(/[^\w]/gi, '_');
|
|
2435
|
+
};
|
|
2436
|
+
|
|
2437
|
+
// Spec version detection
|
|
2438
|
+
function isOAS3(spec) {
|
|
2439
|
+
var oasVersion = spec.openapi;
|
|
2440
|
+
if (!oasVersion) {
|
|
2441
|
+
return false;
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
return startsWith_default()(oasVersion, '3');
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
function isSwagger2(spec) {
|
|
2448
|
+
var swaggerVersion = spec.swagger;
|
|
2449
|
+
if (!swaggerVersion) {
|
|
2450
|
+
return false;
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
return startsWith_default()(swaggerVersion, '2');
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
// Strategy for determining operationId
|
|
2457
|
+
function opId(operation, pathName) {var method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';var _ref = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},v2OperationIdCompatibilityMode = _ref.v2OperationIdCompatibilityMode;
|
|
2458
|
+
if (!operation || typeof_default()(operation) !== 'object') {
|
|
2459
|
+
return null;
|
|
2460
|
+
}
|
|
2461
|
+
var idWithoutWhitespace = (operation.operationId || '').replace(/\s/g, '');
|
|
2462
|
+
if (idWithoutWhitespace.length) {
|
|
2463
|
+
return escapeString(operation.operationId);
|
|
2464
|
+
}
|
|
2465
|
+
return idFromPathMethod(pathName, method, { v2OperationIdCompatibilityMode: v2OperationIdCompatibilityMode });
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
|
|
2469
|
+
// Create a generated operationId from pathName + method
|
|
2470
|
+
function idFromPathMethod(pathName, method) {var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},v2OperationIdCompatibilityMode = _ref2.v2OperationIdCompatibilityMode;
|
|
2471
|
+
if (v2OperationIdCompatibilityMode) {
|
|
2472
|
+
var res = "".concat(method.toLowerCase(), "_").concat(pathName).
|
|
2473
|
+
replace(/[\s!@#$%^&*()_+=[{\]};:<>|./?,\\'""-]/g, '_');
|
|
2474
|
+
|
|
2475
|
+
res = res || "".concat(pathName.substring(1), "_").concat(method);
|
|
2476
|
+
|
|
2477
|
+
return res.
|
|
2478
|
+
replace(/((_){2,})/g, '_').
|
|
2479
|
+
replace(/^(_)*/g, '').
|
|
2480
|
+
replace(/([_])*$/g, '');
|
|
2481
|
+
}
|
|
2482
|
+
return "".concat(toLower(method)).concat(escapeString(pathName));
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
function legacyIdFromPathMethod(pathName, method) {
|
|
2486
|
+
return "".concat(toLower(method), "-").concat(pathName);
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2489
|
+
// Get the operation, based on operationId ( just return the object, no inheritence )
|
|
2490
|
+
function getOperationRaw(spec, id) {
|
|
2491
|
+
if (!spec || !spec.paths) {
|
|
2492
|
+
return null;
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2495
|
+
|
|
2496
|
+
return findOperation(spec, function (_ref3) {var pathName = _ref3.pathName,method = _ref3.method,operation = _ref3.operation;
|
|
2497
|
+
if (!operation || typeof_default()(operation) !== 'object') {
|
|
2498
|
+
return false;
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
var rawOperationId = operation.operationId; // straight from the source
|
|
2502
|
+
var operationId = opId(operation, pathName, method);
|
|
2503
|
+
var legacyOperationId = legacyIdFromPathMethod(pathName, method);
|
|
2504
|
+
|
|
2505
|
+
return [operationId, legacyOperationId, rawOperationId].
|
|
2506
|
+
some(function (val) {return val && val === id;});
|
|
2507
|
+
});
|
|
2508
|
+
}
|
|
2509
|
+
|
|
2510
|
+
// Will stop iterating over the operations and return the operationObj
|
|
2511
|
+
// as soon as predicate returns true
|
|
2512
|
+
function findOperation(spec, predicate) {
|
|
2513
|
+
return eachOperation(spec, predicate, true) || null;
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
// iterate over each operation, and fire a callback with details
|
|
2517
|
+
// `find=true` will stop iterating, when the cb returns truthy
|
|
2518
|
+
function eachOperation(spec, cb, find) {
|
|
2519
|
+
if (!spec || typeof_default()(spec) !== 'object' || !spec.paths || typeof_default()(spec.paths) !== 'object') {
|
|
2520
|
+
return null;
|
|
2521
|
+
}var
|
|
2522
|
+
|
|
2523
|
+
paths = spec.paths;
|
|
2524
|
+
|
|
2525
|
+
// Iterate over the spec, collecting operations
|
|
2526
|
+
for (var pathName in paths) {
|
|
2527
|
+
for (var method in paths[pathName]) {
|
|
2528
|
+
if (method.toUpperCase() === 'PARAMETERS') {
|
|
2529
|
+
continue;
|
|
2530
|
+
}
|
|
2531
|
+
var operation = paths[pathName][method];
|
|
2532
|
+
if (!operation || typeof_default()(operation) !== 'object') {
|
|
2533
|
+
continue;
|
|
2534
|
+
}
|
|
2535
|
+
|
|
2536
|
+
var operationObj = {
|
|
2537
|
+
spec: spec,
|
|
2538
|
+
pathName: pathName,
|
|
2539
|
+
method: method.toUpperCase(),
|
|
2540
|
+
operation: operation };
|
|
2541
|
+
|
|
2542
|
+
var cbValue = cb(operationObj);
|
|
2543
|
+
|
|
2544
|
+
if (find && cbValue) {
|
|
2545
|
+
return operationObj;
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
// REVIEW: OAS3: identify normalization steps that need changes
|
|
2552
|
+
// ...maybe create `normalizeOAS3`?
|
|
2553
|
+
|
|
2554
|
+
function normalizeSwagger(parsedSpec) {var
|
|
2555
|
+
spec = parsedSpec.spec;var
|
|
2556
|
+
paths = spec.paths;
|
|
2557
|
+
var map = {};
|
|
2558
|
+
|
|
2559
|
+
if (!paths || spec.$$normalized) {
|
|
2560
|
+
return parsedSpec;
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
for (var pathName in paths) {
|
|
2564
|
+
var path = paths[pathName];
|
|
2565
|
+
|
|
2566
|
+
if (!isObject_default()(path)) {
|
|
2567
|
+
continue;
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2570
|
+
var pathParameters = path.parameters;var _loop = function _loop(
|
|
2571
|
+
|
|
2572
|
+
method) {
|
|
2573
|
+
var operation = path[method];
|
|
2574
|
+
if (!isObject_default()(operation)) {
|
|
2575
|
+
return "continue";
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
var oid = opId(operation, pathName, method);
|
|
2579
|
+
|
|
2580
|
+
if (oid) {
|
|
2581
|
+
if (map[oid]) {
|
|
2582
|
+
map[oid].push(operation);
|
|
2583
|
+
} else
|
|
2584
|
+
{
|
|
2585
|
+
map[oid] = [operation];
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2588
|
+
var opList = map[oid];
|
|
2589
|
+
if (opList.length > 1) {
|
|
2590
|
+
opList.forEach(function (o, i) {
|
|
2591
|
+
o.__originalOperationId = o.__originalOperationId || o.operationId;
|
|
2592
|
+
o.operationId = "".concat(oid).concat(i + 1);
|
|
2593
|
+
});
|
|
2594
|
+
} else
|
|
2595
|
+
if (typeof operation.operationId !== 'undefined') {
|
|
2596
|
+
// Ensure we always add the normalized operation ID if one already exists
|
|
2597
|
+
// ( potentially different, given that we normalize our IDs)
|
|
2598
|
+
// ... _back_ to the spec. Otherwise, they might not line up
|
|
2599
|
+
var obj = opList[0];
|
|
2600
|
+
obj.__originalOperationId = obj.__originalOperationId || operation.operationId;
|
|
2601
|
+
obj.operationId = oid;
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
|
|
2605
|
+
if (method !== 'parameters') {
|
|
2606
|
+
// Add inherited consumes, produces, parameters, securities
|
|
2607
|
+
var inheritsList = [];
|
|
2608
|
+
var toBeInherit = {};
|
|
2609
|
+
|
|
2610
|
+
// Global-levels
|
|
2611
|
+
for (var key in spec) {
|
|
2612
|
+
if (key === 'produces' || key === 'consumes' || key === 'security') {
|
|
2613
|
+
toBeInherit[key] = spec[key];
|
|
2614
|
+
inheritsList.push(toBeInherit);
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
// Path-levels
|
|
2619
|
+
if (pathParameters) {
|
|
2620
|
+
toBeInherit.parameters = pathParameters;
|
|
2621
|
+
inheritsList.push(toBeInherit);
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
if (inheritsList.length) {
|
|
2625
|
+
for (var _i = 0, _inheritsList = inheritsList; _i < _inheritsList.length; _i++) {var inherits = _inheritsList[_i];
|
|
2626
|
+
for (var inheritName in inherits) {
|
|
2627
|
+
if (!operation[inheritName]) {
|
|
2628
|
+
operation[inheritName] = inherits[inheritName];
|
|
2629
|
+
} else
|
|
2630
|
+
if (inheritName === 'parameters') {var _iteratorNormalCompletion = true;var _didIteratorError = false;var _iteratorError = undefined;try {var _loop2 = function _loop2() {var
|
|
2631
|
+
param = _step.value;
|
|
2632
|
+
var exists = operation[inheritName].some(function (opParam) {
|
|
2633
|
+
return opParam.name && opParam.name === param.name ||
|
|
2634
|
+
opParam.$ref && opParam.$ref === param.$ref ||
|
|
2635
|
+
opParam.$$ref && opParam.$$ref === param.$$ref ||
|
|
2636
|
+
opParam === param;
|
|
2637
|
+
});
|
|
2638
|
+
|
|
2639
|
+
if (!exists) {
|
|
2640
|
+
operation[inheritName].push(param);
|
|
2641
|
+
}};for (var _iterator = get_iterator_default()(inherits[inheritName]), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {_loop2();
|
|
2642
|
+
}} catch (err) {_didIteratorError = true;_iteratorError = err;} finally {try {if (!_iteratorNormalCompletion && _iterator.return != null) {_iterator.return();}} finally {if (_didIteratorError) {throw _iteratorError;}}}
|
|
2643
|
+
}
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
}
|
|
2647
|
+
}};for (var method in path) {var _ret = _loop(method);if (_ret === "continue") continue;
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2651
|
+
spec.$$normalized = true;
|
|
2652
|
+
|
|
2653
|
+
return parsedSpec;
|
|
2654
|
+
}
|
|
2655
|
+
// CONCATENATED MODULE: ./src/resolver.js
|
|
2656
|
+
|
|
2657
|
+
|
|
2658
|
+
|
|
2659
|
+
|
|
2660
|
+
function makeFetchJSON(http) {var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};var
|
|
2661
|
+
requestInterceptor = opts.requestInterceptor,responseInterceptor = opts.responseInterceptor;
|
|
2662
|
+
// Set credentials with 'http.withCredentials' value
|
|
2663
|
+
var credentials = http.withCredentials ? 'include' : 'same-origin';
|
|
2664
|
+
return function (docPath) {
|
|
2665
|
+
return http({
|
|
2666
|
+
url: docPath,
|
|
2667
|
+
loadSpec: true,
|
|
2668
|
+
requestInterceptor: requestInterceptor,
|
|
2669
|
+
responseInterceptor: responseInterceptor,
|
|
2670
|
+
headers: {
|
|
2671
|
+
Accept: 'application/json' },
|
|
2672
|
+
|
|
2673
|
+
credentials: credentials }).
|
|
2674
|
+
|
|
2675
|
+
then(function (res) {
|
|
2676
|
+
return res.body;
|
|
2677
|
+
});
|
|
2678
|
+
};
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2681
|
+
// Wipe out the http cache
|
|
2682
|
+
function resolver_clearCache() {
|
|
2683
|
+
plugins.refs.clearCache();
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2686
|
+
function resolve(obj) {var
|
|
2687
|
+
|
|
2688
|
+
fetch =
|
|
2689
|
+
|
|
2690
|
+
|
|
2691
|
+
obj.fetch,spec = obj.spec,url = obj.url,mode = obj.mode,_obj$allowMetaPatches = obj.allowMetaPatches,allowMetaPatches = _obj$allowMetaPatches === void 0 ? true : _obj$allowMetaPatches,pathDiscriminator = obj.pathDiscriminator,modelPropertyMacro = obj.modelPropertyMacro,parameterMacro = obj.parameterMacro,requestInterceptor = obj.requestInterceptor,responseInterceptor = obj.responseInterceptor,skipNormalization = obj.skipNormalization,useCircularStructures = obj.useCircularStructures;var
|
|
2692
|
+
|
|
2693
|
+
http = obj.http,baseDoc = obj.baseDoc;
|
|
2694
|
+
|
|
2695
|
+
// @TODO Swagger-UI uses baseDoc instead of url, this is to allow both
|
|
2696
|
+
// need to fix and pick one.
|
|
2697
|
+
baseDoc = baseDoc || url;
|
|
2698
|
+
|
|
2699
|
+
// Provide a default fetch implementation
|
|
2700
|
+
// TODO fetch should be removed, and http used instead
|
|
2701
|
+
http = fetch || http || http_http;
|
|
2702
|
+
|
|
2703
|
+
if (!spec) {
|
|
2704
|
+
return makeFetchJSON(http, { requestInterceptor: requestInterceptor, responseInterceptor: responseInterceptor })(baseDoc).then(doResolve);
|
|
2705
|
+
}
|
|
2706
|
+
|
|
2707
|
+
return doResolve(spec);
|
|
2708
|
+
|
|
2709
|
+
function doResolve(_spec) {
|
|
2710
|
+
if (baseDoc) {
|
|
2711
|
+
plugins.refs.docCache[baseDoc] = _spec;
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
// Build a json-fetcher ( ie: give it a URL and get json out )
|
|
2715
|
+
plugins.refs.fetchJSON = makeFetchJSON(http, { requestInterceptor: requestInterceptor, responseInterceptor: responseInterceptor });
|
|
2716
|
+
|
|
2717
|
+
var plugs = [plugins.refs];
|
|
2718
|
+
|
|
2719
|
+
if (typeof parameterMacro === 'function') {
|
|
2720
|
+
plugs.push(plugins.parameters);
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
if (typeof modelPropertyMacro === 'function') {
|
|
2724
|
+
plugs.push(plugins.properties);
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2727
|
+
if (mode !== 'strict') {
|
|
2728
|
+
plugs.push(plugins.allOf);
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
// mapSpec is where the hard work happens, see https://github.com/swagger-api/specmap for more details
|
|
2732
|
+
return mapSpec({
|
|
2733
|
+
spec: _spec,
|
|
2734
|
+
context: { baseDoc: baseDoc },
|
|
2735
|
+
plugins: plugs,
|
|
2736
|
+
allowMetaPatches: allowMetaPatches, // allows adding .meta patches, which include adding `$$ref`s to the spec
|
|
2737
|
+
pathDiscriminator: pathDiscriminator, // for lazy resolution
|
|
2738
|
+
parameterMacro: parameterMacro,
|
|
2739
|
+
modelPropertyMacro: modelPropertyMacro,
|
|
2740
|
+
useCircularStructures: useCircularStructures }).
|
|
2741
|
+
then(skipNormalization ? /*#__PURE__*/function () {var _ref = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee(a) {return regenerator_default.a.wrap(function _callee$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:return _context.abrupt("return", a);case 1:case "end":return _context.stop();}}}, _callee);}));return function (_x) {return _ref.apply(this, arguments);};}() : normalizeSwagger);
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
// EXTERNAL MODULE: external "lodash/get"
|
|
2745
|
+
var get_ = __webpack_require__(16);
|
|
2746
|
+
var get_default = /*#__PURE__*/__webpack_require__.n(get_);
|
|
2747
|
+
|
|
2748
|
+
// CONCATENATED MODULE: ./src/subtree-resolver/index.js
|
|
2749
|
+
function subtree_resolver_ownKeys(object, enumerableOnly) {var keys = keys_default()(object);if (get_own_property_symbols_default.a) {var symbols = get_own_property_symbols_default()(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {return get_own_property_descriptor_default()(object, sym).enumerable;});keys.push.apply(keys, symbols);}return keys;}function subtree_resolver_objectSpread(target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {subtree_resolver_ownKeys(source, true).forEach(function (key) {defineProperty_default()(target, key, source[key]);});} else if (get_own_property_descriptors_default.a) {define_properties_default()(target, get_own_property_descriptors_default()(source));} else {subtree_resolver_ownKeys(source).forEach(function (key) {define_property_default()(target, key, get_own_property_descriptor_default()(source, key));});}}return target;} // The subtree resolver is a higher-level interface that allows you to
|
|
2750
|
+
// get the same result that you would from `Swagger.resolve`, but focuses on
|
|
2751
|
+
// a subtree of your object.
|
|
2752
|
+
//
|
|
2753
|
+
// It makes several assumptions that allow you to think less about what resolve,
|
|
2754
|
+
// specmap, and normalizeSwagger are doing: if this is not suitable for you,
|
|
2755
|
+
// you can emulate `resolveSubtree`'s behavior by talking to the traditional
|
|
2756
|
+
// resolver directly.
|
|
2757
|
+
//
|
|
2758
|
+
// By providing a top-level `obj` and a `path` to resolve within, the subtree
|
|
2759
|
+
// at `path` will be resolved and normalized in the context of your top-level
|
|
2760
|
+
// `obj`. You'll get the resolved subtree you're interest in as a return value
|
|
2761
|
+
// (or, you can use `returnEntireTree` to get everything back).
|
|
2762
|
+
//
|
|
2763
|
+
// This is useful for cases where resolving your entire object is unnecessary
|
|
2764
|
+
// and/or non-performant; we use this interface for lazily resolving operations
|
|
2765
|
+
// and models in Swagger-UI, which allows us to handle larger definitions.
|
|
2766
|
+
//
|
|
2767
|
+
// It's likely that Swagger-Client will rely entirely on lazy resolving in
|
|
2768
|
+
// future versions.
|
|
2769
|
+
//
|
|
2770
|
+
// TODO: move the remarks above into project documentation
|
|
2771
|
+
|
|
2772
|
+
|
|
2773
|
+
|
|
2774
|
+
|
|
2775
|
+
|
|
2776
|
+
|
|
2777
|
+
function resolveSubtree(_x, _x2) {return _resolveSubtree.apply(this, arguments);}function _resolveSubtree() {_resolveSubtree = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee(obj, path) {var opts,returnEntireTree,baseDoc,requestInterceptor,responseInterceptor,parameterMacro,modelPropertyMacro,useCircularStructures,resolveOptions,_normalizeSwagger,normalized,result,_args = arguments;return regenerator_default.a.wrap(function _callee$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
|
|
2778
|
+
|
|
2779
|
+
returnEntireTree =
|
|
2780
|
+
|
|
2781
|
+
|
|
2782
|
+
|
|
2783
|
+
|
|
2784
|
+
|
|
2785
|
+
|
|
2786
|
+
opts.returnEntireTree, baseDoc = opts.baseDoc, requestInterceptor = opts.requestInterceptor, responseInterceptor = opts.responseInterceptor, parameterMacro = opts.parameterMacro, modelPropertyMacro = opts.modelPropertyMacro, useCircularStructures = opts.useCircularStructures;
|
|
2787
|
+
|
|
2788
|
+
resolveOptions = {
|
|
2789
|
+
pathDiscriminator: path,
|
|
2790
|
+
baseDoc: baseDoc,
|
|
2791
|
+
requestInterceptor: requestInterceptor,
|
|
2792
|
+
responseInterceptor: responseInterceptor,
|
|
2793
|
+
parameterMacro: parameterMacro,
|
|
2794
|
+
modelPropertyMacro: modelPropertyMacro,
|
|
2795
|
+
useCircularStructures: useCircularStructures };_normalizeSwagger =
|
|
2796
|
+
|
|
2797
|
+
|
|
2798
|
+
normalizeSwagger({
|
|
2799
|
+
spec: obj }), normalized = _normalizeSwagger.spec;_context.next = 6;return (
|
|
2800
|
+
|
|
2801
|
+
|
|
2802
|
+
resolve(subtree_resolver_objectSpread({},
|
|
2803
|
+
resolveOptions, {
|
|
2804
|
+
spec: normalized,
|
|
2805
|
+
allowMetaPatches: true,
|
|
2806
|
+
skipNormalization: true })));case 6:result = _context.sent;
|
|
2807
|
+
|
|
2808
|
+
|
|
2809
|
+
if (!returnEntireTree && is_array_default()(path) && path.length) {
|
|
2810
|
+
result.spec = get_default()(result.spec, path) || null;
|
|
2811
|
+
}return _context.abrupt("return",
|
|
2812
|
+
|
|
2813
|
+
result);case 9:case "end":return _context.stop();}}}, _callee);}));return _resolveSubtree.apply(this, arguments);}
|
|
2814
|
+
// EXTERNAL MODULE: external "lodash/pick"
|
|
2815
|
+
var pick_ = __webpack_require__(38);
|
|
2816
|
+
var pick_default = /*#__PURE__*/__webpack_require__.n(pick_);
|
|
2817
|
+
|
|
2818
|
+
// CONCATENATED MODULE: ./src/interfaces.js
|
|
2819
|
+
function interfaces_ownKeys(object, enumerableOnly) {var keys = keys_default()(object);if (get_own_property_symbols_default.a) {var symbols = get_own_property_symbols_default()(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {return get_own_property_descriptor_default()(object, sym).enumerable;});keys.push.apply(keys, symbols);}return keys;}function interfaces_objectSpread(target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {interfaces_ownKeys(source, true).forEach(function (key) {defineProperty_default()(target, key, source[key]);});} else if (get_own_property_descriptors_default.a) {define_properties_default()(target, get_own_property_descriptors_default()(source));} else {interfaces_ownKeys(source).forEach(function (key) {define_property_default()(target, key, get_own_property_descriptor_default()(source, key));});}}return target;}
|
|
2820
|
+
|
|
2821
|
+
|
|
2822
|
+
var nullFn = function nullFn() {return null;};
|
|
2823
|
+
|
|
2824
|
+
var interfaces_normalizeArray = function normalizeArray(arg) {
|
|
2825
|
+
return is_array_default()(arg) ? arg : [arg];
|
|
2826
|
+
};
|
|
2827
|
+
|
|
2828
|
+
// To allow stubbing of functions
|
|
2829
|
+
var interfaces_self = {
|
|
2830
|
+
mapTagOperations: mapTagOperations,
|
|
2831
|
+
makeExecute: makeExecute
|
|
2832
|
+
|
|
2833
|
+
|
|
2834
|
+
// Make an execute, bound to arguments defined in mapTagOperation's callback (cb)
|
|
2835
|
+
};function makeExecute() {var swaggerJs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2836
|
+
return function (_ref) {var pathName = _ref.pathName,method = _ref.method,operationId = _ref.operationId;return function (parameters) {var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2837
|
+
return swaggerJs.execute(interfaces_objectSpread({
|
|
2838
|
+
spec: swaggerJs.spec },
|
|
2839
|
+
pick_default()(swaggerJs, 'requestInterceptor', 'responseInterceptor', 'userFetch'), {
|
|
2840
|
+
pathName: pathName,
|
|
2841
|
+
method: method,
|
|
2842
|
+
parameters: parameters,
|
|
2843
|
+
operationId: operationId },
|
|
2844
|
+
opts));
|
|
2845
|
+
|
|
2846
|
+
};};
|
|
2847
|
+
}
|
|
2848
|
+
|
|
2849
|
+
// Creates an interface with tags+operations = execute
|
|
2850
|
+
// The shape
|
|
2851
|
+
// { apis: { [tag]: { operations: [operation]: { execute }}}}
|
|
2852
|
+
// NOTE: this is mostly for compatibility
|
|
2853
|
+
function makeApisTagOperationsOperationExecute() {var swaggerJs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2854
|
+
// { apis: tag: operations: execute }
|
|
2855
|
+
var cb = interfaces_self.makeExecute(swaggerJs);
|
|
2856
|
+
var tagOperations = interfaces_self.mapTagOperations({
|
|
2857
|
+
v2OperationIdCompatibilityMode: swaggerJs.v2OperationIdCompatibilityMode,
|
|
2858
|
+
spec: swaggerJs.spec,
|
|
2859
|
+
cb: cb });
|
|
2860
|
+
|
|
2861
|
+
|
|
2862
|
+
var apis = {};
|
|
2863
|
+
for (var tag in tagOperations) {
|
|
2864
|
+
apis[tag] = {
|
|
2865
|
+
operations: {} };
|
|
2866
|
+
|
|
2867
|
+
for (var op in tagOperations[tag]) {
|
|
2868
|
+
apis[tag].operations[op] = { execute: tagOperations[tag][op] };
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2872
|
+
return { apis: apis };
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
// .apis[tag][operationId]:ExecuteFunction interface
|
|
2876
|
+
function makeApisTagOperation() {var swaggerJs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2877
|
+
var cb = interfaces_self.makeExecute(swaggerJs);
|
|
2878
|
+
return {
|
|
2879
|
+
apis: interfaces_self.mapTagOperations({
|
|
2880
|
+
v2OperationIdCompatibilityMode: swaggerJs.v2OperationIdCompatibilityMode,
|
|
2881
|
+
spec: swaggerJs.spec,
|
|
2882
|
+
cb: cb }) };
|
|
2883
|
+
|
|
2884
|
+
|
|
2885
|
+
}
|
|
2886
|
+
|
|
2887
|
+
/**
|
|
2888
|
+
* Iterates over a spec, creating a hash of {[tag]: { [operationId], ... }, ...}
|
|
2889
|
+
* with the value of calling `cb`.
|
|
2890
|
+
*
|
|
2891
|
+
* `spec` is a OAI v2.0 compliant specification object
|
|
2892
|
+
* `cb` is called with ({ spec, operation, path, method })
|
|
2893
|
+
* `defaultTag` will house all non-tagged operations
|
|
2894
|
+
*
|
|
2895
|
+
*/
|
|
2896
|
+
function mapTagOperations(_ref2) {var spec = _ref2.spec,_ref2$cb = _ref2.cb,cb = _ref2$cb === void 0 ? nullFn : _ref2$cb,_ref2$defaultTag = _ref2.defaultTag,defaultTag = _ref2$defaultTag === void 0 ? 'default' : _ref2$defaultTag,v2OperationIdCompatibilityMode = _ref2.v2OperationIdCompatibilityMode;
|
|
2897
|
+
var operationIdCounter = {};
|
|
2898
|
+
var tagOperations = {}; // Will house all tags + operations
|
|
2899
|
+
eachOperation(spec, function (_ref3) {var pathName = _ref3.pathName,method = _ref3.method,operation = _ref3.operation;
|
|
2900
|
+
var tags = operation.tags ? interfaces_normalizeArray(operation.tags) : [defaultTag];
|
|
2901
|
+
|
|
2902
|
+
tags.forEach(function (tag) {
|
|
2903
|
+
if (typeof tag !== 'string') {
|
|
2904
|
+
return;
|
|
2905
|
+
}
|
|
2906
|
+
var tagObj = tagOperations[tag] = tagOperations[tag] || {};
|
|
2907
|
+
var id = opId(operation, pathName, method, { v2OperationIdCompatibilityMode: v2OperationIdCompatibilityMode });
|
|
2908
|
+
var cbResult = cb({ spec: spec, pathName: pathName, method: method, operation: operation, operationId: id });
|
|
2909
|
+
|
|
2910
|
+
if (operationIdCounter[id]) {
|
|
2911
|
+
operationIdCounter[id]++;
|
|
2912
|
+
tagObj["".concat(id).concat(operationIdCounter[id])] = cbResult;
|
|
2913
|
+
} else
|
|
2914
|
+
if (typeof tagObj[id] !== 'undefined') {
|
|
2915
|
+
// Bump counter ( for this operationId )
|
|
2916
|
+
var originalCounterValue = operationIdCounter[id] || 1;
|
|
2917
|
+
operationIdCounter[id] = originalCounterValue + 1;
|
|
2918
|
+
// Append _x to the operationId
|
|
2919
|
+
tagObj["".concat(id).concat(operationIdCounter[id])] = cbResult;
|
|
2920
|
+
|
|
2921
|
+
// Rename the first operationId
|
|
2922
|
+
var temp = tagObj[id];
|
|
2923
|
+
delete tagObj[id];
|
|
2924
|
+
tagObj["".concat(id).concat(originalCounterValue)] = temp;
|
|
2925
|
+
} else
|
|
2926
|
+
{
|
|
2927
|
+
// Assign callback result ( usually a bound function )
|
|
2928
|
+
tagObj[id] = cbResult;
|
|
2929
|
+
}
|
|
2930
|
+
});
|
|
2931
|
+
});
|
|
2932
|
+
|
|
2933
|
+
return tagOperations;
|
|
2934
|
+
}
|
|
2935
|
+
// EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/objectWithoutProperties"
|
|
2936
|
+
var objectWithoutProperties_ = __webpack_require__(39);
|
|
2937
|
+
var objectWithoutProperties_default = /*#__PURE__*/__webpack_require__.n(objectWithoutProperties_);
|
|
2938
|
+
|
|
2939
|
+
// EXTERNAL MODULE: external "lodash/isPlainObject"
|
|
2940
|
+
var isPlainObject_ = __webpack_require__(40);
|
|
2941
|
+
var isPlainObject_default = /*#__PURE__*/__webpack_require__.n(isPlainObject_);
|
|
2942
|
+
|
|
2943
|
+
// EXTERNAL MODULE: external "lodash/isArray"
|
|
2944
|
+
var isArray_ = __webpack_require__(41);
|
|
2945
|
+
var isArray_default = /*#__PURE__*/__webpack_require__.n(isArray_);
|
|
2946
|
+
|
|
2947
|
+
// EXTERNAL MODULE: external "btoa"
|
|
2948
|
+
var external_btoa_ = __webpack_require__(19);
|
|
2949
|
+
var external_btoa_default = /*#__PURE__*/__webpack_require__.n(external_btoa_);
|
|
2950
|
+
|
|
2951
|
+
// EXTERNAL MODULE: external "cookie"
|
|
2952
|
+
var external_cookie_ = __webpack_require__(42);
|
|
2953
|
+
var external_cookie_default = /*#__PURE__*/__webpack_require__.n(external_cookie_);
|
|
2954
|
+
|
|
2955
|
+
// CONCATENATED MODULE: ./src/execute/swagger2/parameter-builders.js
|
|
2956
|
+
// These functions will update the request.
|
|
2957
|
+
// They'll be given {req, value, paramter, spec, operation}.
|
|
2958
|
+
|
|
2959
|
+
|
|
2960
|
+
/* harmony default export */ var parameter_builders = ({
|
|
2961
|
+
body: bodyBuilder,
|
|
2962
|
+
header: headerBuilder,
|
|
2963
|
+
query: queryBuilder,
|
|
2964
|
+
path: pathBuilder,
|
|
2965
|
+
formData: formDataBuilder
|
|
2966
|
+
|
|
2967
|
+
|
|
2968
|
+
|
|
2969
|
+
// Add the body to the request
|
|
2970
|
+
});function bodyBuilder(_ref) {var req = _ref.req,value = _ref.value;
|
|
2971
|
+
req.body = value;
|
|
2972
|
+
}
|
|
2973
|
+
|
|
2974
|
+
// Add a form data object.
|
|
2975
|
+
function formDataBuilder(_ref2) {var req = _ref2.req,value = _ref2.value,parameter = _ref2.parameter;
|
|
2976
|
+
if (value || parameter.allowEmptyValue) {
|
|
2977
|
+
req.form = req.form || {};
|
|
2978
|
+
req.form[parameter.name] = {
|
|
2979
|
+
value: value,
|
|
2980
|
+
allowEmptyValue: parameter.allowEmptyValue,
|
|
2981
|
+
collectionFormat: parameter.collectionFormat };
|
|
2982
|
+
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
|
|
2986
|
+
// Add a header to the request
|
|
2987
|
+
function headerBuilder(_ref3) {var req = _ref3.req,parameter = _ref3.parameter,value = _ref3.value;
|
|
2988
|
+
req.headers = req.headers || {};
|
|
2989
|
+
if (typeof value !== 'undefined') {
|
|
2990
|
+
req.headers[parameter.name] = value;
|
|
2991
|
+
}
|
|
2992
|
+
}
|
|
2993
|
+
|
|
2994
|
+
// Replace path paramters, with values ( ie: the URL )
|
|
2995
|
+
function pathBuilder(_ref4) {var req = _ref4.req,value = _ref4.value,parameter = _ref4.parameter;
|
|
2996
|
+
req.url = req.url.split("{".concat(parameter.name, "}")).join(encodeURIComponent(value));
|
|
2997
|
+
}
|
|
2998
|
+
|
|
2999
|
+
// Add a query to the `query` object, which will later be stringified into the URL's search
|
|
3000
|
+
function queryBuilder(_ref5) {var req = _ref5.req,value = _ref5.value,parameter = _ref5.parameter;
|
|
3001
|
+
req.query = req.query || {};
|
|
3002
|
+
|
|
3003
|
+
if (value === false && parameter.type === 'boolean') {
|
|
3004
|
+
value = 'false';
|
|
3005
|
+
}
|
|
3006
|
+
|
|
3007
|
+
if (value === 0 && ['number', 'integer'].indexOf(parameter.type) > -1) {
|
|
3008
|
+
value = '0';
|
|
3009
|
+
}
|
|
3010
|
+
|
|
3011
|
+
if (value) {
|
|
3012
|
+
req.query[parameter.name] = {
|
|
3013
|
+
collectionFormat: parameter.collectionFormat,
|
|
3014
|
+
value: value };
|
|
3015
|
+
|
|
3016
|
+
} else
|
|
3017
|
+
if (parameter.allowEmptyValue && value !== undefined) {
|
|
3018
|
+
var paramName = parameter.name;
|
|
3019
|
+
req.query[paramName] = req.query[paramName] || {};
|
|
3020
|
+
req.query[paramName].allowEmptyValue = true;
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
// EXTERNAL MODULE: external "encode-3986"
|
|
3024
|
+
var external_encode_3986_ = __webpack_require__(49);
|
|
3025
|
+
|
|
3026
|
+
// EXTERNAL MODULE: external "utf8-bytes"
|
|
3027
|
+
var external_utf8_bytes_ = __webpack_require__(43);
|
|
3028
|
+
var external_utf8_bytes_default = /*#__PURE__*/__webpack_require__.n(external_utf8_bytes_);
|
|
3029
|
+
|
|
3030
|
+
// EXTERNAL MODULE: external "utfstring"
|
|
3031
|
+
var external_utfstring_ = __webpack_require__(44);
|
|
3032
|
+
|
|
3033
|
+
// CONCATENATED MODULE: ./src/execute/oas3/style-serializer.js
|
|
3034
|
+
|
|
3035
|
+
|
|
3036
|
+
|
|
3037
|
+
|
|
3038
|
+
var isRfc3986Reserved = function isRfc3986Reserved(char) {return ':/?#[]@!$&\'()*+,;='.indexOf(char) > -1;};
|
|
3039
|
+
var isRrc3986Unreserved = function isRrc3986Unreserved(char) {
|
|
3040
|
+
return /^[a-z0-9\-._~]+$/i.test(char);
|
|
3041
|
+
};
|
|
3042
|
+
|
|
3043
|
+
function encodeDisallowedCharacters(str) {var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},escape = _ref.escape;var parse = arguments.length > 2 ? arguments[2] : undefined;
|
|
3044
|
+
if (typeof str === 'number') {
|
|
3045
|
+
str = str.toString();
|
|
3046
|
+
}
|
|
3047
|
+
if (typeof str !== 'string' || !str.length) {
|
|
3048
|
+
return str;
|
|
3049
|
+
}
|
|
3050
|
+
|
|
3051
|
+
if (!escape) {
|
|
3052
|
+
return str;
|
|
3053
|
+
}
|
|
3054
|
+
|
|
3055
|
+
if (parse) {
|
|
3056
|
+
return JSON.parse(str);
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
return Object(external_utfstring_["stringToCharArray"])(str).map(function (char) {
|
|
3060
|
+
if (isRrc3986Unreserved(char)) {
|
|
3061
|
+
return char;
|
|
3062
|
+
}
|
|
3063
|
+
|
|
3064
|
+
if (isRfc3986Reserved(char) && escape === 'unsafe') {
|
|
3065
|
+
return char;
|
|
3066
|
+
}
|
|
3067
|
+
|
|
3068
|
+
var encoded = (external_utf8_bytes_default()(char) || []).
|
|
3069
|
+
map(function (byte) {return "0".concat(byte.toString(16).toUpperCase()).slice(-2);}).
|
|
3070
|
+
map(function (encodedByte) {return "%".concat(encodedByte);}).
|
|
3071
|
+
join('');
|
|
3072
|
+
|
|
3073
|
+
return encoded;
|
|
3074
|
+
}).join('');
|
|
3075
|
+
}
|
|
3076
|
+
|
|
3077
|
+
function stylize(config) {var
|
|
3078
|
+
value = config.value;
|
|
3079
|
+
|
|
3080
|
+
if (is_array_default()(value)) {
|
|
3081
|
+
return encodeArray(config);
|
|
3082
|
+
} else
|
|
3083
|
+
if (typeof_default()(value) === 'object') {
|
|
3084
|
+
return encodeObject(config);
|
|
3085
|
+
}
|
|
3086
|
+
return encodePrimitive(config);
|
|
3087
|
+
}
|
|
3088
|
+
|
|
3089
|
+
function encodeArray(_ref2) {var key = _ref2.key,value = _ref2.value,style = _ref2.style,explode = _ref2.explode,escape = _ref2.escape;
|
|
3090
|
+
var valueEncoder = function valueEncoder(str) {return encodeDisallowedCharacters(str, {
|
|
3091
|
+
escape: escape });};
|
|
3092
|
+
|
|
3093
|
+
|
|
3094
|
+
if (style === 'simple') {
|
|
3095
|
+
return value.map(function (val) {return valueEncoder(val);}).join(',');
|
|
3096
|
+
}
|
|
3097
|
+
|
|
3098
|
+
if (style === 'label') {
|
|
3099
|
+
return ".".concat(value.map(function (val) {return valueEncoder(val);}).join('.'));
|
|
3100
|
+
}
|
|
3101
|
+
|
|
3102
|
+
if (style === 'matrix') {
|
|
3103
|
+
return value.map(function (val) {return valueEncoder(val);}).reduce(function (prev, curr) {
|
|
3104
|
+
if (!prev || explode) {
|
|
3105
|
+
return "".concat(prev || '', ";").concat(key, "=").concat(curr);
|
|
3106
|
+
}
|
|
3107
|
+
return "".concat(prev, ",").concat(curr);
|
|
3108
|
+
}, '');
|
|
3109
|
+
}
|
|
3110
|
+
|
|
3111
|
+
if (style === 'form') {
|
|
3112
|
+
var after = explode ? "&".concat(key, "=") : ',';
|
|
3113
|
+
return value.map(function (val) {return valueEncoder(val);}).join(after);
|
|
3114
|
+
}
|
|
3115
|
+
|
|
3116
|
+
if (style === 'spaceDelimited') {
|
|
3117
|
+
var _after = explode ? "".concat(key, "=") : '';
|
|
3118
|
+
return value.map(function (val) {return valueEncoder(val);}).join(" ".concat(_after));
|
|
3119
|
+
}
|
|
3120
|
+
|
|
3121
|
+
if (style === 'pipeDelimited') {
|
|
3122
|
+
var _after2 = explode ? "".concat(key, "=") : '';
|
|
3123
|
+
return value.map(function (val) {return valueEncoder(val);}).join("|".concat(_after2));
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
|
|
3127
|
+
function encodeObject(_ref3) {var key = _ref3.key,value = _ref3.value,style = _ref3.style,explode = _ref3.explode,escape = _ref3.escape;
|
|
3128
|
+
var valueEncoder = function valueEncoder(str) {return encodeDisallowedCharacters(str, {
|
|
3129
|
+
escape: escape });};
|
|
3130
|
+
|
|
3131
|
+
|
|
3132
|
+
var valueKeys = keys_default()(value);
|
|
3133
|
+
|
|
3134
|
+
if (style === 'simple') {
|
|
3135
|
+
return valueKeys.reduce(function (prev, curr) {
|
|
3136
|
+
var val = valueEncoder(value[curr]);
|
|
3137
|
+
var middleChar = explode ? '=' : ',';
|
|
3138
|
+
var prefix = prev ? "".concat(prev, ",") : '';
|
|
3139
|
+
|
|
3140
|
+
return "".concat(prefix).concat(curr).concat(middleChar).concat(val);
|
|
3141
|
+
}, '');
|
|
3142
|
+
}
|
|
3143
|
+
|
|
3144
|
+
if (style === 'label') {
|
|
3145
|
+
return valueKeys.reduce(function (prev, curr) {
|
|
3146
|
+
var val = valueEncoder(value[curr]);
|
|
3147
|
+
var middleChar = explode ? '=' : '.';
|
|
3148
|
+
var prefix = prev ? "".concat(prev, ".") : '.';
|
|
3149
|
+
|
|
3150
|
+
return "".concat(prefix).concat(curr).concat(middleChar).concat(val);
|
|
3151
|
+
}, '');
|
|
3152
|
+
}
|
|
3153
|
+
|
|
3154
|
+
if (style === 'matrix' && explode) {
|
|
3155
|
+
return valueKeys.reduce(function (prev, curr) {
|
|
3156
|
+
var val = valueEncoder(value[curr]);
|
|
3157
|
+
var prefix = prev ? "".concat(prev, ";") : ';';
|
|
3158
|
+
|
|
3159
|
+
return "".concat(prefix).concat(curr, "=").concat(val);
|
|
3160
|
+
}, '');
|
|
3161
|
+
}
|
|
3162
|
+
|
|
3163
|
+
if (style === 'matrix') {
|
|
3164
|
+
// no explode
|
|
3165
|
+
return valueKeys.reduce(function (prev, curr) {
|
|
3166
|
+
var val = valueEncoder(value[curr]);
|
|
3167
|
+
var prefix = prev ? "".concat(prev, ",") : ";".concat(key, "=");
|
|
3168
|
+
|
|
3169
|
+
return "".concat(prefix).concat(curr, ",").concat(val);
|
|
3170
|
+
}, '');
|
|
3171
|
+
}
|
|
3172
|
+
|
|
3173
|
+
if (style === 'form') {
|
|
3174
|
+
return valueKeys.reduce(function (prev, curr) {
|
|
3175
|
+
var val = valueEncoder(value[curr]);
|
|
3176
|
+
var prefix = prev ? "".concat(prev).concat(explode ? '&' : ',') : '';
|
|
3177
|
+
var separator = explode ? '=' : ',';
|
|
3178
|
+
|
|
3179
|
+
return "".concat(prefix).concat(curr).concat(separator).concat(val);
|
|
3180
|
+
}, '');
|
|
3181
|
+
}
|
|
3182
|
+
}
|
|
3183
|
+
|
|
3184
|
+
function encodePrimitive(_ref4) {var key = _ref4.key,value = _ref4.value,style = _ref4.style,escape = _ref4.escape;
|
|
3185
|
+
var valueEncoder = function valueEncoder(str) {return encodeDisallowedCharacters(str, {
|
|
3186
|
+
escape: escape });};
|
|
3187
|
+
|
|
3188
|
+
|
|
3189
|
+
if (style === 'simple') {
|
|
3190
|
+
return valueEncoder(value);
|
|
3191
|
+
}
|
|
3192
|
+
|
|
3193
|
+
if (style === 'label') {
|
|
3194
|
+
return ".".concat(valueEncoder(value));
|
|
3195
|
+
}
|
|
3196
|
+
|
|
3197
|
+
if (style === 'matrix') {
|
|
3198
|
+
return ";".concat(key, "=").concat(valueEncoder(value));
|
|
3199
|
+
}
|
|
3200
|
+
|
|
3201
|
+
if (style === 'form') {
|
|
3202
|
+
return valueEncoder(value);
|
|
3203
|
+
}
|
|
3204
|
+
|
|
3205
|
+
if (style === 'deepObject') {
|
|
3206
|
+
return valueEncoder(value, {}, true);
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
// CONCATENATED MODULE: ./src/execute/oas3/content-serializer.js
|
|
3210
|
+
/*
|
|
3211
|
+
Serializer that serializes according to a media type instead of OpenAPI's
|
|
3212
|
+
`style` + `explode` constructs.
|
|
3213
|
+
*/
|
|
3214
|
+
|
|
3215
|
+
function serialize(value, mediaType) {
|
|
3216
|
+
if (mediaType.includes('application/json')) {
|
|
3217
|
+
if (typeof value === 'string') {
|
|
3218
|
+
// Assume the user has a JSON string
|
|
3219
|
+
return value;
|
|
3220
|
+
}
|
|
3221
|
+
return stringify_default()(value);
|
|
3222
|
+
}
|
|
3223
|
+
|
|
3224
|
+
return value.toString();
|
|
3225
|
+
}
|
|
3226
|
+
// CONCATENATED MODULE: ./src/execute/oas3/parameter-builders.js
|
|
3227
|
+
|
|
3228
|
+
|
|
3229
|
+
|
|
3230
|
+
function parameter_builders_path(_ref) {var req = _ref.req,value = _ref.value,parameter = _ref.parameter;var
|
|
3231
|
+
name = parameter.name,style = parameter.style,explode = parameter.explode,content = parameter.content;
|
|
3232
|
+
|
|
3233
|
+
if (content) {
|
|
3234
|
+
var effectiveMediaType = keys_default()(content)[0];
|
|
3235
|
+
|
|
3236
|
+
req.url = req.url.split("{".concat(name, "}")).join(
|
|
3237
|
+
encodeDisallowedCharacters(
|
|
3238
|
+
serialize(value, effectiveMediaType),
|
|
3239
|
+
{ escape: true }));
|
|
3240
|
+
|
|
3241
|
+
|
|
3242
|
+
return;
|
|
3243
|
+
}
|
|
3244
|
+
|
|
3245
|
+
var styledValue = stylize({
|
|
3246
|
+
key: parameter.name,
|
|
3247
|
+
value: value,
|
|
3248
|
+
style: style || 'simple',
|
|
3249
|
+
explode: explode || false,
|
|
3250
|
+
escape: true });
|
|
3251
|
+
|
|
3252
|
+
|
|
3253
|
+
req.url = req.url.split("{".concat(name, "}")).join(styledValue);
|
|
3254
|
+
}
|
|
3255
|
+
|
|
3256
|
+
function parameter_builders_query(_ref2) {var req = _ref2.req,value = _ref2.value,parameter = _ref2.parameter;
|
|
3257
|
+
req.query = req.query || {};
|
|
3258
|
+
|
|
3259
|
+
if (parameter.content) {
|
|
3260
|
+
var effectiveMediaType = keys_default()(parameter.content)[0];
|
|
3261
|
+
|
|
3262
|
+
req.query[parameter.name] = serialize(value, effectiveMediaType);
|
|
3263
|
+
return;
|
|
3264
|
+
}
|
|
3265
|
+
|
|
3266
|
+
if (value === false) {
|
|
3267
|
+
value = 'false';
|
|
3268
|
+
}
|
|
3269
|
+
|
|
3270
|
+
if (value === 0) {
|
|
3271
|
+
value = '0';
|
|
3272
|
+
}
|
|
3273
|
+
|
|
3274
|
+
if (value) {
|
|
3275
|
+
var type = typeof_default()(value);
|
|
3276
|
+
|
|
3277
|
+
if (parameter.style === 'deepObject') {
|
|
3278
|
+
var valueKeys = keys_default()(value);
|
|
3279
|
+
valueKeys.forEach(function (k) {
|
|
3280
|
+
var v = value[k];
|
|
3281
|
+
req.query["".concat(parameter.name, "[").concat(k, "]")] = {
|
|
3282
|
+
value: stylize({
|
|
3283
|
+
key: k,
|
|
3284
|
+
value: v,
|
|
3285
|
+
style: 'deepObject',
|
|
3286
|
+
escape: parameter.allowReserved ? 'unsafe' : 'reserved' }),
|
|
3287
|
+
|
|
3288
|
+
skipEncoding: true };
|
|
3289
|
+
|
|
3290
|
+
});
|
|
3291
|
+
} else
|
|
3292
|
+
if (
|
|
3293
|
+
type === 'object' &&
|
|
3294
|
+
!is_array_default()(value) && (
|
|
3295
|
+
parameter.style === 'form' || !parameter.style) && (
|
|
3296
|
+
parameter.explode || parameter.explode === undefined))
|
|
3297
|
+
{
|
|
3298
|
+
// form explode needs to be handled here,
|
|
3299
|
+
// since we aren't assigning to `req.query[parameter.name]`
|
|
3300
|
+
// like we usually do.
|
|
3301
|
+
var _valueKeys = keys_default()(value);
|
|
3302
|
+
_valueKeys.forEach(function (k) {
|
|
3303
|
+
var v = value[k];
|
|
3304
|
+
req.query[k] = {
|
|
3305
|
+
value: stylize({
|
|
3306
|
+
key: k,
|
|
3307
|
+
value: v,
|
|
3308
|
+
style: parameter.style || 'form',
|
|
3309
|
+
escape: parameter.allowReserved ? 'unsafe' : 'reserved' }),
|
|
3310
|
+
|
|
3311
|
+
skipEncoding: true };
|
|
3312
|
+
|
|
3313
|
+
});
|
|
3314
|
+
} else
|
|
3315
|
+
{
|
|
3316
|
+
req.query[parameter.name] = {
|
|
3317
|
+
value: stylize({
|
|
3318
|
+
key: parameter.name,
|
|
3319
|
+
value: value,
|
|
3320
|
+
style: parameter.style || 'form',
|
|
3321
|
+
explode: typeof parameter.explode === 'undefined' ? true : parameter.explode,
|
|
3322
|
+
escape: parameter.allowReserved ? 'unsafe' : 'reserved' }),
|
|
3323
|
+
|
|
3324
|
+
skipEncoding: true };
|
|
3325
|
+
|
|
3326
|
+
}
|
|
3327
|
+
} else
|
|
3328
|
+
if (parameter.allowEmptyValue && value !== undefined) {
|
|
3329
|
+
var paramName = parameter.name;
|
|
3330
|
+
req.query[paramName] = req.query[paramName] || {};
|
|
3331
|
+
req.query[paramName].allowEmptyValue = true;
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
|
|
3335
|
+
var PARAMETER_HEADER_BLACKLIST = [
|
|
3336
|
+
'accept',
|
|
3337
|
+
'authorization',
|
|
3338
|
+
'content-type'];
|
|
3339
|
+
|
|
3340
|
+
|
|
3341
|
+
function parameter_builders_header(_ref3) {var req = _ref3.req,parameter = _ref3.parameter,value = _ref3.value;
|
|
3342
|
+
req.headers = req.headers || {};
|
|
3343
|
+
|
|
3344
|
+
if (PARAMETER_HEADER_BLACKLIST.indexOf(parameter.name.toLowerCase()) > -1) {
|
|
3345
|
+
return;
|
|
3346
|
+
}
|
|
3347
|
+
|
|
3348
|
+
if (parameter.content) {
|
|
3349
|
+
var effectiveMediaType = keys_default()(parameter.content)[0];
|
|
3350
|
+
|
|
3351
|
+
req.headers[parameter.name] = serialize(value, effectiveMediaType);
|
|
3352
|
+
return;
|
|
3353
|
+
}
|
|
3354
|
+
|
|
3355
|
+
if (typeof value !== 'undefined') {
|
|
3356
|
+
req.headers[parameter.name] = stylize({
|
|
3357
|
+
key: parameter.name,
|
|
3358
|
+
value: value,
|
|
3359
|
+
style: parameter.style || 'simple',
|
|
3360
|
+
explode: typeof parameter.explode === 'undefined' ? false : parameter.explode,
|
|
3361
|
+
escape: false });
|
|
3362
|
+
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
|
|
3366
|
+
function cookie(_ref4) {var req = _ref4.req,parameter = _ref4.parameter,value = _ref4.value;
|
|
3367
|
+
req.headers = req.headers || {};
|
|
3368
|
+
var type = typeof_default()(value);
|
|
3369
|
+
|
|
3370
|
+
if (parameter.content) {
|
|
3371
|
+
var effectiveMediaType = keys_default()(parameter.content)[0];
|
|
3372
|
+
|
|
3373
|
+
req.headers.Cookie = "".concat(parameter.name, "=").concat(serialize(value, effectiveMediaType));
|
|
3374
|
+
return;
|
|
3375
|
+
}
|
|
3376
|
+
|
|
3377
|
+
if (type !== 'undefined') {
|
|
3378
|
+
var prefix =
|
|
3379
|
+
type === 'object' &&
|
|
3380
|
+
!is_array_default()(value) &&
|
|
3381
|
+
parameter.explode ?
|
|
3382
|
+
'' : "".concat(parameter.name, "=");
|
|
3383
|
+
|
|
3384
|
+
req.headers.Cookie = prefix + stylize({
|
|
3385
|
+
key: parameter.name,
|
|
3386
|
+
value: value,
|
|
3387
|
+
escape: false,
|
|
3388
|
+
style: parameter.style || 'form',
|
|
3389
|
+
explode: typeof parameter.explode === 'undefined' ? false : parameter.explode });
|
|
3390
|
+
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
// EXTERNAL MODULE: external "buffer/"
|
|
3394
|
+
var _ = __webpack_require__(30);
|
|
3395
|
+
|
|
3396
|
+
// CONCATENATED MODULE: ./src/execute/oas3/build-request.js
|
|
3397
|
+
// This function runs after the common function,
|
|
3398
|
+
// `src/execute/index.js#buildRequest`
|
|
3399
|
+
|
|
3400
|
+
|
|
3401
|
+
|
|
3402
|
+
|
|
3403
|
+
|
|
3404
|
+
/* harmony default export */ var build_request = (function (options, req) {var
|
|
3405
|
+
|
|
3406
|
+
operation =
|
|
3407
|
+
|
|
3408
|
+
|
|
3409
|
+
|
|
3410
|
+
|
|
3411
|
+
options.operation,requestBody = options.requestBody,securities = options.securities,spec = options.spec,attachContentTypeForEmptyPayload = options.attachContentTypeForEmptyPayload;var
|
|
3412
|
+
|
|
3413
|
+
|
|
3414
|
+
requestContentType =
|
|
3415
|
+
options.requestContentType;
|
|
3416
|
+
|
|
3417
|
+
req = applySecurities({ request: req, securities: securities, operation: operation, spec: spec });
|
|
3418
|
+
|
|
3419
|
+
var requestBodyDef = operation.requestBody || {};
|
|
3420
|
+
var requestBodyMediaTypes = keys_default()(requestBodyDef.content || {});
|
|
3421
|
+
var isExplicitContentTypeValid = requestContentType &&
|
|
3422
|
+
requestBodyMediaTypes.indexOf(requestContentType) > -1;
|
|
3423
|
+
|
|
3424
|
+
// for OAS3: set the Content-Type
|
|
3425
|
+
if (requestBody || attachContentTypeForEmptyPayload) {
|
|
3426
|
+
// does the passed requestContentType appear in the requestBody definition?
|
|
3427
|
+
|
|
3428
|
+
if (requestContentType && isExplicitContentTypeValid) {
|
|
3429
|
+
req.headers['Content-Type'] = requestContentType;
|
|
3430
|
+
} else
|
|
3431
|
+
if (!requestContentType) {
|
|
3432
|
+
var firstMediaType = requestBodyMediaTypes[0];
|
|
3433
|
+
if (firstMediaType) {
|
|
3434
|
+
req.headers['Content-Type'] = firstMediaType;
|
|
3435
|
+
requestContentType = firstMediaType;
|
|
3436
|
+
}
|
|
3437
|
+
}
|
|
3438
|
+
} else
|
|
3439
|
+
if (requestContentType && isExplicitContentTypeValid) {
|
|
3440
|
+
req.headers['Content-Type'] = requestContentType;
|
|
3441
|
+
}
|
|
3442
|
+
|
|
3443
|
+
// for OAS3: add requestBody to request
|
|
3444
|
+
if (requestBody) {
|
|
3445
|
+
if (requestContentType) {
|
|
3446
|
+
if (requestBodyMediaTypes.indexOf(requestContentType) > -1) {
|
|
3447
|
+
// only attach body if the requestBody has a definition for the
|
|
3448
|
+
// contentType that has been explicitly set
|
|
3449
|
+
if (requestContentType === 'application/x-www-form-urlencoded' || requestContentType.indexOf('multipart/') === 0) {
|
|
3450
|
+
if (typeof_default()(requestBody) === 'object') {
|
|
3451
|
+
req.form = {};
|
|
3452
|
+
keys_default()(requestBody).forEach(function (k) {
|
|
3453
|
+
var val = requestBody[k];
|
|
3454
|
+
var newVal;
|
|
3455
|
+
|
|
3456
|
+
var isFile;
|
|
3457
|
+
|
|
3458
|
+
if (typeof File !== 'undefined') {
|
|
3459
|
+
isFile = val instanceof File; // eslint-disable-line no-undef
|
|
3460
|
+
}
|
|
3461
|
+
|
|
3462
|
+
if (typeof Blob !== 'undefined') {
|
|
3463
|
+
isFile = isFile || val instanceof Blob; // eslint-disable-line no-undef
|
|
3464
|
+
}
|
|
3465
|
+
|
|
3466
|
+
if (typeof _["Buffer"] !== 'undefined') {
|
|
3467
|
+
isFile = isFile || _["Buffer"].isBuffer(val);
|
|
3468
|
+
}
|
|
3469
|
+
|
|
3470
|
+
if (typeof_default()(val) === 'object' && !isFile) {
|
|
3471
|
+
if (is_array_default()(val)) {
|
|
3472
|
+
newVal = val.toString();
|
|
3473
|
+
} else
|
|
3474
|
+
{
|
|
3475
|
+
newVal = stringify_default()(val);
|
|
3476
|
+
}
|
|
3477
|
+
} else
|
|
3478
|
+
{
|
|
3479
|
+
newVal = val;
|
|
3480
|
+
}
|
|
3481
|
+
|
|
3482
|
+
req.form[k] = {
|
|
3483
|
+
value: newVal };
|
|
3484
|
+
|
|
3485
|
+
});
|
|
3486
|
+
} else
|
|
3487
|
+
{
|
|
3488
|
+
req.form = requestBody;
|
|
3489
|
+
}
|
|
3490
|
+
} else
|
|
3491
|
+
{
|
|
3492
|
+
req.body = requestBody;
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3495
|
+
} else
|
|
3496
|
+
{
|
|
3497
|
+
req.body = requestBody;
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
|
|
3501
|
+
return req;
|
|
3502
|
+
});
|
|
3503
|
+
|
|
3504
|
+
// Add security values, to operations - that declare their need on them
|
|
3505
|
+
// Adapted from the Swagger2 implementation
|
|
3506
|
+
function applySecurities(_ref) {var request = _ref.request,_ref$securities = _ref.securities,securities = _ref$securities === void 0 ? {} : _ref$securities,_ref$operation = _ref.operation,operation = _ref$operation === void 0 ? {} : _ref$operation,spec = _ref.spec;
|
|
3507
|
+
var result = assign_default()({}, request);var _securities$authorize =
|
|
3508
|
+
securities.authorized,authorized = _securities$authorize === void 0 ? {} : _securities$authorize;
|
|
3509
|
+
var security = operation.security || spec.security || [];
|
|
3510
|
+
var isAuthorized = authorized && !!keys_default()(authorized).length;
|
|
3511
|
+
var securityDef = get_default()(spec, ['components', 'securitySchemes']) || {};
|
|
3512
|
+
|
|
3513
|
+
result.headers = result.headers || {};
|
|
3514
|
+
result.query = result.query || {};
|
|
3515
|
+
|
|
3516
|
+
if (!keys_default()(securities).length || !isAuthorized || !security ||
|
|
3517
|
+
is_array_default()(operation.security) && !operation.security.length) {
|
|
3518
|
+
return request;
|
|
3519
|
+
}
|
|
3520
|
+
|
|
3521
|
+
security.forEach(function (securityObj, index) {
|
|
3522
|
+
for (var key in securityObj) {
|
|
3523
|
+
var auth = authorized[key];
|
|
3524
|
+
var schema = securityDef[key];
|
|
3525
|
+
|
|
3526
|
+
if (!auth) {
|
|
3527
|
+
continue;
|
|
3528
|
+
}
|
|
3529
|
+
|
|
3530
|
+
var value = auth.value || auth;var
|
|
3531
|
+
type = schema.type;
|
|
3532
|
+
|
|
3533
|
+
if (auth) {
|
|
3534
|
+
if (type === 'apiKey') {
|
|
3535
|
+
if (schema.in === 'query') {
|
|
3536
|
+
result.query[schema.name] = value;
|
|
3537
|
+
}
|
|
3538
|
+
if (schema.in === 'header') {
|
|
3539
|
+
result.headers[schema.name] = value;
|
|
3540
|
+
}
|
|
3541
|
+
if (schema.in === 'cookie') {
|
|
3542
|
+
result.cookies[schema.name] = value;
|
|
3543
|
+
}
|
|
3544
|
+
} else
|
|
3545
|
+
if (type === 'http') {
|
|
3546
|
+
if (schema.scheme === 'basic') {var
|
|
3547
|
+
username = value.username,password = value.password;
|
|
3548
|
+
var encoded = external_btoa_default()("".concat(username, ":").concat(password));
|
|
3549
|
+
result.headers.Authorization = "Basic ".concat(encoded);
|
|
3550
|
+
}
|
|
3551
|
+
|
|
3552
|
+
if (schema.scheme === 'bearer') {
|
|
3553
|
+
result.headers.Authorization = "Bearer ".concat(value);
|
|
3554
|
+
}
|
|
3555
|
+
} else
|
|
3556
|
+
if (type === 'oauth2') {
|
|
3557
|
+
var token = auth.token || {};
|
|
3558
|
+
var accessToken = token.access_token;
|
|
3559
|
+
var tokenType = token.token_type;
|
|
3560
|
+
|
|
3561
|
+
if (!tokenType || tokenType.toLowerCase() === 'bearer') {
|
|
3562
|
+
tokenType = 'Bearer';
|
|
3563
|
+
}
|
|
3564
|
+
|
|
3565
|
+
result.headers.Authorization = "".concat(tokenType, " ").concat(accessToken);
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
});
|
|
3570
|
+
|
|
3571
|
+
return result;
|
|
3572
|
+
}
|
|
3573
|
+
// CONCATENATED MODULE: ./src/execute/swagger2/build-request.js
|
|
3574
|
+
// This function runs after the common function,
|
|
3575
|
+
// `src/execute/index.js#buildRequest`
|
|
3576
|
+
|
|
3577
|
+
|
|
3578
|
+
|
|
3579
|
+
|
|
3580
|
+
|
|
3581
|
+
|
|
3582
|
+
/* harmony default export */ var swagger2_build_request = (function (options, req) {var
|
|
3583
|
+
|
|
3584
|
+
spec =
|
|
3585
|
+
|
|
3586
|
+
|
|
3587
|
+
|
|
3588
|
+
|
|
3589
|
+
options.spec,operation = options.operation,securities = options.securities,requestContentType = options.requestContentType,attachContentTypeForEmptyPayload = options.attachContentTypeForEmptyPayload;
|
|
3590
|
+
// Add securities, which are applicable
|
|
3591
|
+
req = build_request_applySecurities({ request: req, securities: securities, operation: operation, spec: spec });
|
|
3592
|
+
|
|
3593
|
+
if (req.body || req.form || attachContentTypeForEmptyPayload) {
|
|
3594
|
+
// all following conditionals are Swagger2 only
|
|
3595
|
+
if (requestContentType) {
|
|
3596
|
+
req.headers['Content-Type'] = requestContentType;
|
|
3597
|
+
} else
|
|
3598
|
+
if (is_array_default()(operation.consumes)) {
|
|
3599
|
+
req.headers['Content-Type'] = operation.consumes[0];
|
|
3600
|
+
} else
|
|
3601
|
+
if (is_array_default()(spec.consumes)) {
|
|
3602
|
+
req.headers['Content-Type'] = spec.consumes[0];
|
|
3603
|
+
} else
|
|
3604
|
+
if (operation.parameters && operation.parameters.filter(function (p) {return p.type === 'file';}).length) {
|
|
3605
|
+
req.headers['Content-Type'] = 'multipart/form-data';
|
|
3606
|
+
} else
|
|
3607
|
+
if (operation.parameters && operation.parameters.filter(function (p) {return p.in === 'formData';}).length) {
|
|
3608
|
+
req.headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
3609
|
+
}
|
|
3610
|
+
} else
|
|
3611
|
+
if (requestContentType) {
|
|
3612
|
+
var isBodyParamPresent = operation.parameters && operation.parameters.filter(function (p) {return p.in === 'body';}).length > 0;
|
|
3613
|
+
var isFormDataParamPresent = operation.parameters && operation.parameters.filter(function (p) {return p.in === 'formData';}).length > 0;
|
|
3614
|
+
if (isBodyParamPresent || isFormDataParamPresent) {
|
|
3615
|
+
req.headers['Content-Type'] = requestContentType;
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
|
|
3619
|
+
return req;
|
|
3620
|
+
});
|
|
3621
|
+
|
|
3622
|
+
// Add security values, to operations - that declare their need on them
|
|
3623
|
+
function build_request_applySecurities(_ref) {var request = _ref.request,_ref$securities = _ref.securities,securities = _ref$securities === void 0 ? {} : _ref$securities,_ref$operation = _ref.operation,operation = _ref$operation === void 0 ? {} : _ref$operation,spec = _ref.spec;
|
|
3624
|
+
var result = assign_default()({}, request);var _securities$authorize =
|
|
3625
|
+
securities.authorized,authorized = _securities$authorize === void 0 ? {} : _securities$authorize,_securities$specSecur = securities.specSecurity,specSecurity = _securities$specSecur === void 0 ? [] : _securities$specSecur;
|
|
3626
|
+
var security = operation.security || specSecurity;
|
|
3627
|
+
var isAuthorized = authorized && !!keys_default()(authorized).length;
|
|
3628
|
+
var securityDef = spec.securityDefinitions;
|
|
3629
|
+
|
|
3630
|
+
result.headers = result.headers || {};
|
|
3631
|
+
result.query = result.query || {};
|
|
3632
|
+
|
|
3633
|
+
if (!keys_default()(securities).length || !isAuthorized || !security ||
|
|
3634
|
+
is_array_default()(operation.security) && !operation.security.length) {
|
|
3635
|
+
return request;
|
|
3636
|
+
}
|
|
3637
|
+
|
|
3638
|
+
security.forEach(function (securityObj, index) {
|
|
3639
|
+
for (var key in securityObj) {
|
|
3640
|
+
var auth = authorized[key];
|
|
3641
|
+
if (!auth) {
|
|
3642
|
+
continue;
|
|
3643
|
+
}
|
|
3644
|
+
|
|
3645
|
+
var token = auth.token;
|
|
3646
|
+
var value = auth.value || auth;
|
|
3647
|
+
var schema = securityDef[key];var
|
|
3648
|
+
type = schema.type;
|
|
3649
|
+
var tokenName = schema['x-tokenName'] || 'access_token';
|
|
3650
|
+
var oauthToken = token && token[tokenName];
|
|
3651
|
+
var tokenType = token && token.token_type;
|
|
3652
|
+
|
|
3653
|
+
if (auth) {
|
|
3654
|
+
if (type === 'apiKey') {
|
|
3655
|
+
var inType = schema.in === 'query' ? 'query' : 'headers';
|
|
3656
|
+
result[inType] = result[inType] || {};
|
|
3657
|
+
result[inType][schema.name] = value;
|
|
3658
|
+
} else
|
|
3659
|
+
if (type === 'basic') {
|
|
3660
|
+
if (value.header) {
|
|
3661
|
+
result.headers.authorization = value.header;
|
|
3662
|
+
} else
|
|
3663
|
+
{
|
|
3664
|
+
value.base64 = external_btoa_default()("".concat(value.username, ":").concat(value.password));
|
|
3665
|
+
result.headers.authorization = "Basic ".concat(value.base64);
|
|
3666
|
+
}
|
|
3667
|
+
} else
|
|
3668
|
+
if (type === 'oauth2' && oauthToken) {
|
|
3669
|
+
tokenType = !tokenType || tokenType.toLowerCase() === 'bearer' ? 'Bearer' : tokenType;
|
|
3670
|
+
result.headers.authorization = "".concat(tokenType, " ").concat(oauthToken);
|
|
3671
|
+
}
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3674
|
+
});
|
|
3675
|
+
|
|
3676
|
+
return result;
|
|
3677
|
+
}
|
|
3678
|
+
// CONCATENATED MODULE: ./src/execute/index.js
|
|
3679
|
+
function execute_ownKeys(object, enumerableOnly) {var keys = keys_default()(object);if (get_own_property_symbols_default.a) {var symbols = get_own_property_symbols_default()(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {return get_own_property_descriptor_default()(object, sym).enumerable;});keys.push.apply(keys, symbols);}return keys;}function execute_objectSpread(target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {execute_ownKeys(source, true).forEach(function (key) {defineProperty_default()(target, key, source[key]);});} else if (get_own_property_descriptors_default.a) {define_properties_default()(target, get_own_property_descriptors_default()(source));} else {execute_ownKeys(source).forEach(function (key) {define_property_default()(target, key, get_own_property_descriptor_default()(source, key));});}}return target;}
|
|
3680
|
+
|
|
3681
|
+
|
|
3682
|
+
|
|
3683
|
+
|
|
3684
|
+
|
|
3685
|
+
|
|
3686
|
+
|
|
3687
|
+
|
|
3688
|
+
|
|
3689
|
+
|
|
3690
|
+
|
|
3691
|
+
|
|
3692
|
+
|
|
3693
|
+
|
|
3694
|
+
|
|
3695
|
+
var execute_arrayOrEmpty = function arrayOrEmpty(ar) {
|
|
3696
|
+
return is_array_default()(ar) ? ar : [];
|
|
3697
|
+
};
|
|
3698
|
+
|
|
3699
|
+
var OperationNotFoundError = createErrorType('OperationNotFoundError', function (message, extra, oriError) {
|
|
3700
|
+
this.originalError = oriError;
|
|
3701
|
+
object_assign_default()(this, extra || {});
|
|
3702
|
+
});
|
|
3703
|
+
|
|
3704
|
+
var findParametersWithName = function findParametersWithName(name, parameters) {
|
|
3705
|
+
return parameters.filter(function (p) {return p.name === name;});
|
|
3706
|
+
};
|
|
3707
|
+
|
|
3708
|
+
// removes parameters that have duplicate 'in' and 'name' properties
|
|
3709
|
+
var execute_deduplicateParameters = function deduplicateParameters(parameters) {
|
|
3710
|
+
var paramsMap = {};
|
|
3711
|
+
parameters.forEach(function (p) {
|
|
3712
|
+
if (!paramsMap[p.in]) {
|
|
3713
|
+
paramsMap[p.in] = {};
|
|
3714
|
+
}
|
|
3715
|
+
paramsMap[p.in][p.name] = p;
|
|
3716
|
+
});
|
|
3717
|
+
|
|
3718
|
+
var dedupedParameters = [];
|
|
3719
|
+
keys_default()(paramsMap).forEach(function (i) {
|
|
3720
|
+
keys_default()(paramsMap[i]).forEach(function (p) {
|
|
3721
|
+
dedupedParameters.push(paramsMap[i][p]);
|
|
3722
|
+
});
|
|
3723
|
+
});
|
|
3724
|
+
return dedupedParameters;
|
|
3725
|
+
};
|
|
3726
|
+
|
|
3727
|
+
// For stubbing in tests
|
|
3728
|
+
var execute_self = {
|
|
3729
|
+
buildRequest: buildRequest
|
|
3730
|
+
|
|
3731
|
+
|
|
3732
|
+
// Execute request, with the given operationId and parameters
|
|
3733
|
+
// pathName/method or operationId is optional
|
|
3734
|
+
};function execute(_ref)
|
|
3735
|
+
|
|
3736
|
+
|
|
3737
|
+
|
|
3738
|
+
|
|
3739
|
+
|
|
3740
|
+
|
|
3741
|
+
|
|
3742
|
+
|
|
3743
|
+
|
|
3744
|
+
{var userHttp = _ref.http,fetch = _ref.fetch,spec = _ref.spec,operationId = _ref.operationId,pathName = _ref.pathName,method = _ref.method,parameters = _ref.parameters,securities = _ref.securities,extras = objectWithoutProperties_default()(_ref, ["http", "fetch", "spec", "operationId", "pathName", "method", "parameters", "securities"]);
|
|
3745
|
+
// Provide default fetch implementation
|
|
3746
|
+
var http = userHttp || fetch || http_http; // Default to _our_ http
|
|
3747
|
+
|
|
3748
|
+
if (pathName && method && !operationId) {
|
|
3749
|
+
operationId = legacyIdFromPathMethod(pathName, method);
|
|
3750
|
+
}
|
|
3751
|
+
|
|
3752
|
+
var request = execute_self.buildRequest(execute_objectSpread({ spec: spec, operationId: operationId, parameters: parameters, securities: securities, http: http }, extras));
|
|
3753
|
+
|
|
3754
|
+
if (request.body && (isPlainObject_default()(request.body) || isArray_default()(request.body))) {
|
|
3755
|
+
request.body = stringify_default()(request.body);
|
|
3756
|
+
}
|
|
3757
|
+
|
|
3758
|
+
// Build request and execute it
|
|
3759
|
+
return http(request);
|
|
3760
|
+
}
|
|
3761
|
+
|
|
3762
|
+
// Build a request, which can be handled by the `http.js` implementation.
|
|
3763
|
+
function buildRequest(options) {var
|
|
3764
|
+
|
|
3765
|
+
spec =
|
|
3766
|
+
|
|
3767
|
+
|
|
3768
|
+
|
|
3769
|
+
|
|
3770
|
+
|
|
3771
|
+
|
|
3772
|
+
|
|
3773
|
+
|
|
3774
|
+
|
|
3775
|
+
|
|
3776
|
+
|
|
3777
|
+
|
|
3778
|
+
|
|
3779
|
+
options.spec,operationId = options.operationId,securities = options.securities,requestContentType = options.requestContentType,responseContentType = options.responseContentType,scheme = options.scheme,requestInterceptor = options.requestInterceptor,responseInterceptor = options.responseInterceptor,contextUrl = options.contextUrl,userFetch = options.userFetch,requestBody = options.requestBody,server = options.server,serverVariables = options.serverVariables,http = options.http;var
|
|
3780
|
+
|
|
3781
|
+
|
|
3782
|
+
parameters =
|
|
3783
|
+
|
|
3784
|
+
options.parameters,parameterBuilders = options.parameterBuilders;
|
|
3785
|
+
|
|
3786
|
+
var specIsOAS3 = isOAS3(spec);
|
|
3787
|
+
if (!parameterBuilders) {
|
|
3788
|
+
// user did not provide custom parameter builders
|
|
3789
|
+
if (specIsOAS3) {
|
|
3790
|
+
parameterBuilders = oas3_parameter_builders_namespaceObject;
|
|
3791
|
+
} else
|
|
3792
|
+
{
|
|
3793
|
+
parameterBuilders = parameter_builders;
|
|
3794
|
+
}
|
|
3795
|
+
}
|
|
3796
|
+
|
|
3797
|
+
// Set credentials with 'http.withCredentials' value
|
|
3798
|
+
var credentials = http && http.withCredentials ? 'include' : 'same-origin';
|
|
3799
|
+
|
|
3800
|
+
// Base Template
|
|
3801
|
+
var req = {
|
|
3802
|
+
url: '',
|
|
3803
|
+
credentials: credentials,
|
|
3804
|
+
headers: {},
|
|
3805
|
+
cookies: {} };
|
|
3806
|
+
|
|
3807
|
+
|
|
3808
|
+
if (requestInterceptor) {
|
|
3809
|
+
req.requestInterceptor = requestInterceptor;
|
|
3810
|
+
}
|
|
3811
|
+
if (responseInterceptor) {
|
|
3812
|
+
req.responseInterceptor = responseInterceptor;
|
|
3813
|
+
}
|
|
3814
|
+
if (userFetch) {
|
|
3815
|
+
req.userFetch = userFetch;
|
|
3816
|
+
}
|
|
3817
|
+
|
|
3818
|
+
var operationRaw = getOperationRaw(spec, operationId);
|
|
3819
|
+
if (!operationRaw) {
|
|
3820
|
+
throw new OperationNotFoundError("Operation ".concat(operationId, " not found"));
|
|
3821
|
+
}var _operationRaw$operati =
|
|
3822
|
+
|
|
3823
|
+
operationRaw.operation,operation = _operationRaw$operati === void 0 ? {} : _operationRaw$operati,method = operationRaw.method,pathName = operationRaw.pathName;
|
|
3824
|
+
|
|
3825
|
+
req.url += execute_baseUrl({ spec: spec, scheme: scheme, contextUrl: contextUrl, server: server, serverVariables: serverVariables, pathName: pathName, method: method });
|
|
3826
|
+
|
|
3827
|
+
// Mostly for testing
|
|
3828
|
+
if (!operationId) {
|
|
3829
|
+
// Not removing req.cookies causes testing issues and would
|
|
3830
|
+
// change our interface, so we're always sure to remove it.
|
|
3831
|
+
// See the same statement lower down in this function for
|
|
3832
|
+
// more context.
|
|
3833
|
+
delete req.cookies;
|
|
3834
|
+
return req;
|
|
3835
|
+
}
|
|
3836
|
+
|
|
3837
|
+
req.url += pathName; // Have not yet replaced the path parameters
|
|
3838
|
+
req.method = "".concat(method).toUpperCase();
|
|
3839
|
+
|
|
3840
|
+
parameters = parameters || {};
|
|
3841
|
+
var path = spec.paths[pathName] || {};
|
|
3842
|
+
|
|
3843
|
+
if (responseContentType) {
|
|
3844
|
+
req.headers.accept = responseContentType;
|
|
3845
|
+
}
|
|
3846
|
+
|
|
3847
|
+
var combinedParameters = execute_deduplicateParameters([].
|
|
3848
|
+
concat(execute_arrayOrEmpty(operation.parameters)) // operation parameters
|
|
3849
|
+
.concat(execute_arrayOrEmpty(path.parameters)) // path parameters
|
|
3850
|
+
);
|
|
3851
|
+
|
|
3852
|
+
// REVIEW: OAS3: have any key names or parameter shapes changed?
|
|
3853
|
+
// Any new features that need to be plugged in here?
|
|
3854
|
+
|
|
3855
|
+
|
|
3856
|
+
// Add values to request
|
|
3857
|
+
combinedParameters.forEach(function (parameter) {
|
|
3858
|
+
var builder = parameterBuilders[parameter.in];
|
|
3859
|
+
var value;
|
|
3860
|
+
|
|
3861
|
+
if (parameter.in === 'body' && parameter.schema && parameter.schema.properties) {
|
|
3862
|
+
value = parameters;
|
|
3863
|
+
}
|
|
3864
|
+
|
|
3865
|
+
value = parameter && parameter.name && parameters[parameter.name];
|
|
3866
|
+
|
|
3867
|
+
if (typeof value === 'undefined') {
|
|
3868
|
+
// check for `name-in` formatted key
|
|
3869
|
+
value = parameter && parameter.name && parameters["".concat(parameter.in, ".").concat(parameter.name)];
|
|
3870
|
+
} else
|
|
3871
|
+
if (findParametersWithName(parameter.name, combinedParameters).length > 1) {
|
|
3872
|
+
// value came from `parameters[parameter.name]`
|
|
3873
|
+
// check to see if this is an ambiguous parameter
|
|
3874
|
+
// eslint-disable-next-line no-console
|
|
3875
|
+
console.warn("Parameter '".concat(parameter.name, "' is ambiguous because the defined spec has more than one parameter with the name: '").concat(parameter.name, "' and the passed-in parameter values did not define an 'in' value."));
|
|
3876
|
+
}
|
|
3877
|
+
|
|
3878
|
+
if (value === null) {
|
|
3879
|
+
return;
|
|
3880
|
+
}
|
|
3881
|
+
|
|
3882
|
+
if (typeof parameter.default !== 'undefined' && typeof value === 'undefined') {
|
|
3883
|
+
value = parameter.default;
|
|
3884
|
+
}
|
|
3885
|
+
|
|
3886
|
+
if (typeof value === 'undefined' && parameter.required && !parameter.allowEmptyValue) {
|
|
3887
|
+
throw new Error("Required parameter ".concat(parameter.name, " is not provided"));
|
|
3888
|
+
}
|
|
3889
|
+
|
|
3890
|
+
if (specIsOAS3 && parameter.schema && parameter.schema.type === 'object' && typeof value === 'string') {
|
|
3891
|
+
try {
|
|
3892
|
+
value = JSON.parse(value);
|
|
3893
|
+
}
|
|
3894
|
+
catch (e) {
|
|
3895
|
+
throw new Error('Could not parse object parameter value string as JSON');
|
|
3896
|
+
}
|
|
3897
|
+
}
|
|
3898
|
+
|
|
3899
|
+
if (builder) {
|
|
3900
|
+
builder({ req: req, parameter: parameter, value: value, operation: operation, spec: spec });
|
|
3901
|
+
}
|
|
3902
|
+
});
|
|
3903
|
+
|
|
3904
|
+
// Do version-specific tasks, then return those results.
|
|
3905
|
+
var versionSpecificOptions = execute_objectSpread({}, options, { operation: operation });
|
|
3906
|
+
|
|
3907
|
+
if (specIsOAS3) {
|
|
3908
|
+
req = build_request(versionSpecificOptions, req);
|
|
3909
|
+
} else
|
|
3910
|
+
{
|
|
3911
|
+
// If not OAS3, then treat as Swagger2.
|
|
3912
|
+
req = swagger2_build_request(versionSpecificOptions, req);
|
|
3913
|
+
}
|
|
3914
|
+
|
|
3915
|
+
|
|
3916
|
+
// If the cookie convenience object exists in our request,
|
|
3917
|
+
// serialize its content and then delete the cookie object.
|
|
3918
|
+
if (req.cookies && keys_default()(req.cookies).length) {
|
|
3919
|
+
var cookieString = keys_default()(req.cookies).reduce(function (prev, cookieName) {
|
|
3920
|
+
var cookieValue = req.cookies[cookieName];
|
|
3921
|
+
var prefix = prev ? '&' : '';
|
|
3922
|
+
var stringified = external_cookie_default.a.serialize(cookieName, cookieValue);
|
|
3923
|
+
return prev + prefix + stringified;
|
|
3924
|
+
}, '');
|
|
3925
|
+
req.headers.Cookie = cookieString;
|
|
3926
|
+
}
|
|
3927
|
+
|
|
3928
|
+
if (req.cookies) {
|
|
3929
|
+
// even if no cookies were defined, we need to remove
|
|
3930
|
+
// the cookies key from our request, or many many legacy
|
|
3931
|
+
// tests will break.
|
|
3932
|
+
delete req.cookies;
|
|
3933
|
+
}
|
|
3934
|
+
|
|
3935
|
+
// Will add the query object into the URL, if it exists
|
|
3936
|
+
// ... will also create a FormData instance, if multipart/form-data (eg: a file)
|
|
3937
|
+
mergeInQueryOrForm(req);
|
|
3938
|
+
|
|
3939
|
+
return req;
|
|
3940
|
+
}
|
|
3941
|
+
|
|
3942
|
+
var stripNonAlpha = function stripNonAlpha(str) {return str ? str.replace(/\W/g, '') : null;};
|
|
3943
|
+
|
|
3944
|
+
function execute_baseUrl(obj) {
|
|
3945
|
+
var specIsOAS3 = isOAS3(obj.spec);
|
|
3946
|
+
|
|
3947
|
+
return specIsOAS3 ? oas3BaseUrl(obj) : swagger2BaseUrl(obj);
|
|
3948
|
+
}
|
|
3949
|
+
|
|
3950
|
+
function oas3BaseUrl(_ref2) {var spec = _ref2.spec,pathName = _ref2.pathName,method = _ref2.method,server = _ref2.server,contextUrl = _ref2.contextUrl,_ref2$serverVariables = _ref2.serverVariables,serverVariables = _ref2$serverVariables === void 0 ? {} : _ref2$serverVariables;
|
|
3951
|
+
var servers =
|
|
3952
|
+
get_default()(spec, ['paths', pathName, (method || '').toLowerCase(), 'servers']) ||
|
|
3953
|
+
get_default()(spec, ['paths', pathName, 'servers']) ||
|
|
3954
|
+
get_default()(spec, ['servers']);
|
|
3955
|
+
|
|
3956
|
+
var selectedServerUrl = '';
|
|
3957
|
+
var selectedServerObj = null;
|
|
3958
|
+
|
|
3959
|
+
if (server && servers && servers.length) {
|
|
3960
|
+
var serverUrls = servers.map(function (srv) {return srv.url;});
|
|
3961
|
+
|
|
3962
|
+
if (serverUrls.indexOf(server) > -1) {
|
|
3963
|
+
selectedServerUrl = server;
|
|
3964
|
+
selectedServerObj = servers[serverUrls.indexOf(server)];
|
|
3965
|
+
}
|
|
3966
|
+
}
|
|
3967
|
+
|
|
3968
|
+
if (!selectedServerUrl && servers && servers.length) {
|
|
3969
|
+
// default to the first server if we don't have one by now
|
|
3970
|
+
selectedServerUrl = servers[0].url;
|
|
3971
|
+
selectedServerObj = servers[0];
|
|
3972
|
+
}
|
|
3973
|
+
|
|
3974
|
+
if (selectedServerUrl.indexOf('{') > -1) {
|
|
3975
|
+
// do variable substitution
|
|
3976
|
+
var varNames = getVariableTemplateNames(selectedServerUrl);
|
|
3977
|
+
varNames.forEach(function (vari) {
|
|
3978
|
+
if (selectedServerObj.variables && selectedServerObj.variables[vari]) {
|
|
3979
|
+
// variable is defined in server
|
|
3980
|
+
var variableDefinition = selectedServerObj.variables[vari];
|
|
3981
|
+
var variableValue = serverVariables[vari] || variableDefinition.default;
|
|
3982
|
+
|
|
3983
|
+
var re = new RegExp("{".concat(vari, "}"), 'g');
|
|
3984
|
+
selectedServerUrl = selectedServerUrl.replace(re, variableValue);
|
|
3985
|
+
}
|
|
3986
|
+
});
|
|
3987
|
+
}
|
|
3988
|
+
|
|
3989
|
+
return buildOas3UrlWithContext(selectedServerUrl, contextUrl);
|
|
3990
|
+
}
|
|
3991
|
+
|
|
3992
|
+
function buildOas3UrlWithContext() {var ourUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';var contextUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
3993
|
+
var parsedUrl = external_url_default.a.parse(ourUrl);
|
|
3994
|
+
var parsedContextUrl = external_url_default.a.parse(contextUrl);
|
|
3995
|
+
|
|
3996
|
+
var computedScheme = stripNonAlpha(parsedUrl.protocol) || stripNonAlpha(parsedContextUrl.protocol) || '';
|
|
3997
|
+
var computedHost = parsedUrl.host || parsedContextUrl.host;
|
|
3998
|
+
var computedPath = parsedUrl.pathname || '';
|
|
3999
|
+
var res;
|
|
4000
|
+
|
|
4001
|
+
if (computedScheme && computedHost) {
|
|
4002
|
+
res = "".concat(computedScheme, "://").concat(computedHost + computedPath);
|
|
4003
|
+
|
|
4004
|
+
// If last character is '/', trim it off
|
|
4005
|
+
} else
|
|
4006
|
+
{
|
|
4007
|
+
res = computedPath;
|
|
4008
|
+
}
|
|
4009
|
+
|
|
4010
|
+
return res[res.length - 1] === '/' ? res.slice(0, -1) : res;
|
|
4011
|
+
}
|
|
4012
|
+
|
|
4013
|
+
function getVariableTemplateNames(str) {
|
|
4014
|
+
var results = [];
|
|
4015
|
+
var re = /{([^}]+)}/g;
|
|
4016
|
+
var text;
|
|
4017
|
+
|
|
4018
|
+
// eslint-disable-next-line no-cond-assign
|
|
4019
|
+
while (text = re.exec(str)) {
|
|
4020
|
+
results.push(text[1]);
|
|
4021
|
+
}
|
|
4022
|
+
return results;
|
|
4023
|
+
}
|
|
4024
|
+
|
|
4025
|
+
// Compose the baseUrl ( scheme + host + basePath )
|
|
4026
|
+
function swagger2BaseUrl(_ref3) {var spec = _ref3.spec,scheme = _ref3.scheme,_ref3$contextUrl = _ref3.contextUrl,contextUrl = _ref3$contextUrl === void 0 ? '' : _ref3$contextUrl;
|
|
4027
|
+
var parsedContextUrl = external_url_default.a.parse(contextUrl);
|
|
4028
|
+
var firstSchemeInSpec = is_array_default()(spec.schemes) ? spec.schemes[0] : null;
|
|
4029
|
+
|
|
4030
|
+
var computedScheme = scheme || firstSchemeInSpec || stripNonAlpha(parsedContextUrl.protocol) || 'http';
|
|
4031
|
+
var computedHost = spec.host || parsedContextUrl.host || '';
|
|
4032
|
+
var computedPath = spec.basePath || '';
|
|
4033
|
+
var res;
|
|
4034
|
+
|
|
4035
|
+
if (computedScheme && computedHost) {
|
|
4036
|
+
// we have what we need for an absolute URL
|
|
4037
|
+
res = "".concat(computedScheme, "://").concat(computedHost + computedPath);
|
|
4038
|
+
} else
|
|
4039
|
+
{
|
|
4040
|
+
// if not, a relative URL will have to do
|
|
4041
|
+
res = computedPath;
|
|
4042
|
+
}
|
|
4043
|
+
|
|
4044
|
+
// If last character is '/', trim it off
|
|
4045
|
+
return res[res.length - 1] === '/' ? res.slice(0, -1) : res;
|
|
4046
|
+
}
|
|
4047
|
+
// CONCATENATED MODULE: ./src/index.js
|
|
4048
|
+
function src_ownKeys(object, enumerableOnly) {var keys = keys_default()(object);if (get_own_property_symbols_default.a) {var symbols = get_own_property_symbols_default()(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {return get_own_property_descriptor_default()(object, sym).enumerable;});keys.push.apply(keys, symbols);}return keys;}function src_objectSpread(target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {src_ownKeys(source, true).forEach(function (key) {defineProperty_default()(target, key, source[key]);});} else if (get_own_property_descriptors_default.a) {define_properties_default()(target, get_own_property_descriptors_default()(source));} else {src_ownKeys(source).forEach(function (key) {define_property_default()(target, key, get_own_property_descriptor_default()(source, key));});}}return target;}
|
|
4049
|
+
|
|
4050
|
+
|
|
4051
|
+
|
|
4052
|
+
|
|
4053
|
+
|
|
4054
|
+
|
|
4055
|
+
|
|
4056
|
+
|
|
4057
|
+
|
|
4058
|
+
|
|
4059
|
+
Swagger.http = http_http;
|
|
4060
|
+
Swagger.makeHttp = makeHttp.bind(null, Swagger.http);
|
|
4061
|
+
Swagger.resolve = resolve;
|
|
4062
|
+
Swagger.resolveSubtree = resolveSubtree;
|
|
4063
|
+
Swagger.execute = execute;
|
|
4064
|
+
Swagger.serializeRes = serializeRes;
|
|
4065
|
+
Swagger.serializeHeaders = serializeHeaders;
|
|
4066
|
+
Swagger.clearCache = resolver_clearCache;
|
|
4067
|
+
Swagger.makeApisTagOperation = makeApisTagOperation;
|
|
4068
|
+
Swagger.buildRequest = buildRequest;
|
|
4069
|
+
Swagger.helpers = { opId: opId };
|
|
4070
|
+
|
|
4071
|
+
function Swagger(url) {var _this = this;var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4072
|
+
// Allow url as a separate argument
|
|
4073
|
+
if (typeof url === 'string') {
|
|
4074
|
+
opts.url = url;
|
|
4075
|
+
} else
|
|
4076
|
+
{
|
|
4077
|
+
opts = url;
|
|
4078
|
+
}
|
|
4079
|
+
|
|
4080
|
+
if (!(this instanceof Swagger)) {
|
|
4081
|
+
return new Swagger(opts);
|
|
4082
|
+
}
|
|
4083
|
+
|
|
4084
|
+
assign_default()(this, opts);
|
|
4085
|
+
|
|
4086
|
+
var prom = this.resolve().
|
|
4087
|
+
then(function () {
|
|
4088
|
+
if (!_this.disableInterfaces) {
|
|
4089
|
+
assign_default()(_this, Swagger.makeApisTagOperation(_this));
|
|
4090
|
+
}
|
|
4091
|
+
return _this;
|
|
4092
|
+
});
|
|
4093
|
+
|
|
4094
|
+
// Expose this instance on the promise that gets returned
|
|
4095
|
+
prom.client = this;
|
|
4096
|
+
return prom;
|
|
4097
|
+
}
|
|
4098
|
+
|
|
4099
|
+
Swagger.prototype = {
|
|
4100
|
+
|
|
4101
|
+
http: http_http,
|
|
4102
|
+
|
|
4103
|
+
execute: function execute(argHash) {
|
|
4104
|
+
this.applyDefaults();
|
|
4105
|
+
|
|
4106
|
+
return Swagger.execute(src_objectSpread({
|
|
4107
|
+
spec: this.spec,
|
|
4108
|
+
http: this.http,
|
|
4109
|
+
securities: { authorized: this.authorizations },
|
|
4110
|
+
contextUrl: typeof this.url === 'string' ? this.url : undefined },
|
|
4111
|
+
argHash));
|
|
4112
|
+
|
|
4113
|
+
},
|
|
4114
|
+
|
|
4115
|
+
resolve: function resolve() {var _this2 = this;
|
|
4116
|
+
return Swagger.resolve({
|
|
4117
|
+
spec: this.spec,
|
|
4118
|
+
url: this.url,
|
|
4119
|
+
allowMetaPatches: this.allowMetaPatches,
|
|
4120
|
+
useCircularStructures: this.useCircularStructures,
|
|
4121
|
+
requestInterceptor: this.requestInterceptor || null,
|
|
4122
|
+
responseInterceptor: this.responseInterceptor || null }).
|
|
4123
|
+
then(function (obj) {
|
|
4124
|
+
_this2.originalSpec = _this2.spec;
|
|
4125
|
+
_this2.spec = obj.spec;
|
|
4126
|
+
_this2.errors = obj.errors;
|
|
4127
|
+
return _this2;
|
|
4128
|
+
});
|
|
4129
|
+
} };
|
|
4130
|
+
|
|
4131
|
+
|
|
4132
|
+
Swagger.prototype.applyDefaults = function () {
|
|
4133
|
+
var spec = this.spec;
|
|
4134
|
+
var specUrl = this.url;
|
|
4135
|
+
// TODO: OAS3: support servers here
|
|
4136
|
+
if (specUrl && startsWith_default()(specUrl, 'http')) {
|
|
4137
|
+
var parsed = external_url_default.a.parse(specUrl);
|
|
4138
|
+
if (!spec.host) {
|
|
4139
|
+
spec.host = parsed.host;
|
|
4140
|
+
}
|
|
4141
|
+
if (!spec.schemes) {
|
|
4142
|
+
spec.schemes = [parsed.protocol.replace(':', '')];
|
|
4143
|
+
}
|
|
4144
|
+
if (!spec.basePath) {
|
|
4145
|
+
spec.basePath = '/';
|
|
4146
|
+
}
|
|
4147
|
+
}
|
|
4148
|
+
};
|
|
4149
|
+
|
|
4150
|
+
/* harmony default export */ var src = __webpack_exports__["default"] = (Swagger);
|
|
4151
|
+
|
|
4152
|
+
/***/ })
|
|
4153
|
+
/******/ ])["default"];
|
|
2
4154
|
//# sourceMappingURL=index.js.map
|