swagger-client
Version:
swagger-client is a javascript client for use with swaggering APIs.
40 lines (26 loc) • 223 kB
JavaScript
/**
* swagger-client - swagger-client is a javascript client for use with swaggering APIs.
* @version v2.1.19
* @link http://swagger.io
* @license Apache-2.0
*/
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.SwaggerClient = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
"use strict";var auth=require("./lib/auth"),helpers=require("./lib/helpers"),SwaggerClient=require("./lib/client"),deprecationWrapper=function(e,r){return helpers.log('This is deprecated, use "new SwaggerClient" instead.'),new SwaggerClient(e,r)};Array.prototype.indexOf||(Array.prototype.indexOf=function(e,r){for(var t=r||0,i=this.length;i>t;t++)if(this[t]===e)return t;return-1}),String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),String.prototype.endsWith||(String.prototype.endsWith=function(e){return-1!==this.indexOf(e,this.length-e.length)}),module.exports=SwaggerClient,SwaggerClient.ApiKeyAuthorization=auth.ApiKeyAuthorization,SwaggerClient.PasswordAuthorization=auth.PasswordAuthorization,SwaggerClient.CookieAuthorization=auth.CookieAuthorization,SwaggerClient.SwaggerApi=deprecationWrapper,SwaggerClient.SwaggerClient=deprecationWrapper,SwaggerClient.SchemaMarkup=require("./lib/schema-markup");
},{"./lib/auth":2,"./lib/client":3,"./lib/helpers":4,"./lib/schema-markup":7}],2:[function(require,module,exports){
"use strict";var helpers=require("./helpers"),btoa=require("btoa"),CookieJar=require("cookiejar").CookieJar,_={each:require("lodash-compat/collection/each"),includes:require("lodash-compat/collection/includes"),isObject:require("lodash-compat/lang/isObject"),isArray:require("lodash-compat/lang/isArray")},SwaggerAuthorizations=module.exports.SwaggerAuthorizations=function(e){this.authz=e||{}};SwaggerAuthorizations.prototype.add=function(e,t){if(_.isObject(e))for(var o in e)this.authz[o]=e[o];else"string"==typeof e&&(this.authz[e]=t);return t},SwaggerAuthorizations.prototype.remove=function(e){return delete this.authz[e]},SwaggerAuthorizations.prototype.apply=function(e,t){var o=!0,i=!t,r=[],a=e.clientAuthorizations||this.authz;return _.each(t,function(e,t){"string"==typeof t&&r.push(t),_.each(e,function(e,t){r.push(t)})}),_.each(a,function(t,a){if(i||_.includes(r,a)){var n=t.apply(e);o=o&&!!n}}),o};var ApiKeyAuthorization=module.exports.ApiKeyAuthorization=function(e,t,o){this.name=e,this.value=t,this.type=o};ApiKeyAuthorization.prototype.apply=function(e){if("query"===this.type){var t;if(e.url.indexOf("?")>0){t=e.url.substring(e.url.indexOf("?")+1);var o=t.split("&");if(o&&o.length>0)for(var i=0;i<o.length;i++){var r=o[i].split("=");if(r&&r.length>0&&r[0]===this.name)return!1}}return e.url.indexOf("?")>0?e.url=e.url+"&"+this.name+"="+this.value:e.url=e.url+"?"+this.name+"="+this.value,!0}return"header"===this.type?("undefined"==typeof e.headers[this.name]&&(e.headers[this.name]=this.value),!0):void 0};var CookieAuthorization=module.exports.CookieAuthorization=function(e){this.cookie=e};CookieAuthorization.prototype.apply=function(e){return e.cookieJar=e.cookieJar||new CookieJar,e.cookieJar.setCookie(this.cookie),!0};var PasswordAuthorization=module.exports.PasswordAuthorization=function(e,t){3===arguments.length&&(helpers.log("PasswordAuthorization: the 'name' argument has been removed, pass only username and password"),e=arguments[1],t=arguments[2]),this.username=e,this.password=t};PasswordAuthorization.prototype.apply=function(e){return"undefined"==typeof e.headers.Authorization&&(e.headers.Authorization="Basic "+btoa(this.username+":"+this.password)),!0};
},{"./helpers":4,"btoa":13,"cookiejar":18,"lodash-compat/collection/each":52,"lodash-compat/collection/includes":55,"lodash-compat/lang/isArray":140,"lodash-compat/lang/isObject":144}],3:[function(require,module,exports){
"use strict";var _={bind:require("lodash-compat/function/bind"),cloneDeep:require("lodash-compat/lang/cloneDeep"),find:require("lodash-compat/collection/find"),forEach:require("lodash-compat/collection/forEach"),indexOf:require("lodash-compat/array/indexOf"),isArray:require("lodash-compat/lang/isArray"),isObject:require("lodash-compat/lang/isObject"),isFunction:require("lodash-compat/lang/isFunction"),isPlainObject:require("lodash-compat/lang/isPlainObject"),isUndefined:require("lodash-compat/lang/isUndefined")},auth=require("./auth"),helpers=require("./helpers"),Model=require("./types/model"),Operation=require("./types/operation"),OperationGroup=require("./types/operationGroup"),Resolver=require("./resolver"),SwaggerHttp=require("./http"),SwaggerSpecConverter=require("./spec-converter"),Q=require("q"),reservedClientTags=["apis","authorizationScheme","authorizations","basePath","build","buildFrom1_1Spec","buildFrom1_2Spec","buildFromSpec","clientAuthorizations","convertInfo","debug","defaultErrorCallback","defaultSuccessCallback","enableCookies","fail","failure","finish","help","host","idFromOp","info","initialize","isBuilt","isValid","modelPropertyMacro","models","modelsArray","options","parameterMacro","parseUri","progress","resourceCount","sampleModels","selfReflect","setConsolidatedModels","spec","supportedSubmitMethods","swaggerRequestHeaders","tagFromLabel","title","url","useJQuery","jqueryAjaxCache"],reservedApiTags=["apis","asCurl","description","externalDocs","help","label","name","operation","operations","operationsArray","path","tag"],supportedOperationMethods=["delete","get","head","options","patch","post","put"],SwaggerClient=module.exports=function(e,t){return this.authorizations=null,this.authorizationScheme=null,this.basePath=null,this.debug=!1,this.enableCookies=!1,this.info=null,this.isBuilt=!1,this.isValid=!1,this.modelsArray=[],this.resourceCount=0,this.url=null,this.useJQuery=!1,this.jqueryAjaxCache=!1,this.swaggerObject={},this.deferredClient=void 0,this.clientAuthorizations=new auth.SwaggerAuthorizations,"undefined"!=typeof e?this.initialize(e,t):this};SwaggerClient.prototype.initialize=function(e,t){return this.models={},this.sampleModels={},"string"==typeof e?this.url=e:_.isObject(e)&&(t=e,this.url=t.url),this.url&&-1===this.url.indexOf("http:")&&-1===this.url.indexOf("https:")&&"undefined"!=typeof window&&window&&window.location&&(this.url=window.location.origin+this.url),t=t||{},this.clientAuthorizations.add(t.authorizations),this.swaggerRequestHeaders=t.swaggerRequestHeaders||"application/json;charset=utf-8,*/*",this.defaultSuccessCallback=t.defaultSuccessCallback||null,this.defaultErrorCallback=t.defaultErrorCallback||null,this.modelPropertyMacro=t.modelPropertyMacro||null,this.parameterMacro=t.parameterMacro||null,this.usePromise=t.usePromise||null,this.timeout=t.timeout||null,this.fetchSpecTimeout="undefined"!=typeof t.fetchSpecTimeout?t.fetchSpecTimeout:t.timeout||null,this.usePromise&&(this.deferredClient=Q.defer()),"function"==typeof t.success&&(this.success=t.success),t.useJQuery&&(this.useJQuery=t.useJQuery),t.jqueryAjaxCache&&(this.jqueryAjaxCache=t.jqueryAjaxCache),t.enableCookies&&(this.enableCookies=t.enableCookies),this.options=t||{},this.options.timeout=this.timeout,this.options.fetchSpecTimeout=this.fetchSpecTimeout,this.supportedSubmitMethods=t.supportedSubmitMethods||[],this.failure=t.failure||function(e){throw e},this.progress=t.progress||function(){},this.spec=_.cloneDeep(t.spec),t.scheme&&(this.scheme=t.scheme),this.usePromise||"function"==typeof t.success?(this.ready=!0,this.build()):void 0},SwaggerClient.prototype.build=function(e){if(this.isBuilt)return this;var t=this;this.spec?this.progress("fetching resource list; Please wait."):this.progress("fetching resource list: "+this.url+"; Please wait.");var i={useJQuery:this.useJQuery,jqueryAjaxCache:this.jqueryAjaxCache,url:this.url,method:"get",headers:{accept:this.swaggerRequestHeaders},on:{error:function(e){return"http"!==t.url.substring(0,4)?t.fail("Please specify the protocol for "+t.url):!e.errObj||"ECONNABORTED"!==e.errObj.code&&-1==e.errObj.message.indexOf("timeout")?0===e.status?t.fail("Can't read from server. It may not have the appropriate access-control-origin settings."):404===e.status?t.fail("Can't read swagger JSON from "+t.url):t.fail(e.status+" : "+e.statusText+" "+t.url):t.fail("Request timed out after "+t.fetchSpecTimeout+"ms")},response:function(e){var i=e.obj;if(!i)return t.fail("failed to parse JSON/YAML response");if(t.swaggerVersion=i.swaggerVersion,t.swaggerObject=i,i.swagger&&2===parseInt(i.swagger))t.swaggerVersion=i.swagger,(new Resolver).resolve(i,t.url,t.buildFromSpec,t),t.isValid=!0;else{var s=new SwaggerSpecConverter;t.oldSwaggerObject=t.swaggerObject,s.setDocumentationLocation(t.url),s.convert(i,t.clientAuthorizations,t.options,function(e){t.swaggerObject=e,(new Resolver).resolve(e,t.url,t.buildFromSpec,t),t.isValid=!0})}}}};if(this.fetchSpecTimeout&&(i.timeout=this.fetchSpecTimeout),this.spec)t.swaggerObject=this.spec,setTimeout(function(){(new Resolver).resolve(t.spec,t.url,t.buildFromSpec,t)},10);else{if(this.clientAuthorizations.apply(i),e)return i;(new SwaggerHttp).execute(i,this.options)}return this.usePromise?this.deferredClient.promise:this},SwaggerClient.prototype.buildFromSpec=function(e){if(this.isBuilt)return this;this.apis={},this.apisArray=[],this.basePath=e.basePath||"",this.consumes=e.consumes,this.host=e.host||"",this.info=e.info||{},this.produces=e.produces,this.schemes=e.schemes||[],this.securityDefinitions=e.securityDefinitions,this.security=e.security,this.title=e.title||"",e.externalDocs&&(this.externalDocs=e.externalDocs),this.authSchemes=e.securityDefinitions;var t,i={};if(Array.isArray(e.tags))for(i={},t=0;t<e.tags.length;t++){var s=e.tags[t];i[s.name]=s}var r;if("string"==typeof this.url){if(r=this.parseUri(this.url),"undefined"==typeof this.scheme&&"undefined"==typeof this.schemes||0===this.schemes.length)"undefined"!=typeof window?this.scheme=window.location.scheme:this.scheme=r.scheme||"http";else if("undefined"==typeof this.scheme)if("undefined"!=typeof window){var o=window.location.protocol.replace(":","");-1!==this.schemes.indexOf(o)?this.scheme=o:this.scheme="http"}else this.scheme=this.schemes[0]||r.scheme;"undefined"!=typeof this.host&&""!==this.host||(this.host=r.host,r.port&&(this.host=this.host+":"+r.port))}else"undefined"==typeof this.schemes||0===this.schemes.length?this.scheme="http":"undefined"==typeof this.scheme&&(this.scheme=this.schemes[0]);this.definitions=e.definitions;var a;for(a in this.definitions){var n=new Model(a,this.definitions[a],this.models,this.modelPropertyMacro);n&&(this.models[a]=n)}var h=this;h.apis.help=_.bind(h.help,h),_.forEach(e.paths,function(e,t){_.isPlainObject(e)&&_.forEach(supportedOperationMethods,function(s){var r=e[s];if(!_.isUndefined(r)){if(!_.isPlainObject(r))return void helpers.log("The '"+s+"' operation for '"+t+"' path is not an Operation Object");var o=r.tags;!_.isUndefined(o)&&_.isArray(o)&&0!==o.length||(o=r.tags=["default"]);var a=h.idFromOp(t,s,r),n=new Operation(h,r.scheme,a,s,t,r,h.definitions,h.models,h.clientAuthorizations);_.forEach(o,function(e){var t=_.indexOf(reservedClientTags,e)>-1?"_"+e:e,s=_.indexOf(reservedApiTags,e)>-1?"_"+e:e,r=h[t];if(t!==e&&helpers.log("The '"+e+"' tag conflicts with a SwaggerClient function/property name. Use 'client."+t+"' or 'client.apis."+e+"' instead of 'client."+e+"'."),s!==e&&helpers.log("The '"+e+"' tag conflicts with a SwaggerClient operation function/property name. Use 'client.apis."+s+"' instead of 'client.apis."+e+"'."),_.indexOf(reservedApiTags,a)>-1&&(helpers.log("The '"+a+"' operationId conflicts with a SwaggerClient operation function/property name. Use 'client.apis."+s+"._"+a+"' instead of 'client.apis."+s+"."+a+"'."),a="_"+a,n.nickname=a),_.isUndefined(r)){r=h[t]=h.apis[s]={},r.operations={},r.label=s,r.apis={};var o=i[e];_.isUndefined(o)||(r.description=o.description,r.externalDocs=o.externalDocs),h[t].help=_.bind(h.help,r),h.apisArray.push(new OperationGroup(e,r.description,r.externalDocs,n))}a=h.makeUniqueOperationId(a,h.apis[s]),_.isFunction(r.help)||(r.help=_.bind(h.help,r)),h.apis[s][a]=r[a]=_.bind(n.execute,n),h.apis[s][a].help=r[a].help=_.bind(n.help,n),h.apis[s][a].asCurl=r[a].asCurl=_.bind(n.asCurl,n),r.apis[a]=r.operations[a]=n;var l=_.find(h.apisArray,function(t){return t.tag===e});l&&l.operationsArray.push(n)})}})});var l=[];return _.forEach(Object.keys(i),function(e){var t;for(t in h.apisArray){var i=h.apisArray[t];i&&e===i.name&&(l.push(i),h.apisArray[t]=null)}}),_.forEach(h.apisArray,function(e){e&&l.push(e)}),h.apisArray=l,_.forEach(e.definitions,function(e,t){e.id=t.toLowerCase(),e.name=t,h.modelsArray.push(e)}),this.isBuilt=!0,this.usePromise?(this.isValid=!0,this.isBuilt=!0,this.deferredClient.resolve(this),this.deferredClient.promise):(this.success&&this.success(),this)},SwaggerClient.prototype.makeUniqueOperationId=function(e,t){for(var i=0,s=e;;){var r=!1;if(_.forEach(t.operations,function(e){e.nickname===s&&(r=!0)}),!r)return s;s=e+"_"+i,i++}return e},SwaggerClient.prototype.parseUri=function(e){var t=/^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/,i=t.exec(e);return{scheme:i[4]?i[4].replace(":",""):void 0,host:i[11],port:i[12],path:i[15]}},SwaggerClient.prototype.help=function(e){var t="";return this instanceof SwaggerClient?_.forEach(this.apis,function(e,i){_.isPlainObject(e)&&(t+="operations for the '"+i+"' tag\n",_.forEach(e.operations,function(e,i){t+=" * "+i+": "+e.summary+"\n"}))}):(this instanceof OperationGroup||_.isPlainObject(this))&&(t+="operations for the '"+this.label+"' tag\n",_.forEach(this.apis,function(e,i){t+=" * "+i+": "+e.summary+"\n"})),e?t:(helpers.log(t),t)},SwaggerClient.prototype.tagFromLabel=function(e){return e},SwaggerClient.prototype.idFromOp=function(e,t,i){i&&i.operationId||(i=i||{},i.operationId=t+"_"+e);var s=i.operationId.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|.\/?,\\'""-]/g,"_")||e.substring(1)+"_"+t;return s=s.replace(/((_){2,})/g,"_"),s=s.replace(/^(_)*/g,""),s=s.replace(/([_])*$/g,"")},SwaggerClient.prototype.setHost=function(e){this.host=e,this.apis&&_.forEach(this.apis,function(t){t.operations&&_.forEach(t.operations,function(t){t.host=e})})},SwaggerClient.prototype.setBasePath=function(e){this.basePath=e,this.apis&&_.forEach(this.apis,function(t){t.operations&&_.forEach(t.operations,function(t){t.basePath=e})})},SwaggerClient.prototype.setSchemes=function(e){this.schemes=e,e&&e.length>0&&this.apis&&_.forEach(this.apis,function(t){t.operations&&_.forEach(t.operations,function(t){t.scheme=e[0]})})},SwaggerClient.prototype.fail=function(e){return this.usePromise?(this.deferredClient.reject(e),this.deferredClient.promise):void(this.failure?this.failure(e):this.failure(e))};
},{"./auth":2,"./helpers":4,"./http":5,"./resolver":6,"./spec-converter":8,"./types/model":9,"./types/operation":10,"./types/operationGroup":11,"lodash-compat/array/indexOf":49,"lodash-compat/collection/find":53,"lodash-compat/collection/forEach":54,"lodash-compat/function/bind":58,"lodash-compat/lang/cloneDeep":138,"lodash-compat/lang/isArray":140,"lodash-compat/lang/isFunction":142,"lodash-compat/lang/isObject":144,"lodash-compat/lang/isPlainObject":145,"lodash-compat/lang/isUndefined":148,"q":157}],4:[function(require,module,exports){
(function (process){
"use strict";var _={isPlainObject:require("lodash-compat/lang/isPlainObject"),indexOf:require("lodash-compat/array/indexOf")};module.exports.__bind=function(e,o){return function(){return e.apply(o,arguments)}};var log=module.exports.log=function(){console&&"test"!==process.env.NODE_ENV&&console.log(Array.prototype.slice.call(arguments)[0])};module.exports.fail=function(e){log(e)};var optionHtml=module.exports.optionHtml=function(e,o){return'<tr><td class="optionName">'+e+":</td><td>"+o+"</td></tr>"},resolveSchema=module.exports.resolveSchema=function(e){return _.isPlainObject(e.schema)&&(e=resolveSchema(e.schema)),e},simpleRef=module.exports.simpleRef=function(e){return"undefined"==typeof e?null:0===e.indexOf("#/definitions/")?e.substring("#/definitions/".length):e};
}).call(this,require('_process'))
},{"_process":12,"lodash-compat/array/indexOf":49,"lodash-compat/lang/isPlainObject":145}],5:[function(require,module,exports){
"use strict";var helpers=require("./helpers"),request=require("superagent"),jsyaml=require("js-yaml"),_={isObject:require("lodash-compat/lang/isObject"),keys:require("lodash-compat/object/keys")},JQueryHttpClient=function(){this.type="JQueryHttpClient"},SuperagentHttpClient=function(){this.type="SuperagentHttpClient"},SwaggerHttp=module.exports=function(){};SwaggerHttp.prototype.execute=function(e,t){var r;r=t&&t.client?t.client:new SuperagentHttpClient(t),r.opts=t||{};var o=!1;if("undefined"!=typeof window&&"undefined"!=typeof window.jQuery&&(o=!0),"options"===e.method.toLowerCase()&&"SuperagentHttpClient"===r.type&&(log("forcing jQuery as OPTIONS are not supported by SuperAgent"),e.useJQuery=!0),this.isInternetExplorer()&&(e.useJQuery===!1||!o))throw new Error("Unsupported configuration! JQuery is required but not available");(e&&e.useJQuery===!0||this.isInternetExplorer()&&o)&&(r=new JQueryHttpClient(t));var n=e.on.response,s=e.on.error,a=function(e){return t&&t.requestInterceptor&&(e=t.requestInterceptor.apply(e)),e},i=function(e){return t&&t.responseInterceptor&&(e=t.responseInterceptor.apply(e)),n(e)},u=function(e){t&&t.responseInterceptor&&(e=t.responseInterceptor.apply(e)),s(e)};return e.on.error=function(e){u(e)},e.on.response=function(e){i(e)},_.isObject(e)&&_.isObject(e.body)&&e.body.type&&"formData"===e.body.type&&t.useJQuery&&(e.contentType=!1,e.processData=!1,delete e.headers["Content-Type"]),e=a(e)||e,e.beforeSend?e.beforeSend(function(t){r.execute(t||e)}):r.execute(e),e.deferred?e.deferred.promise:e},SwaggerHttp.prototype.isInternetExplorer=function(){var e=!1;if("undefined"!=typeof navigator&&navigator.userAgent){var t=navigator.userAgent.toLowerCase();if(-1!==t.indexOf("msie")){var r=parseInt(t.split("msie")[1]);8>=r&&(e=!0)}}return e},JQueryHttpClient.prototype.execute=function(e){var t=this.jQuery||"undefined"!=typeof window&&window.jQuery,r=e.on,o=e;if("undefined"==typeof t||t===!1)throw new Error("Unsupported configuration! JQuery is required but not available");return e.type=e.method,e.cache=e.jqueryAjaxCache,e.data=e.body,delete e.jqueryAjaxCache,delete e.useJQuery,delete e.body,e.complete=function(e){for(var t={},n=e.getAllResponseHeaders().split("\n"),s=0;s<n.length;s++){var a=n[s].trim();if(0!==a.length){var i=a.indexOf(":");if(-1!==i){var u=a.substring(0,i).trim(),p=a.substring(i+1).trim();t[u]=p}else t[a]=null}}var d={url:o.url,method:o.method,status:e.status,statusText:e.statusText,data:e.responseText,headers:t};try{var l=e.responseJSON||jsyaml.safeLoad(e.responseText);d.obj="string"==typeof l?{}:l}catch(y){helpers.log("unable to parse JSON/YAML content")}if(d.obj=d.obj||null,e.status>=200&&e.status<300)r.response(d);else{if(!(0===e.status||e.status>=400&&e.status<599))return r.response(d);r.error(d)}},t.support.cors=!0,t.ajax(e)},SuperagentHttpClient.prototype.execute=function(e){var t=e.method.toLowerCase(),r=e.timeout;"delete"===t&&(t="del");var o=e.headers||{},n=request[t](e.url);if(r&&n.timeout(r),e.enableCookies&&n.withCredentials(),e.body)if(_.isObject(e.body)){var s=e.headers["Content-Type"]||"";if(0===s.indexOf("multipart/form-data"))if(delete o["Content-Type"],"[object FormData]"==={}.toString.apply(e.body))for(var a=e.body.keys(),i=[];;){var u=a.next();if(u.done)break;var p=u.value;if(-1===i.indexOf(p)){i.push(p);var d=e.body.getAll(p);if("[object File]"==={}.toString.apply(d))n.attach(p,d);else if(Array.isArray(d))for(var u in d)n.field(p,d[u]);else n.field(p,d)}}else{var l;for(var l in e.body){var d=e.body[l];if(Array.isArray(d))for(var u in d)n.field(l,u);else n.field(l,d)}}else _.isObject(e.body)&&(e.body=JSON.stringify(e.body),n.send(e.body))}else n.send(e.body);var y;for(y in o)n.set(y,o[y]);"function"==typeof n.buffer&&n.buffer(),n.end(function(t,r){r=r||{status:0,headers:{error:"no response from server"}};var o,n={url:e.url,method:e.method,headers:r.headers};if(!t&&r.error&&(t=r.error),t&&e.on&&e.on.error){if(n.errObj=t,n.status=r?r.status:500,n.statusText=r?r.text:t.message,r.headers&&r.headers["content-type"]&&r.headers["content-type"].indexOf("application/json")>=0)try{n.obj=JSON.parse(n.statusText)}catch(s){n.obj=null}o=e.on.error}else if(r&&e.on&&e.on.response){var a;if(r.body&&_.keys(r.body).length>0)a=r.body;else try{a=jsyaml.safeLoad(r.text),a="string"==typeof a?null:a}catch(s){helpers.log("cannot parse JSON/YAML content")}n.obj="object"==typeof a?a:null,n.status=r.status,n.statusText=r.text,o=e.on.response}n.data=n.statusText,o&&o(n)})};
},{"./helpers":4,"js-yaml":19,"lodash-compat/lang/isObject":144,"lodash-compat/object/keys":149,"superagent":158}],6:[function(require,module,exports){
"use strict";function splitUrl(e){var i={},r=/[a-z]+:\/\//i.exec(e);r&&(i.proto=r[0].slice(0,-3),e=e.slice(i.proto.length+1)),"//"===e.slice(0,2)&&(i.domain=e.slice(2).split("/")[0],e=e.slice(2+i.domain.length));var t=e.split("#");return t[0].length&&(i.path=t[0]),t.length>1&&(i.fragment=t.slice(1).join("#")),i}function unsplitUrl(e){var i=e.path;return void 0===i&&(i=""),void 0!==e.fragment&&(i+="#"+e.fragment),void 0!==e.domain&&("/"===i.slice(0,1)&&(i=i.slice(1)),i="//"+e.domain+"/"+i,void 0!==e.proto&&(i=e.proto+":"+i)),i}function joinUrl(e,i){var r=splitUrl(i);if(void 0!==r.domain)return i;var t=splitUrl(e);if(void 0===r.path)t.fragment=r.fragment;else if("/"===r.path.slice(0,1))t.path=r.path,t.fragment=r.fragment;else{var o=void 0===t.path?[]:t.path.split("/"),s=r.path.split("/");for(o.length&&o.pop();".."===s[0]||"."===s[0];)".."===s[0]&&o.pop(),s.shift();t.path=o.concat(s).join("/"),t.fragment=r.fragment}return unsplitUrl(t)}var SwaggerHttp=require("./http"),_={isObject:require("lodash-compat/lang/isObject"),cloneDeep:require("lodash-compat/lang/cloneDeep"),isArray:require("lodash-compat/lang/isArray"),isString:require("lodash-compat/lang/isString")},Resolver=module.exports=function(){this.failedUrls=[],this.resolverCache={},this.pendingUrls={}};Resolver.prototype.processAllOf=function(e,i,r,t,o,s){var n,l,f;r["x-resolved-from"]=["#/definitions/"+i];var a=r.allOf;for(a.sort(function(e,i){return e.$ref&&i.$ref?0:e.$ref?-1:1}),n=0;n<a.length;n++)f=a[n],l="/definitions/"+i+"/allOf",this.resolveInline(e,s,f,t,o,l)},Resolver.prototype.resolve=function(e,i,r,t){this.spec=e;var o,s,n=i,l=r,f=t,a={};"function"==typeof i&&(n=null,l=i,f=r);var p=n;this.scope=f||this,this.iteration=this.iteration||0,this.scope.options&&this.scope.options.requestInterceptor&&(a.requestInterceptor=this.scope.options.requestInterceptor),this.scope.options&&this.scope.options.responseInterceptor&&(a.responseInterceptor=this.scope.options.responseInterceptor);var h,c,v,d,u=0,m={},g={},y=[];e.definitions=e.definitions||{};for(h in e.definitions){var O=e.definitions[h];if(O.$ref)this.resolveInline(n,e,O,y,g,O);else{for(d in O.properties)v=O.properties[d],_.isArray(v.allOf)?this.processAllOf(n,h,v,y,g,e):this.resolveTo(n,v,y,"/definitions");O.allOf&&this.processAllOf(n,h,O,y,g,e)}}e.parameters=e.parameters||{};for(h in e.parameters){var b=e.parameters[h];if("body"===b["in"]&&b.schema)if(_.isArray(b.schema.allOf)){for(var x="inline_model",h=x,j=!1,A=0;!j;){if("undefined"==typeof e.definitions[h]){j=!0;break}h=x+"_"+A,A++}e.definitions[h]={allOf:b.schema.allOf},delete b.schema.allOf,b.schema.$ref="#/definitions/"+h,this.processAllOf(n,h,e.definitions[h],y,g,e)}else this.resolveTo(n,b.schema,y,o);b.$ref&&this.resolveInline(n,e,b,y,g,b.$ref)}for(h in e.paths){var k,$,R;c=e.paths[h];for(k in c)if("$ref"===k)o="/paths"+h,this.resolveInline(n,e,c,y,g,o);else{$=c[k];var I=c.parameters||[],q=$.parameters||[];for(s in I){var b=I[s];q.unshift(b)}"parameters"!==k&&_.isObject($)&&($.parameters=$.parameters||q);for(s in q){var b=q[s];if(o="/paths"+h+"/"+k+"/parameters","body"===b["in"]&&b.schema)if(_.isArray(b.schema.allOf)){for(var x="inline_model",h=x,j=!1,A=0;!j;){if("undefined"==typeof e.definitions[h]){j=!0;break}h=x+"_"+A,A++}e.definitions[h]={allOf:b.schema.allOf},delete b.schema.allOf,b.schema.$ref="#/definitions/"+h,this.processAllOf(n,h,e.definitions[h],y,g,e)}else this.resolveTo(n,b.schema,y,o);b.$ref&&this.resolveInline(n,e,b,y,g,b.$ref)}for(R in $.responses){var U=$.responses[R];if(o="/paths"+h+"/"+k+"/responses/"+R,_.isObject(U)&&(U.$ref&&this.resolveInline(n,e,U,y,g,o),U.schema)){var w=U;if(_.isArray(w.schema.allOf)){for(var x="inline_model",h=x,j=!1,A=0;!j;){if("undefined"==typeof e.definitions[h]){j=!0;break}h=x+"_"+A,A++}e.definitions[h]={allOf:w.schema.allOf},delete w.schema.allOf,delete w.schema.type,w.schema.$ref="#/definitions/"+h,this.processAllOf(n,h,e.definitions[h],y,g,e)}else"array"===w.schema.type?w.schema.items&&w.schema.items.$ref&&this.resolveInline(n,e,w.schema.items,y,g,o):this.resolveTo(n,U.schema,y,o)}}}c.parameters=[]}var T,S=0,D=[],C=y;for(s=0;s<C.length;s++){var P=C[s];if(n===P.root){if("ref"===P.resolveAs){var z,H=((P.root||"")+"/"+P.key).split("/"),N=[],E="";if(P.key.indexOf("../")>=0){for(var J=0;J<H.length;J++)".."===H[J]?N=N.slice(0,N.length-1):N.push(H[J]);for(z=0;z<N.length;z++)z>0&&(E+="/"),E+=N[z];P.root=E,D.push(P)}else if(T=P.key.split("#"),2===T.length){0!==T[0].indexOf("http:")&&0!==T[0].indexOf("https:")||(P.root=T[0]),o=T[1].split("/");var Q,B=e;for(z=0;z<o.length;z++){var F=o[z];if(""!==F){if(B=B[F],"undefined"==typeof B){Q=null;break}Q=B}}null===Q&&D.push(P)}}else if("inline"===P.resolveAs){if(P.key&&-1===P.key.indexOf("#")&&"/"!==P.key.charAt(0)){for(T=P.root.split("/"),o="",s=0;s<T.length-1;s++)o+=T[s]+"/";o+=P.key,P.root=o,P.location=""}D.push(P)}}else D.push(P)}S=D.length;for(var G={},K=0;K<D.length;K++)!function(e,i,r,t,o){if(e.root&&e.root!==n)if(-1===r.failedUrls.indexOf(e.root)){var s={useJQuery:!1,url:e.root,method:"get",headers:{accept:r.scope.swaggerRequestHeaders||"application/json"},on:{error:function(o){u+=1,console.log("failed url: "+s.url),r.failedUrls.push(s.url),t&&delete t[e.root],g[e.key]={root:e.root,location:e.location},u===S&&r.finish(i,p,y,m,g,l)},response:function(o){var s=o.obj;t&&delete t[e.root],r.resolverCache&&(r.resolverCache[e.root]=s),r.resolveItem(s,e.root,y,m,g,e),u+=1,u===S&&r.finish(i,p,y,m,g,l)}}};f&&f.fetchSpecTimeout&&(s.timeout=f.fetchSpecTimeout),f&&f.clientAuthorizations&&f.clientAuthorizations.apply(s),function h(){setTimeout(function(){if(t[s.url])h();else{var e=r.resolverCache[s.url];_.isObject(e)?(s.on.response({obj:e}),1):(t[s.url]=!0,(new SwaggerHttp).execute(s,a))}},0)}()}else u+=1,g[e.key]={root:e.root,location:e.location},u===S&&r.finish(i,p,y,m,g,l);else r.resolveItem(i,p,y,m,g,e),u+=1,u===S&&r.finish(i,n,y,m,g,l,!0)}(D[K],e,this,G,K);0===Object.keys(D).length&&this.finish(e,p,y,m,g,l)},Resolver.prototype.resolveItem=function(e,i,r,t,o,s){var n=s.location,l=e,f=n.split("/");if(""!==n)for(var a=0;a<f.length;a++){var p=f[a];if(-1!==p.indexOf("~1")&&(p=f[a].replace(/~0/g,"~").replace(/~1/g,"/"),"/"!==p.charAt(0)&&(p="/"+p)),"undefined"==typeof l||null===l)break;if(""===p&&a===f.length-1&&f.length>1){l=null;break}p.length>0&&(l=l[p])}var h=s.key;f=s.key.split("/");var c=f[f.length-1];c.indexOf("#")>=0&&(c=c.split("#")[1]),null!==l&&"undefined"!=typeof l?t[h]={name:c,obj:l,key:s.key,root:s.root}:o[h]={root:s.root,location:s.location}},Resolver.prototype.finish=function(e,i,r,t,o,s,n){var l;for(l in r){var f=r[l],a=f.key,p=t[a];if(p)if(e.definitions=e.definitions||{},"ref"===f.resolveAs){if(n!==!0)for(a in p.obj){var h=this.retainRoot(a,p.obj[a],f.root);p.obj[a]=h}e.definitions[p.name]=p.obj,f.obj.$ref="#/definitions/"+p.name}else if("inline"===f.resolveAs){var c=f.obj;c["x-resolved-from"]=[f.key],delete c.$ref;for(a in p.obj){var h=p.obj[a];n!==!0&&(h=this.retainRoot(a,p.obj[a],f.root)),c[a]=h}}}var v=this.countUnresolvedRefs(e);0===v||this.iteration>5?(this.resolveAllOf(e.definitions),this.resolverCache=null,s.call(this.scope,e,o)):(this.iteration+=1,this.resolve(e,i,s,this.scope))},Resolver.prototype.countUnresolvedRefs=function(e){var i,r=this.getRefs(e),t=[],o=[];for(i in r)0===i.indexOf("#")?t.push(i.substring(1)):o.push(i);for(i=0;i<t.length;i++)for(var s=t[i],n=s.split("/"),l=e,f=0;f<n.length;f++){var a=n[f];if(""!==a&&(l=l[a],"undefined"==typeof l)){o.push(s);break}}return o.length},Resolver.prototype.getRefs=function(e,i){i=i||e;var r={};for(var t in i)if(i.hasOwnProperty(t)){var o=i[t];if("$ref"===t&&"string"==typeof o)r[o]=null;else if(_.isObject(o)){var s=this.getRefs(o);for(var n in s)r[n]=null}}return r},Resolver.prototype.retainRoot=function(e,i,r){if(_.isObject(i))for(var t in i){var o=i[t];"$ref"===t&&"string"==typeof o?i[t]=joinUrl(r,o):_.isObject(o)&&this.retainRoot(t,o,r)}else _.isString(i)&&"$ref"===e&&(i=joinUrl(r,i));return i},Resolver.prototype.resolveInline=function(e,i,r,t,o,s){var n,l,f,a,p=r.$ref,h=r.$ref,c=!1;if(e=e||"",h){if(0===h.indexOf("../")){for(l=h.split("../"),f=e.split("/"),h="",n=0;n<l.length;n++)""===l[n]?f=f.slice(0,f.length-1):h+=l[n];for(e="",n=0;n<f.length-1;n++)n>0&&(e+="/"),e+=f[n];c=!0}if(h.indexOf("#")>=0)if(0===h.indexOf("/"))a=h.split("#"),l=e.split("//"),f=l[1].split("/"),e=l[0]+"//"+f[0]+a[0],s=a[1];else{if(a=h.split("#"),""!==a[0]){if(f=e.split("/"),f=f.slice(0,f.length-1),!c){e="";for(var v=0;v<f.length;v++)v>0&&(e+="/"),e+=f[v]}e+="/"+h.split("#")[0]}s=a[1]}if(0===h.indexOf("http:")||0===h.indexOf("https:"))h.indexOf("#")>=0?(e=h.split("#")[0],s=h.split("#")[1]):(e=h,s=""),t.push({obj:r,resolveAs:"inline",root:e,key:p,location:s});else if(0===h.indexOf("#"))s=h.split("#")[1],t.push({obj:r,resolveAs:"inline",root:e,key:p,location:s});else if(0===h.indexOf("/")&&-1===h.indexOf("#")){s=h;var d=e.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);d&&(e=d[0]+h.substring(1),s=""),t.push({obj:r,resolveAs:"inline",root:e,key:p,location:s})}else t.push({obj:r,resolveAs:"inline",root:e,key:p,location:s})}else"array"===r.type&&this.resolveTo(e,r.items,t,s)},Resolver.prototype.resolveTo=function(e,i,r,t){var o,s,n=i.$ref,l=e;if("undefined"!=typeof n&&null!==n){if(n.indexOf("#")>=0){var f=n.split("#");if(f[0]&&0===n.indexOf("/"));else if(!f[0]||0!==f[0].indexOf("http:")&&0!==f[0].indexOf("https:")){if(f[0]&&f[0].length>0){for(o=e.split("/"),l="",s=0;s<o.length-1;s++)l+=o[s]+"/";l+=f[0]}}else l=f[0],n=f[1];t=f[1]}else if(0===n.indexOf("http:")||0===n.indexOf("https:"))l=n,t="";else{for(o=e.split("/"),l="",s=0;s<o.length-1;s++)l+=o[s]+"/";l+=n,t=""}r.push({obj:i,resolveAs:"ref",root:l,key:n,location:t})}else if("array"===i.type){var a=i.items;this.resolveTo(e,a,r,t)}else if(i&&(i.properties||i.additionalProperties)){var p=this.uniqueName("inline_model");i.title&&(p=this.uniqueName(i.title)),delete i.title,this.spec.definitions[p]=_.cloneDeep(i),i.$ref="#/definitions/"+p,delete i.type,delete i.properties}},Resolver.prototype.uniqueName=function(e){for(var i=e,r=0;;){if(!_.isObject(this.spec.definitions[i]))return i;i=e+"_"+r,r++}},Resolver.prototype.resolveAllOf=function(e,i,r){r=r||0,i=i||e;var t;for(var o in i)if(i.hasOwnProperty(o)){var s=i[o];if(null===s)throw new TypeError("Swagger 2.0 does not support null types ("+i+"). See https://github.com/swagger-api/swagger-spec/issues/229.");if("object"==typeof s&&this.resolveAllOf(e,s,r+1),s&&"undefined"!=typeof s.allOf){var n=s.allOf;if(_.isArray(n)){var l=_.cloneDeep(s);delete l.allOf,l["x-composed"]=!0,"undefined"!=typeof s["x-resolved-from"]&&(l["x-resolved-from"]=s["x-resolved-from"]);for(var f=0;f<n.length;f++){var a=n[f],p="self";"undefined"!=typeof a["x-resolved-from"]&&(p=a["x-resolved-from"][0]);for(var h in a)if(l.hasOwnProperty(h))if("properties"===h){var c=a[h];for(t in c){l.properties[t]=_.cloneDeep(c[t]);var v=c[t]["x-resolved-from"];"undefined"!=typeof v&&"self"!==v||(v=p),l.properties[t]["x-resolved-from"]=v}}else if("required"===h){for(var d=l.required.concat(a[h]),u=0;u<d.length;++u)for(var m=u+1;m<d.length;++m)d[u]===d[m]&&d.splice(m--,1);l.required=d}else"x-resolved-from"===h&&l["x-resolved-from"].push(p);else if(l[h]=_.cloneDeep(a[h]),"properties"===h)for(t in l[h])l[h][t]["x-resolved-from"]=p}i[o]=l}}}};
},{"./http":5,"lodash-compat/lang/cloneDeep":138,"lodash-compat/lang/isArray":140,"lodash-compat/lang/isObject":144,"lodash-compat/lang/isString":146}],7:[function(require,module,exports){
"use strict";function optionHtml(e,t){return'<tr><td class="optionName">'+e+":</td><td>"+t+"</td></tr>"}function typeFromJsonSchema(e,t){var i;return"integer"===e&&"int32"===t?i="integer":"integer"===e&&"int64"===t?i="long":"integer"===e&&"undefined"==typeof t?i="long":"string"===e&&"date-time"===t?i="date-time":"string"===e&&"date"===t?i="date":"number"===e&&"float"===t?i="float":"number"===e&&"double"===t?i="double":"number"===e&&"undefined"==typeof t?i="double":"boolean"===e?i="boolean":"string"===e&&(i="string"),i}function getStringSignature(e,t){var i="";return"undefined"!=typeof e.$ref?i+=Helpers.simpleRef(e.$ref):"undefined"==typeof e.type?i+="object":"array"===e.type?t?i+=getStringSignature(e.items||e.$ref||{}):(i+="Array[",i+=getStringSignature(e.items||e.$ref||{}),i+="]"):i+="integer"===e.type&&"int32"===e.format?"integer":"integer"===e.type&&"int64"===e.format?"long":"integer"===e.type&&"undefined"==typeof e.format?"long":"string"===e.type&&"date-time"===e.format?"date-time":"string"===e.type&&"date"===e.format?"date":"string"===e.type&&"undefined"==typeof e.format?"string":"number"===e.type&&"float"===e.format?"float":"number"===e.type&&"double"===e.format?"double":"number"===e.type&&"undefined"==typeof e.format?"double":"boolean"===e.type?"boolean":e.$ref?Helpers.simpleRef(e.$ref):e.type,i}function schemaToJSON(e,t,i,n){e=Helpers.resolveSchema(e),"function"!=typeof n&&(n=function(e){return(e||{})["default"]}),i=i||{};var r,o,s=e.type||"object",a=e.format;return _.isUndefined(e.example)?_.isUndefined(e.items)&&_.isArray(e["enum"])&&(o=e["enum"][0]):o=e.example,_.isUndefined(o)&&(e.$ref?(r=t[Helpers.simpleRef(e.$ref)],_.isUndefined(r)||(_.isUndefined(i[r.name])?(i[r.name]=r,o=schemaToJSON(r.definition,t,i,n),delete i[r.name]):o="array"===r.type?[]:{})):_.isUndefined(e["default"])?"string"===s?o="date-time"===a?(new Date).toISOString():"date"===a?(new Date).toISOString().split("T")[0]:"string":"integer"===s?o=0:"number"===s?o=0:"boolean"===s?o=!0:"object"===s?(o={},_.forEach(e.properties,function(e,r){var s=_.cloneDeep(e);s["default"]=n(e),o[r]=schemaToJSON(s,t,i,n)})):"array"===s&&(o=[],_.isArray(e.items)?_.forEach(e.items,function(e){o.push(schemaToJSON(e,t,i,n))}):_.isPlainObject(e.items)?o.push(schemaToJSON(e.items,t,i,n)):_.isUndefined(e.items)?o.push({}):Helpers.log("Array type's 'items' property is not an array or an object, cannot process")):o=e["default"]),o}function schemaToHTML(e,t,i,n){function r(e,t,n){var r,o=t;return e.$ref?(o=e.title||Helpers.simpleRef(e.$ref),r=i[o]):_.isUndefined(t)&&(o=e.title||"Inline Model "+ ++f,r={definition:e}),n!==!0&&(l[o]=_.isUndefined(r)?{}:r.definition),o}function o(e){var t='<span class="propType">',i=e.type||"object";return e.$ref?t+=r(e,Helpers.simpleRef(e.$ref)):"object"===i?t+=_.isUndefined(e.properties)?"object":r(e):"array"===i?(t+="Array[",_.isArray(e.items)?t+=_.map(e.items,r).join(","):_.isPlainObject(e.items)?t+=_.isUndefined(e.items.$ref)?_.isUndefined(e.items.type)||-1!==_.indexOf(["array","object"],e.items.type)?r(e.items):e.items.type:r(e.items,Helpers.simpleRef(e.items.$ref)):(Helpers.log("Array type's 'items' schema is not an array or an object, cannot process"),t+="object"),t+="]"):t+=e.type,t+="</span>"}function s(e,t){var i="",n=e.type||"object",r="array"===n;switch(r&&(n=_.isPlainObject(e.items)&&!_.isUndefined(e.items.type)?e.items.type:"object"),_.isUndefined(e["default"])||(i+=optionHtml("Default",e["default"])),n){case"string":e.minLength&&(i+=optionHtml("Min. Length",e.minLength)),e.maxLength&&(i+=optionHtml("Max. Length",e.maxLength)),e.pattern&&(i+=optionHtml("Reg. Exp.",e.pattern));break;case"integer":case"number":e.minimum&&(i+=optionHtml("Min. Value",e.minimum)),e.exclusiveMinimum&&(i+=optionHtml("Exclusive Min.","true")),e.maximum&&(i+=optionHtml("Max. Value",e.maximum)),e.exclusiveMaximum&&(i+=optionHtml("Exclusive Max.","true")),e.multipleOf&&(i+=optionHtml("Multiple Of",e.multipleOf))}if(r&&(e.minItems&&(i+=optionHtml("Min. Items",e.minItems)),e.maxItems&&(i+=optionHtml("Max. Items",e.maxItems)),e.uniqueItems&&(i+=optionHtml("Unique Items","true")),e.collectionFormat&&(i+=optionHtml("Coll. Format",e.collectionFormat))),_.isUndefined(e.items)&&_.isArray(e["enum"])){var o;o="number"===n||"integer"===n?e["enum"].join(", "):'"'+e["enum"].join('", "')+'"',i+=optionHtml("Enum",o)}return i.length>0&&(t='<span class="propWrap">'+t+'<table class="optionsWrapper"><tr><th colspan="2">'+n+"</th></tr>"+i+"</table></span>"),t}function a(e,t){var a=e.type||"object",l="array"===e.type,f=p+t+" "+(l?"[":"{")+m;if(t&&d.push(t),l)_.isArray(e.items)?f+="<div>"+_.map(e.items,function(e){var t=e.type||"object";return _.isUndefined(e.$ref)?_.indexOf(["array","object"],t)>-1?"object"===t&&_.isUndefined(e.properties)?"object":r(e):s(e,t):r(e,Helpers.simpleRef(e.$ref))}).join(",</div><div>"):_.isPlainObject(e.items)?f+=_.isUndefined(e.items.$ref)?_.indexOf(["array","object"],e.items.type||"object")>-1?(_.isUndefined(e.items.type)||"object"===e.items.type)&&_.isUndefined(e.items.properties)?"<div>object</div>":"<div>"+r(e.items)+"</div>":"<div>"+s(e.items,e.items.type)+"</div>":"<div>"+r(e.items,Helpers.simpleRef(e.items.$ref))+"</div>":(Helpers.log("Array type's 'items' property is not an array or an object, cannot process"),f+="<div>object</div>");else if(e.$ref)f+="<div>"+r(e,t)+"</div>";else if("object"===a){if(_.isPlainObject(e.properties)){var c=_.map(e.properties,function(t,r){var a,p,m=_.indexOf(e.required,r)>=0,l=_.cloneDeep(t),d=m?"required":"",f='<span class="propName '+d+'">'+r+"</span> (";return l["default"]=n(l),l=Helpers.resolveSchema(l),p=t.description||l.description,_.isUndefined(l.$ref)||(a=i[Helpers.simpleRef(l.$ref)],_.isUndefined(a)||-1!==_.indexOf([void 0,"array","object"],a.definition.type)||(l=Helpers.resolveSchema(a.definition))),f+=o(l),m||(f+=', <span class="propOptKey">optional</span>'),t.readOnly&&(f+=', <span class="propReadOnly">read only</span>'),f+=")",_.isUndefined(p)||(f+=': <span class="propDesc">'+p+"</span>"),l["enum"]&&(f+=' = <span class="propVals">[\''+l["enum"].join("', '")+"']</span>"),"<div"+(t.readOnly?' class="readOnly"':"")+">"+s(l,f)}).join(",</div>");c&&(f+=c+"</div>")}}else f+="<div>"+s(e,a)+"</div>";return f+p+(l?"]":"}")+m}var p='<span class="strong">',m="</span>";if(_.isObject(arguments[0])&&(e=void 0,t=arguments[0],i=arguments[1],n=arguments[2]),i=i||{},t=Helpers.resolveSchema(t),_.isEmpty(t))return p+"Empty"+m;if("string"==typeof t.$ref&&(e=Helpers.simpleRef(t.$ref),t=i[e],"undefined"==typeof t))return p+e+" is not defined!"+m;"string"!=typeof e&&(e=t.title||"Inline Model"),t.definition&&(t=t.definition),"function"!=typeof n&&(n=function(e){return(e||{})["default"]});for(var l={},d=[],f=0,c=a(t,e);_.keys(l).length>0;)_.forEach(l,function(e,t){var i=_.indexOf(d,t)>-1;delete l[t],i||(d.push(t),c+="<br />"+a(e,t))});return c}var Helpers=require("./helpers"),_={isPlainObject:require("lodash-compat/lang/isPlainObject"),isUndefined:require("lodash-compat/lang/isUndefined"),isArray:require("lodash-compat/lang/isArray"),isObject:require("lodash-compat/lang/isObject"),isEmpty:require("lodash-compat/lang/isEmpty"),map:require("lodash-compat/collection/map"),indexOf:require("lodash-compat/array/indexOf"),cloneDeep:require("lodash-compat/lang/cloneDeep"),keys:require("lodash-compat/object/keys"),forEach:require("lodash-compat/collection/forEach")};module.exports.optionHtml=optionHtml,module.exports.typeFromJsonSchema=typeFromJsonSchema,module.exports.getStringSignature=getStringSignature,module.exports.schemaToHTML=schemaToHTML,module.exports.schemaToJSON=schemaToJSON;
},{"./helpers":4,"lodash-compat/array/indexOf":49,"lodash-compat/collection/forEach":54,"lodash-compat/collection/map":56,"lodash-compat/lang/cloneDeep":138,"lodash-compat/lang/isArray":140,"lodash-compat/lang/isEmpty":141,"lodash-compat/lang/isObject":144,"lodash-compat/lang/isPlainObject":145,"lodash-compat/lang/isUndefined":148,"lodash-compat/object/keys":149}],8:[function(require,module,exports){
"use strict";var SwaggerHttp=require("./http"),_={isObject:require("lodash-compat/lang/isObject")},SwaggerSpecConverter=module.exports=function(){this.errors=[],this.warnings=[],this.modelMap={}};SwaggerSpecConverter.prototype.setDocumentationLocation=function(e){this.docLocation=e},SwaggerSpecConverter.prototype.convert=function(e,t,r,i){if(!e||!Array.isArray(e.apis))return this.finish(i,null);this.clientAuthorizations=t;var s={swagger:"2.0"};s.originalVersion=e.swaggerVersion,this.apiInfo(e,s),this.securityDefinitions(e,s),e.basePath&&this.setDocumentationLocation(e.basePath);var n,o=!1;for(n=0;n<e.apis.length;n++){var a=e.apis[n];Array.isArray(a.operations)&&(o=!0)}o?(this.declaration(e,s),this.finish(i,s)):this.resourceListing(e,s,r,i)},SwaggerSpecConverter.prototype.declaration=function(e,t){var r,i,s,n;if(e.apis){0===e.basePath.indexOf("http://")?(s=e.basePath.substring("http://".length),n=s.indexOf("/"),n>0?(t.host=s.substring(0,n),t.basePath=s.substring(n)):(t.host=s,t.basePath="/")):0===e.basePath.indexOf("https://")?(s=e.basePath.substring("https://".length),n=s.indexOf("/"),n>0?(t.host=s.substring(0,n),t.basePath=s.substring(n)):(t.host=s,t.basePath="/")):t.basePath=e.basePath;var o;if(e.authorizations&&(o=e.authorizations),e.consumes&&(t.consumes=e.consumes),e.produces&&(t.produces=e.produces),_.isObject(e))for(r in e.models){var a=e.models[r],p=a.id||r;this.modelMap[p]=r}for(i=0;i<e.apis.length;i++){var u=e.apis[i],c=u.path,f=u.operations;this.operations(c,e.resourcePath,f,o,t)}var h=e.models||{};this.models(h,t)}},SwaggerSpecConverter.prototype.models=function(e,t){if(_.isObject(e)){var r;t.definitions=t.definitions||{};for(r in e){var i,s=e[r],n=[],o={properties:{}};for(i in s.properties){var a=s.properties[i],p={};this.dataType(a,p),a.description&&(p.description=a.description),a["enum"]&&(p["enum"]=a["enum"]),"boolean"==typeof a.required&&a.required===!0&&n.push(i),"string"==typeof a.required&&"true"===a.required&&n.push(i),o.properties[i]=p}n.length>0?o.required=n:o.required=s.required,t.definitions[r]=o}}},SwaggerSpecConverter.prototype.extractTag=function(e){var t=e||"default";return 0!==t.indexOf("http:")&&0!==t.indexOf("https:")||(t=t.split(["/"]),t=t[t.length-1].substring()),t.endsWith(".json")&&(t=t.substring(0,t.length-".json".length)),t.replace("/","")},SwaggerSpecConverter.prototype.operations=function(e,t,r,i,s){if(Array.isArray(r)){var n;s.paths||(s.paths={});var o=s.paths[e]||{},a=this.extractTag(t);s.tags=s.tags||[];var p=!1;for(n=0;n<s.tags.length;n++){var u=s.tags[n];u.name===a&&(p=!0)}for(p||s.tags.push({name:a}),n=0;n<r.length;n++){var c=r[n],f=(c.method||c.httpMethod).toLowerCase(),h={tags:[a]},l=c.authorizations;if(l&&0===Object.keys(l).length&&(l=i),"undefined"!=typeof l){var m;for(var d in l){h.security=h.security||[];var g=l[d];if(g){var y=[];for(var v in g)y.push(g[v].scope);m={},m[d]=y,h.security.push(m)}else m={},m[d]=[],h.security.push(m)}}c.consumes?h.consumes=c.consumes:s.consumes&&(h.consumes=s.consumes),c.produces?h.produces=c.produces:s.produces&&(h.produces=s.produces),c.summary&&(h.summary=c.summary),c.notes&&(h.description=c.notes),c.nickname&&(h.operationId=c.nickname),c.deprecated&&(h.deprecated=c.deprecated),this.authorizations(l,s),this.parameters(h,c.parameters,s),this.responseMessages(h,c,s),o[f]=h}s.paths[e]=o}},SwaggerSpecConverter.prototype.responseMessages=function(e,t){if(_.isObject(t)){var r={};this.dataType(t,r),!r.schema&&r.type&&(r={schema:r}),e.responses=e.responses||{};var i=!1;if(Array.isArray(t.responseMessages)){var s,n=t.responseMessages;for(s=0;s<n.length;s++){var o=n[s],a={description:o.message};200===o.code&&(i=!0),o.responseModel&&(a.schema={$ref:"#/definitions/"+o.responseModel}),e.responses[""+o.code]=a}}i?e.responses["default"]=r:e.responses[200]=r}},SwaggerSpecConverter.prototype.authorizations=function(e){!_.isObject(e)},SwaggerSpecConverter.prototype.parameters=function(e,t){if(Array.isArray(t)){var r;for(r=0;r<t.length;r++){var i=t[r],s={};if(s.name=i.name,s.description=i.description,s.required=i.required,s["in"]=i.paramType,"body"===s["in"]&&(s.name="body"),"form"===s["in"]&&(s["in"]="formData"),i["enum"]&&(s["enum"]=i["enum"]),i.allowMultiple===!0||"true"===i.allowMultiple){var n={};if(this.dataType(i,n),s.type="array",s.items=n,i.allowableValues){var o=i.allowableValues;"LIST"===o.valueType&&(s["enum"]=o.values)}}else this.dataType(i,s);"undefined"!=typeof i.defaultValue&&(s["default"]=i.defaultValue),e.parameters=e.parameters||[],e.parameters.push(s)}}},SwaggerSpecConverter.prototype.dataType=function(e,t){if(_.isObject(e)){e.minimum&&(t.minimum=e.minimum),e.maximum&&(t.maximum=e.maximum),e.format&&(t.format=e.format),"undefined"!=typeof e.defaultValue&&(t["default"]=e.defaultValue);var r=this.toJsonSchema(e);r&&(t=t||{},r.type&&(t.type=r.type),r.format&&(t.format=r.format),r.$ref&&(t.schema={$ref:r.$ref}),r.items&&(t.items=r.items))}},SwaggerSpecConverter.prototype.toJsonSchema=function(e){if(!e)return"object";var t=e.type||e.dataType||e.responseClass||"",r=t.toLowerCase(),i=(e.format||"").toLowerCase();if(0===r.indexOf("list[")){var s=t.substring(5,t.length-1),n=this.toJsonSchema({type:s});return{type:"array",items:n}}if("int"===r||"integer"===r&&"int32"===i)return{type:"integer",format:"int32"};if("long"===r||"integer"===r&&"int64"===i)return{type:"integer",format:"int64"};if("integer"===r)return{type:"integer",format:"int64"};if("float"===r||"number"===r&&"float"===i)return{type:"number",format:"float"};if("double"===r||"number"===r&&"double"===i)return{type:"number",format:"double"};if("string"===r&&"date-time"===i||"date"===r)return{type:"string",format:"date-time"};if("string"===r)return{type:"string"};if("file"===r)return{type:"file"};if("boolean"===r)return{type:"boolean"};if("boolean"===r)return{type:"boolean"};if("array"===r||"list"===r){if(e.items){var o=this.toJsonSchema(e.items);return{type:"array",items:o}}return{type:"array",items:{type:"object"}}}return e.$ref?{$ref:this.modelMap[e.$ref]?"#/definitions/"+this.modelMap[e.$ref]:e.$ref}:"void"===r||""===r?{}:this.modelMap[e.type]?{$ref:"#/definitions/"+this.modelMap[e.type]}:{type:e.type}},SwaggerSpecConverter.prototype.resourceListing=function(e,t,r,i){var s,n=0,o=this,a=e.apis.length,p=t,u={};r&&r.requestInterceptor&&(u.requestInterceptor=r.requestInterceptor),r&&r.responseInterceptor&&(u.responseInterceptor=r.responseInterceptor);var c="application/json";for(r&&r.swaggerRequestHeaders&&(c=r.swaggerRequestHeaders),0===a&&this.finish(i,t),s=0;a>s;s++){var f=e.apis[s],h=f.path,l=this.getAbsolutePath(e.swaggerVersion,this.docLocation,h);f.description&&(t.tags=t.tags||[],t.tags.push({name:this.extractTag(f.path),description:f.description||""}));var m={url:l,headers:{accept:c},on:{},method:"get",timeout:r.timeout};m.on.response=function(e){n+=1;var t=e.obj;t&&o.declaration(t,p),n===a&&o.finish(i,p)},m.on.error=function(e){console.error(e),n+=1,n===a&&o.finish(i,p)},this.clientAuthorizations&&"function"==typeof this.clientAuthorizations.apply&&this.clientAuthorizations.apply(m),(new SwaggerHttp).execute(m,u)}},SwaggerSpecConverter.prototype.getAbsolutePath=function(e,t,r){if("1.0"===e&&t.endsWith(".json")){var i=t.lastIndexOf("/");i>0&&(t=t.substring(0,i))}var s=t;return 0===r.indexOf("http:")||0===r.indexOf("https:")?s=r:(t.endsWith("/")&&(s=t.substring(0,t.length-1)),s+=r),s=s.replace("{format}","json")},SwaggerSpecConverter.prototype.securityDefinitions=function(e,t){if(e.authorizations){var r;for(r in e.authorizations){var i=!1,s={},n=e.authorizations[r];if("apiKey"===n.type)s.type="apiKey",s["in"]=n.passAs,s.name=n.keyname||r,i=!0;else if("basicAuth"===n.type)s.type="basicAuth",i=!0;else if("oauth2"===n.type){var o,a=n.scopes||[],p={};for(o in a){var u=a[o];p[u.scope]=u.description}if(s.type="oauth2",o>0&&(s.scopes=p),n.grantTypes){if(n.grantTypes.implicit){var c=n.grantTypes.implicit;s.flow="implicit",s.authorizationUrl=c.loginEndpoint,i=!0}if(n.grantTypes.authorization_code&&!s.flow){var f=n.grantTypes.authorization_code;s.flow="accessCode",s.authorizationUrl=f.tokenRequestEndpoint.url,s.tokenUrl=f.tokenEndpoint.url,i=!0}}}i&&(t.securityDefinitions=t.securityDefinitions||{},t.securityDefinitions[r]=s)}}},SwaggerSpecConverter.prototype.apiInfo=function(e,t){if(e.info){var r=e.info;t.info={},r.contact&&(t.info.contact={},t.info.contact.email=r.contact),r.description&&(t.info.description=r.description),r.title&&(t.info.title=r.title),r.termsOfServiceUrl&&(t.info.termsOfService=r.termsOfServiceUrl),(r.license||r.licenseUrl)&&(t.license={},r.license&&(t.license.name=r.license),r.licenseUrl&&(t.license.url=r.licenseUrl))}else this.warnings.push("missing info section")},SwaggerSpecConverter.prototype.finish=function(e,t){e(t)};
},{"./http":5,"lodash-compat/lang/isObject":144}],9:[function(require,module,exports){
"use strict";var log=require("../helpers").log,_={isPlainObject:require("lodas