';
+ var stronger = '';
+ var strongClose = '';
+ var classOpen = strong + 'array' + ' {' + strongClose;
+ var classClose = strong + '}' + strongClose;
+ var returnVal = classOpen + '' + propertiesStr.join(',
') + '
' + classClose;
- if(this.ref) {
- return models[simpleRef(this.ref)].getMockSignature();
+ if (!modelsToIgnore)
+ modelsToIgnore = {};
+ modelsToIgnore[this.name] = this;
+ for (i = 0; i < this.properties.length; i++) {
+ prop = this.properties[i];
+ var ref = prop.$ref;
+ var model = models[ref];
+ if (model && typeof modelsToIgnore[ref] === 'undefined') {
+ returnVal = returnVal + ('
' + model.getMockSignature(modelsToIgnore));
+ }
}
+ return returnVal;
};
@@ -2356,7 +2377,7 @@ SwaggerOperation.prototype.urlify = function (args) {
if (param.paramType === 'path') {
if (typeof args[param.name] !== 'undefined') {
// apply path params and remove from args
- var reg = new RegExp('\\{\\s*?' + param.name + '.*?\\}(?=\\s*?(\\/?|$))', 'gi');
+ var reg = new RegExp('\\{\\s*?' + param.name + '[^\\{\\}\\/]*(?:\\{.*?\\}[^\\{\\}\\/]*)*\\}(?=(\\/?|$))', 'gi');
url = url.replace(reg, this.encodePathParam(args[param.name]));
delete args[param.name];
}
diff --git a/lib/swagger-client.min.js b/lib/swagger-client.min.js
index c21506fb7..c2e181c70 100644
--- a/lib/swagger-client.min.js
+++ b/lib/swagger-client.min.js
@@ -1,2 +1,2 @@
-!function(){var e=function(e){this.name="arrayModel",this.definition=e||{},this.properties=[];var t=(e["enum"]||[],e.items);return t&&(t.type?this.type=typeFromJsonSchema(t.type,t.format):this.ref=t.$ref),this};e.prototype.createJSONSample=function(e){var t;if(e=e||{},this.type)t=this.type;else if(this.ref){var s=simpleRef(this.ref);if("undefined"!=typeof e[s])return s;e[s]=this,t=g[s].createJSONSample(e)}return[t]},e.prototype.getSampleValue=function(e){var t;if(e=e||{},this.type)t=type;else if(this.ref){var s=simpleRef(this.ref);t=g[s].getSampleValue(e)}return[t]},e.prototype.getMockSignature=function(){return this.ref?g[simpleRef(this.ref)].getMockSignature():void 0};var t=function(){this.authz={}};t.prototype.add=function(e,t){return this.authz[e]=t,t},t.prototype.remove=function(e){return delete this.authz[e]},t.prototype.apply=function(e,t){var s,r,i,n,a=null;if("undefined"==typeof t||0===Object.keys(t).length)for(s in this.authz)i=this.authz[s],n=i.apply(e,t),n===!0&&(a=!0);else if(Array.isArray(t))for(var o=0;o0?e.url+"&"+this.name+"="+this.value:e.url+"?"+this.name+"="+this.value,!0):"header"===this.type?(e.headers[this.name]=this.value,!0):void 0};var i=function(e){this.cookie=e};i.prototype.apply=function(e){return e.cookieJar=e.cookieJar||CookieJar(),e.cookieJar.setCookie(this.cookie),!0};var n=function(e,t,s){this.name=e,this.username=t,this.password=s,this._btoa=null,this._btoa="undefined"!=typeof window?btoa:require("btoa")};n.prototype.apply=function(e){var t=this._btoa;return e.headers.Authorization="Basic "+t(this.username+":"+this.password),!0};var a=function(e,t){return function(){return e.apply(t,arguments)}};fail=function(e){log(e)},log=function(){log.history=log.history||[],log.history.push(arguments),this.console&&console.log(Array.prototype.slice.call(arguments)[0])},Array.prototype.indexOf||(Array.prototype.indexOf=function(e,t){for(var s=t||0,r=this.length;r>s;s++)if(this[s]===e)return s;return-1});var o=function(e,t){var s="undefined"!=typeof window?window:exports;return s.parameterMacro?s.parameterMacro(e,t):t.defaultValue},p=function(e,t){var s="undefined"!=typeof window?window:exports;return s.modelPropertyMacro?s.modelPropertyMacro(e,t):t.defaultValue},u=function(e){this.name="name",this.definition=e||{},this.properties=[];e["enum"]||[];this.type=typeFromJsonSchema(e.type,e.format)};u.prototype.createJSONSample=function(){var e=this.type;return e},u.prototype.getSampleValue=function(){this.type;return null},u.prototype.getMockSignature=function(e){var t,s,r=[];for(t=0;t",a=i+this.name+" {"+n,o=i+"}"+n,p=a+""+r.join(",
")+"
"+o;for(e||(e={}),e[this.name]=this,t=0;t"+h.getMockSignature(e))}return p};var h=function(e,t){g[e]=t},l=function(e,t){return this.isBuilt=!1,this.url=null,this.debug=!1,this.basePath=null,this.modelsArray=[],this.authorizations=null,this.authorizationScheme=null,this.isValid=!1,this.info=null,this.useJQuery=!1,this.resourceCount=0,"undefined"!=typeof e?this.initialize(e,t):void 0};l.prototype.initialize=function(e,t){if(this.models=g={},t=t||{},"string"==typeof e?this.url=e:"object"==typeof e&&(t=e,this.url=t.url),this.swaggerRequstHeaders=t.swaggerRequstHeaders||"application/json;charset=utf-8,*/*",this.defaultSuccessCallback=t.defaultSuccessCallback||null,this.defaultErrorCallback=t.defaultErrorCallback||null,"function"==typeof t.success&&(this.success=t.success),t.useJQuery&&(this.useJQuery=t.useJQuery),t.authorizations)this.clientAuthorizations=t.authorizations;else{var s="undefined"!=typeof window?window:exports;this.clientAuthorizations=s.authorizations}this.supportedSubmitMethods=t.supportedSubmitMethods||[],this.failure=t.failure||function(){},this.progress=t.progress||function(){},this.spec=t.spec,this.options=t,"function"==typeof t.success&&this.build()},l.prototype.build=function(e){if(this.isBuilt)return this;var t=this;this.progress("fetching resource list: "+this.url);var s={useJQuery:this.useJQuery,url:this.url,method:"get",headers:{accept:this.swaggerRequstHeaders},on:{error:function(e){return t.fail("http"!==t.url.substring(0,4)?"Please specify the protocol for "+t.url:0===e.status?"Can't read from server. It may not have the appropriate access-control-origin settings.":404===e.status?"Can't read swagger JSON from "+t.url:e.status+" : "+e.statusText+" "+t.url)},response:function(e){var s=e.obj||JSON.parse(e.data);return t.swaggerVersion=s.swaggerVersion,s.swagger&&2===parseInt(s.swagger)?(t.swaggerVersion=s.swagger,t.buildFromSpec(s),t.isValid=!0,void 0):"1.2"===t.swaggerVersion?t.buildFrom1_2Spec(s):t.buildFrom1_1Spec(s)}}};if(this.spec)setTimeout(function(){t.buildFromSpec(t.spec)},10);else{{var r="undefined"!=typeof window?window:exports;r.authorizations.apply(s)}if(e)return s;(new C).execute(s)}return this},l.prototype.buildFromSpec=function(e){if(this.isBuilt)return this;this.info=e.info||{},this.title=e.title||"",this.host=e.host||"",this.schemes=e.schemes||[],this.basePath=e.basePath||"",this.apis={},this.apisArray=[],this.consumes=e.consumes,this.produces=e.produces,this.securityDefinitions=e.securityDefinitions,this.authSchemes=e.securityDefinitions;var t;"string"==typeof this.url&&(t=this.parseUri(this.url)),this.scheme="undefined"==typeof this.schemes||0===this.schemes.length?t.scheme||"http":this.schemes[0],("undefined"==typeof this.host||""===this.host)&&(this.host=t.host,t.port&&(this.host=this.host+":"+t.port)),this.definitions=e.definitions;var s;for(s in this.definitions){var r=new c(s,this.definitions[s]);r&&(g[s]=r)}var i;for(i in e.paths)if("object"==typeof e.paths[i]){var n;for(n in e.paths[i])if(-1!==["delete","get","head","options","patch","post","put"].indexOf(n)){var a=e.paths[i][n],o=a.tags;"undefined"==typeof o&&(a.tags=["default"],o=a.tags);var p=this.idFromOp(i,n,a),u=new d(this,a.scheme,p,n,i,a,this.definitions);if(o.length>0){var h;for(h=0;h0&&this.resource&&this.resource.api&&this.resource.api.fail&&this.resource.api.fail(o),this};f.prototype.sort=function(){},d.prototype.getType=function(e){var t,s=e.type,r=e.format,i=!1;"integer"===s&&"int32"===r?t="integer":"integer"===s&&"int64"===r?t="long":"integer"===s?t="integer":"string"===s&&"date-time"===r?t="date-time":"string"===s&&"date"===r?t="date":"number"===s&&"float"===r?t="float":"number"===s&&"double"===r?t="double":"number"===s?t="double":"boolean"===s?t="boolean":"string"===s?t="string":"array"===s&&(i=!0,e.items&&(t=this.getType(e.items))),e.$ref&&(t=e.$ref);var n=e.schema;if(n){var a=n.$ref;return a?(a=simpleRef(a),i?[a]:a):this.getType(n)}return i?[t]:t},d.prototype.resolveModel=function(t,s){if("undefined"!=typeof t.$ref){var r=t.$ref;if(0===r.indexOf("#/definitions/")&&(r=r.substring("#/definitions/".length)),s[r])return new c(r,s[r])}return"array"===t.type?new e(t):null},d.prototype.help=function(e){for(var t=this.nickname+": "+this.summary+"\n",s=0;s0&&(n=i[0]),n.nodeName){var a=(new XMLSerializer).serializeToString(n);return this.formatXml(a)}return JSON.stringify(i,null,2)}return i}},d.prototype["do"]=function(e,t,s,r,i){return this.execute(e,t,s,r,i)},d.prototype.execute=function(e,t,s,r,i){var n,a,o=e||{},p={};"object"==typeof t&&(p=t,n=s,a=r),"function"==typeof t&&(n=t,a=s),n=n||log,a=a||log,"boolean"==typeof p.useJQuery&&(this.useJQuery=p.useJQuery);var u=this.getMissingParams(o);if(u.length>0){var h="missing required params: "+u;return void fail(h)}var l,f=this.getHeaderParams(o),d=this.setContentTypes(o,p),c={};for(l in f)c[l]=f[l];for(l in d)c[l]=d[l];{var m=this.getBody(c,o),y=this.urlify(o),g={url:y,method:this.method.toUpperCase(),body:m,useJQuery:this.useJQuery,headers:c,on:{response:function(e){return n(e,i)},error:function(e){return a(e,i)}}};P.authorizations.apply(g,this.operation.security)}return p.mock===!0?g:void(new C).execute(g)},d.prototype.setContentTypes=function(e,t){var s,r,i="application/json",n=e.parameterContentType||"application/json",a=this.parameters,o=[],p=[],u={};for(r=0;r0?n=t.requestContentType?t.requestContentType:p.length>0?"multipart/form-data":"application/x-www-form-urlencoded":"DELETE"==this.type?s="{}":"DELETE"!=this.type&&(n=null):t.requestContentType&&(n=t.requestContentType),n&&this.consumes&&-1===this.consumes.indexOf(n)&&log("server doesn't consume "+n+", try "+JSON.stringify(this.consumes)),i=t.responseContentType?t.responseContentType:"application/json",i&&this.produces&&-1===this.produces.indexOf(i)&&log("server can't produce "+i),(n&&""!==s||"application/x-www-form-urlencoded"===n)&&(u["Content-Type"]=n),i&&(u.Accept=i),u},d.prototype.asCurl=function(e){var t=[],s=this.getHeaderParams(e);if(s){var r;for(r in s)t.push('--header "'+r+": "+s[r]+'"')}return"curl "+t.join(" ")+" "+this.urlify(e)},d.prototype.encodePathCollection=function(e,t,s){var r,i="",n="";for(n="ssv"===e?"%20":"tsv"===e?"\\t":"pipes"===e?"|":",",r=0;r0&&(i+="&"),i+=this.encodeQueryParam(t)+"="+this.encodeQueryParam(s[r]);else{var n="";if("csv"===e)n=",";else if("ssv"===e)n="%20";else if("tsv"===e)n="\\t";else if("pipes"===e)n="|";else if("brackets"===e)for(r=0;rr;r++)t.push(encodeURIComponent(s[r]));return t.join("/")};var c=function(t,s){this.name=t,this.definition=s||{},this.properties=[];var r=s.required||[];if("array"===s.type){var i=new e(s);return i}var n,a=s.properties;if(a)for(n in a){var o=!1,p=a[n];r.indexOf(n)>=0&&(o=!0),this.properties.push(new m(n,p,o))}};c.prototype.createJSONSample=function(e){var t,s={};for(e=e||{},e[this.name]=this,t=0;t",a=i+this.name+" {"+n,o=i+"}"+n,p=a+""+r.join(",
")+"
"+o;for(e||(e={}),e[this.name]=this,t=0;t"+h.getMockSignature(e))}return p};var m=function(e,t,s){this.schema=t,this.required=s,t.$ref?this.$ref=simpleRef(t.$ref):"array"===t.type&&t.items&&(t.items.$ref?this.$ref=simpleRef(t.items.$ref):t=t.items),this.name=e,this.description=t.description,this.obj=t,this.optional=!0,this.optional=!s,this["default"]=t["default"]||null,this.example=t.example||null,this.collectionFormat=t.collectionFormat||null,this.maximum=t.maximum||null,this.exclusiveMaximum=t.exclusiveMaximum||null,this.minimum=t.minimum||null,this.exclusiveMinimum=t.exclusiveMinimum||null,this.maxLength=t.maxLength||null,this.minLength=t.minLength||null,this.pattern=t.pattern||null,this.maxItems=t.maxItems||null,this.minItems=t.minItems||null,this.uniqueItems=t.uniqueItems||null,this["enum"]=t["enum"]||null,this.multipleOf=t.multipleOf||null};m.prototype.getSampleValue=function(e){return this.sampleValue(!1,e)},m.prototype.isArray=function(){var e=this.schema;return"array"===e.type?!0:!1},m.prototype.sampleValue=function(e,t){e=e||this.isArray(),t=t||{};var s,r=getStringSignature(this.obj,!0);if(this.$ref){var i=simpleRef(this.$ref),n=g[i];n&&"undefined"==typeof t[r]?(t[r]=this,s=n.getSampleValue(t)):s=i}else s=this.example?this.example:this["default"]?this["default"]:"date-time"===r?(new Date).toISOString():"date"===r?(new Date).toISOString().split("T")[0]:"string"===r?"string":"integer"===r?0:"long"===r?0:"float"===r?0:"double"===r?0:"boolean"===r?!0:{};return t[r]=s,e?[s]:s},getStringSignature=function(e,t){var s="";return"undefined"!=typeof e.$ref?s+=simpleRef(e.$ref):"undefined"==typeof e.type?s+="object":"array"===e.type?t?s+=getStringSignature(e.items||e.$ref||{}):(s+="Array[",s+=getStringSignature(e.items||e.$ref||{}),s+="]"):s+="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?simpleRef(e.$ref):e.type,s},simpleRef=function(e){return"undefined"==typeof e?null:0===e.indexOf("#/definitions/")?e.substring("#/definitions/".length):e},m.prototype.toString=function(){var e=getStringSignature(this.obj);""!==e?(e=''+this.name+' ('+e+"",this.required||(e+=', optional'),e+=")"):e=this.name+" ("+JSON.stringify(this.obj)+")","undefined"!=typeof this.description&&(e+=": "+this.description),this["enum"]&&(e+=' = [\''+this["enum"].join("' or '")+"']"),this.descr&&(e+=': '+this.descr+"");var t,s="",r="array"===this.schema.type;switch(t=r?this.schema.items?this.schema.items.type:"":this.schema.type,this["default"]&&(s+=optionHtml("Default",this["default"])),t){case"string":this.minLength&&(s+=optionHtml("Min. Length",this.minLength)),this.maxLength&&(s+=optionHtml("Max. Length",this.maxLength)),this.pattern&&(s+=optionHtml("Reg. Exp.",this.pattern));break;case"integer":case"number":this.minimum&&(s+=optionHtml("Min. Value",this.minimum)),this.exclusiveMinimum&&(s+=optionHtml("Exclusive Min.","true")),this.maximum&&(s+=optionHtml("Max. Value",this.maximum)),this.exclusiveMaximum&&(s+=optionHtml("Exclusive Max.","true")),this.multipleOf&&(s+=optionHtml("Multiple Of",this.multipleOf))}if(r&&(this.minItems&&(s+=optionHtml("Min. Items",this.minItems)),this.maxItems&&(s+=optionHtml("Max. Items",this.maxItems)),this.uniqueItems&&(s+=optionHtml("Unique Items","true")),this.collectionFormat&&(s+=optionHtml("Coll. Format",this.collectionFormat))),this["enum"]){var i;i="number"===t||"integer"===t?this["enum"].join(", "):'"'+this["enum"].join('", "')+'"',s+=optionHtml("Enum",i)}return s.length>0&&(e=''+e+'"),e},optionHtml=function(e,t){return'| '+e+": | "+t+" |
"},typeFromJsonSchema=function(e,t){var s;return"integer"===e&&"int32"===t?s="integer":"integer"===e&&"int64"===t?s="long":"integer"===e&&"undefined"==typeof t?s="long":"string"===e&&"date-time"===t?s="date-time":"string"===e&&"date"===t?s="date":"number"===e&&"float"===t?s="float":"number"===e&&"double"===t?s="double":"number"===e&&"undefined"==typeof t?s="double":"boolean"===e?s="boolean":"string"===e&&(s="string"),s};var y={},g={};l.prototype.buildFrom1_2Spec=function(e){null!==e.apiVersion&&(this.apiVersion=e.apiVersion),this.apis={},this.apisArray=[],this.consumes=e.consumes,this.produces=e.produces,this.authSchemes=e.authorizations,this.info=this.convertInfo(e.info);var t,s,r=!1;for(t=0;t0?this.url.substring(0,this.url.lastIndexOf("?")):this.url,r){var a=e.resourcePath.replace(/\//g,"");this.resourcePath=e.resourcePath,s=new v(e,this),this.apis[a]=s,this.apisArray.push(s)}else{var o;for(this.expectedResourceCount=e.apis.length,o=0;o0?this.url.substring(0,this.url.lastIndexOf("?")):this.url,s){var a=e.resourcePath.replace(/\//g,"");this.resourcePath=e.resourcePath,t=new v(e,this),this.apis[a]=t,this.apisArray.push(t)}else for(k=0;k0&&(this.basePath=-1===e.basePath.indexOf("http")?this.getAbsoluteBasePath(e.basePath):e.basePath),this.resourcePath=e.resourcePath,this.addModels(e.models),e.apis)for(var t=0;t|.\/?,\\'""-]/g,"_"),t=t.replace(/((_){2,})/g,"_"),t=t.replace(/^(_)*/g,""),t=t.replace(/([_])*$/g,"")};var b=function(e,t){this.name="undefined"!=typeof t.id?t.id:e,this.properties=[];var s;for(s in t.properties){if(t.required){var r;for(r in t.required)s===t.required[r]&&(t.properties[s].required=!0)}var i=new w(s,t.properties[s],this);this.properties.push(i)}};b.prototype.setReferencedModels=function(e){for(var t=[],s=0;s",a=i+this.name+" {"+n,o=i+"}"+n,p=a+""+r.join(",
")+"
"+o;for(e||(e=[]),e.push(this.name),t=0;t"+s.refModel.getMockSignature(e));return p},b.prototype.createJSONSample=function(e){if(y[this.name])return y[this.name];var t={};e=e||[],e.push(this.name);for(var s=0;s'+this.name+' (