Delete netconf
[controller.git] / opendaylight / md-sal / sal-rest-docgen / src / main / resources / explorer / lib / swagger.js
1 // Generated by CoffeeScript 1.6.3
2 (function() {
3   var ApiKeyAuthorization, PasswordAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
4     __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
5
6   SwaggerApi = (function() {
7     SwaggerApi.prototype.url = "http://api.wordnik.com/v4/resources.json";
8
9     SwaggerApi.prototype.debug = false;
10
11     SwaggerApi.prototype.basePath = null;
12
13     SwaggerApi.prototype.authorizations = null;
14
15     SwaggerApi.prototype.authorizationScheme = null;
16
17     SwaggerApi.prototype.info = null;
18
19     function SwaggerApi(url, options) {
20       if (options == null) {
21         options = {};
22       }
23       if (url) {
24         if (url.url) {
25           options = url;
26         } else {
27           this.url = url;
28         }
29       } else {
30         options = url;
31       }
32       if (options.url != null) {
33         this.url = options.url;
34       }
35       if (options.success != null) {
36         this.success = options.success;
37       }
38       this.failure = options.failure != null ? options.failure : function() {};
39       this.progress = options.progress != null ? options.progress : function() {};
40       if (options.success != null) {
41         this.build();
42       }
43     }
44
45     SwaggerApi.prototype.build = function() {
46       var e, obj,
47         _this = this;
48       this.progress('fetching resource list: ' + this.url);
49       obj = {
50         url: this.url,
51         method: "get",
52         headers: {},
53         on: {
54           error: function(response) {
55             if (_this.url.substring(0, 4) !== 'http') {
56               return _this.fail('Please specify the protocol for ' + _this.url);
57             } else if (response.status === 0) {
58               return _this.fail('Can\'t read from server.  It may not have the appropriate access-control-origin settings.');
59             } else if (response.status === 404) {
60               return _this.fail('Can\'t read swagger JSON from ' + _this.url);
61             } else {
62               return _this.fail(response.status + ' : ' + response.statusText + ' ' + _this.url);
63             }
64           },
65           response: function(rawResponse) {
66             var response;
67             response = JSON.parse(rawResponse.content.data);
68             _this.swaggerVersion = response.swaggerVersion;
69             if (_this.swaggerVersion === "1.2") {
70               return _this.buildFromSpec(response);
71             } else {
72               return _this.buildFrom1_1Spec(response);
73             }
74           }
75         }
76       };
77       e = {};
78       if (typeof window !== 'undefined') {
79         e = window;
80       } else {
81         e = exports;
82       }
83       e.authorizations.apply(obj);
84       new SwaggerHttp().execute(obj);
85       return this;
86     };
87
88     SwaggerApi.prototype.buildFromSpec = function(response) {
89       var api, isApi, newName, operation, res, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
90       if (response.apiVersion != null) {
91         this.apiVersion = response.apiVersion;
92       }
93       this.apis = {};
94       this.apisArray = [];
95       this.produces = response.produces;
96       this.authSchemes = response.authorizations;
97       if (response.info != null) {
98         this.info = response.info;
99       }
100       isApi = false;
101       _ref = response.apis;
102       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
103         api = _ref[_i];
104         if (api.operations) {
105           _ref1 = api.operations;
106           for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
107             operation = _ref1[_j];
108             isApi = true;
109           }
110         }
111       }
112       if (response.basePath) {
113         this.basePath = response.basePath;
114       } else if (this.url.indexOf('?') > 0) {
115         this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
116       } else {
117         this.basePath = this.url;
118       }
119       if (isApi) {
120         newName = response.resourcePath.replace(/\//g, '');
121         this.resourcePath = response.resourcePath;
122         res = new SwaggerResource(response, this);
123         this.apis[newName] = res;
124         this.apisArray.push(res);
125       } else {
126         _ref2 = response.apis;
127         for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
128           resource = _ref2[_k];
129           res = new SwaggerResource(resource, this);
130           this.apis[res.name] = res;
131           this.apisArray.push(res);
132         }
133       }
134       if (this.success) {
135         this.success();
136       }
137       return this;
138     };
139
140     SwaggerApi.prototype.buildFrom1_1Spec = function(response) {
141       var api, isApi, newName, operation, res, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
142       console.log("This API is using a deprecated version of Swagger!  Please see http://github.com/wordnik/swagger-core/wiki for more info");
143       if (response.apiVersion != null) {
144         this.apiVersion = response.apiVersion;
145       }
146       this.apis = {};
147       this.apisArray = [];
148       this.produces = response.produces;
149       if (response.info != null) {
150         this.info = response.info;
151       }
152       isApi = false;
153       _ref = response.apis;
154       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
155         api = _ref[_i];
156         if (api.operations) {
157           _ref1 = api.operations;
158           for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
159             operation = _ref1[_j];
160             isApi = true;
161           }
162         }
163       }
164       if (response.basePath) {
165         this.basePath = response.basePath;
166       } else if (this.url.indexOf('?') > 0) {
167         this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
168       } else {
169         this.basePath = this.url;
170       }
171       if (isApi) {
172         newName = response.resourcePath.replace(/\//g, '');
173         this.resourcePath = response.resourcePath;
174         res = new SwaggerResource(response, this);
175         this.apis[newName] = res;
176         this.apisArray.push(res);
177       } else {
178         _ref2 = response.apis;
179         for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
180           resource = _ref2[_k];
181           res = new SwaggerResource(resource, this);
182           this.apis[res.name] = res;
183           this.apisArray.push(res);
184         }
185       }
186       if (this.success) {
187         this.success();
188       }
189       return this;
190     };
191
192     SwaggerApi.prototype.selfReflect = function() {
193       var resource, resource_name, _ref;
194       if (this.apis == null) {
195         return false;
196       }
197       _ref = this.apis;
198       for (resource_name in _ref) {
199         resource = _ref[resource_name];
200         if (resource.ready == null) {
201           return false;
202         }
203       }
204       this.setConsolidatedModels();
205       this.ready = true;
206       if (this.success != null) {
207         return this.success();
208       }
209     };
210
211     SwaggerApi.prototype.fail = function(message) {
212       this.failure(message);
213       throw message;
214     };
215
216     SwaggerApi.prototype.setConsolidatedModels = function() {
217       var model, modelName, resource, resource_name, _i, _len, _ref, _ref1, _results;
218       this.modelsArray = [];
219       this.models = {};
220       _ref = this.apis;
221       for (resource_name in _ref) {
222         resource = _ref[resource_name];
223         for (modelName in resource.models) {
224           if (this.models[modelName] == null) {
225             this.models[modelName] = resource.models[modelName];
226             this.modelsArray.push(resource.models[modelName]);
227           }
228         }
229       }
230       _ref1 = this.modelsArray;
231       _results = [];
232       for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
233         model = _ref1[_i];
234         _results.push(model.setReferencedModels(this.models));
235       }
236       return _results;
237     };
238
239     SwaggerApi.prototype.help = function() {
240       var operation, operation_name, parameter, resource, resource_name, _i, _len, _ref, _ref1, _ref2;
241       _ref = this.apis;
242       for (resource_name in _ref) {
243         resource = _ref[resource_name];
244         console.log(resource_name);
245         _ref1 = resource.operations;
246         for (operation_name in _ref1) {
247           operation = _ref1[operation_name];
248           console.log("  " + operation.nickname);
249           _ref2 = operation.parameters;
250           for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
251             parameter = _ref2[_i];
252             console.log("    " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
253           }
254         }
255       }
256       return this;
257     };
258
259     return SwaggerApi;
260
261   })();
262
263   SwaggerResource = (function() {
264     SwaggerResource.prototype.api = null;
265
266     SwaggerResource.prototype.produces = null;
267
268     SwaggerResource.prototype.consumes = null;
269
270     function SwaggerResource(resourceObj, api) {
271       var consumes, e, obj, parts, produces,
272         _this = this;
273       this.api = api;
274       this.api = this.api;
275       produces = [];
276       consumes = [];
277       this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
278       this.description = resourceObj.description;
279       parts = this.path.split("/");
280       this.name = parts[parts.length - 1].replace('.{format}', '');
281       this.basePath = this.api.basePath;
282       this.operations = {};
283       this.operationsArray = [];
284       this.modelsArray = [];
285       this.models = {};
286       if ((resourceObj.apis != null) && (this.api.resourcePath != null)) {
287         this.addApiDeclaration(resourceObj);
288       } else {
289         if (this.path == null) {
290           this.api.fail("SwaggerResources must have a path.");
291         }
292         if (this.path.substring(0, 4) === 'http') {
293           this.url = this.path.replace('{format}', 'json');
294         } else {
295           this.url = this.api.basePath + this.path.replace('{format}', 'json');
296         }
297         this.api.progress('fetching resource ' + this.name + ': ' + this.url);
298         obj = {
299           url: this.url,
300           method: "get",
301           headers: {},
302           on: {
303             error: function(response) {
304               return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")");
305             },
306             response: function(rawResponse) {
307               var response;
308               response = JSON.parse(rawResponse.content.data);
309               return _this.addApiDeclaration(response);
310             }
311           }
312         };
313         e = {};
314         if (typeof window !== 'undefined') {
315           e = window;
316         } else {
317           e = exports;
318         }
319         e.authorizations.apply(obj);
320         new SwaggerHttp().execute(obj);
321       }
322     }
323
324     SwaggerResource.prototype.addApiDeclaration = function(response) {
325       var endpoint, _i, _len, _ref;
326       if (response.produces != null) {
327         this.produces = response.produces;
328       }
329       if (response.consumes != null) {
330         this.consumes = response.consumes;
331       }
332       if ((response.basePath != null) && response.basePath.replace(/\s/g, '').length > 0) {
333         this.basePath = response.basePath;
334       }
335       this.addModels(response.models);
336       if (response.apis) {
337         _ref = response.apis;
338         for (_i = 0, _len = _ref.length; _i < _len; _i++) {
339           endpoint = _ref[_i];
340           this.addOperations(endpoint.path, endpoint.operations, response.consumes, response.produces);
341         }
342       }
343       this.api[this.name] = this;
344       this.ready = true;
345       return this.api.selfReflect();
346     };
347
348     SwaggerResource.prototype.addModels = function(models) {
349       var model, modelName, swaggerModel, _i, _len, _ref, _results;
350       if (models != null) {
351         for (modelName in models) {
352           if (this.models[modelName] == null) {
353             swaggerModel = new SwaggerModel(modelName, models[modelName]);
354             this.modelsArray.push(swaggerModel);
355             this.models[modelName] = swaggerModel;
356           }
357         }
358         _ref = this.modelsArray;
359         _results = [];
360         for (_i = 0, _len = _ref.length; _i < _len; _i++) {
361           model = _ref[_i];
362           _results.push(model.setReferencedModels(this.models));
363         }
364         return _results;
365       }
366     };
367
368     SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes, produces) {
369       var method, o, op, r, ref, responseMessages, type, _i, _j, _len, _len1, _results;
370       if (ops) {
371         _results = [];
372         for (_i = 0, _len = ops.length; _i < _len; _i++) {
373           o = ops[_i];
374           consumes = this.consumes;
375           produces = this.produces;
376           if (o.consumes != null) {
377             consumes = o.consumes;
378           } else {
379             consumes = this.consumes;
380           }
381           if (o.produces != null) {
382             produces = o.produces;
383           } else {
384             produces = this.produces;
385           }
386           type = o.type || o.responseClass;
387           if (type === "array") {
388             ref = null;
389             if (o.items) {
390               ref = o.items["type"] || o.items["$ref"];
391             }
392             type = "array[" + ref + "]";
393           }
394           responseMessages = o.responseMessages;
395           method = o.method;
396           if (o.httpMethod) {
397             method = o.httpMethod;
398           }
399           if (o.supportedContentTypes) {
400             consumes = o.supportedContentTypes;
401           }
402           if (o.errorResponses) {
403             responseMessages = o.errorResponses;
404             for (_j = 0, _len1 = responseMessages.length; _j < _len1; _j++) {
405               r = responseMessages[_j];
406               r.message = r.reason;
407               r.reason = null;
408             }
409           }
410           o.nickname = this.sanitize(o.nickname);
411           op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, type, responseMessages, this, consumes, produces);
412           this.operations[op.nickname] = op;
413           _results.push(this.operationsArray.push(op));
414         }
415         return _results;
416       }
417     };
418
419     SwaggerResource.prototype.sanitize = function(nickname) {
420       var op;
421       op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|./?,\\'""-]/g, '_');
422       op = op.replace(/((_){2,})/g, '_');
423       op = op.replace(/^(_)*/g, '');
424       op = op.replace(/([_])*$/g, '');
425       return op;
426     };
427
428     SwaggerResource.prototype.help = function() {
429       var msg, operation, operation_name, parameter, _i, _len, _ref, _ref1, _results;
430       _ref = this.operations;
431       _results = [];
432       for (operation_name in _ref) {
433         operation = _ref[operation_name];
434         msg = "  " + operation.nickname;
435         _ref1 = operation.parameters;
436         for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
437           parameter = _ref1[_i];
438           msg.concat("    " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
439         }
440         _results.push(msg);
441       }
442       return _results;
443     };
444
445     return SwaggerResource;
446
447   })();
448
449   SwaggerModel = (function() {
450     function SwaggerModel(modelName, obj) {
451       var prop, propertyName, value;
452       this.name = obj.id != null ? obj.id : modelName;
453       this.properties = [];
454       for (propertyName in obj.properties) {
455         if (obj.required != null) {
456           for (value in obj.required) {
457             if (propertyName === obj.required[value]) {
458               obj.properties[propertyName].required = true;
459             }
460           }
461         }
462         prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]);
463         this.properties.push(prop);
464       }
465     }
466
467     SwaggerModel.prototype.setReferencedModels = function(allModels) {
468       var prop, type, _i, _len, _ref, _results;
469       _ref = this.properties;
470       _results = [];
471       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
472         prop = _ref[_i];
473         type = prop.type || prop.dataType;
474         if (allModels[type] != null) {
475           _results.push(prop.refModel = allModels[type]);
476         } else if ((prop.refDataType != null) && (allModels[prop.refDataType] != null)) {
477           _results.push(prop.refModel = allModels[prop.refDataType]);
478         } else {
479           _results.push(void 0);
480         }
481       }
482       return _results;
483     };
484
485     SwaggerModel.prototype.getMockSignature = function(modelsToIgnore) {
486       var classClose, classOpen, prop, propertiesStr, returnVal, strong, strongClose, stronger, _i, _j, _len, _len1, _ref, _ref1;
487       propertiesStr = [];
488       _ref = this.properties;
489       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
490         prop = _ref[_i];
491         propertiesStr.push(prop.toString());
492       }
493       strong = '<span class="strong">';
494       stronger = '<span class="stronger">';
495       strongClose = '</span>';
496       classOpen = strong + this.name + ' {' + strongClose;
497       classClose = strong + '}' + strongClose;
498       returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;
499       if (!modelsToIgnore) {
500         modelsToIgnore = [];
501       }
502       modelsToIgnore.push(this);
503       _ref1 = this.properties;
504       for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
505         prop = _ref1[_j];
506         if ((prop.refModel != null) && (modelsToIgnore.indexOf(prop.refModel)) === -1) {
507           returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));
508         }
509       }
510       return returnVal;
511     };
512
513     SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) {
514       var prop, result, _i, _len, _ref;
515       result = {};
516       modelsToIgnore = modelsToIgnore || [];
517       modelsToIgnore.push(this.name);
518       _ref = this.properties;
519       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
520         prop = _ref[_i];
521         result[prop.name] = prop.getSampleValue(modelsToIgnore);
522       }
523       modelsToIgnore.pop(this.name);
524       return result;
525     };
526
527     return SwaggerModel;
528
529   })();
530
531   SwaggerModelProperty = (function() {
532     function SwaggerModelProperty(name, obj) {
533       this.name = name;
534       this.dataType = obj.type || obj.dataType || obj["$ref"];
535       this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
536       this.descr = obj.description;
537       this.required = obj.required;
538       if (obj.items != null) {
539         if (obj.items.type != null) {
540           this.refDataType = obj.items.type;
541         }
542         if (obj.items.$ref != null) {
543           this.refDataType = obj.items.$ref;
544         }
545       }
546       this.dataTypeWithRef = this.refDataType != null ? this.dataType + '[' + this.refDataType + ']' : this.dataType;
547       if (obj.allowableValues != null) {
548         this.valueType = obj.allowableValues.valueType;
549         this.values = obj.allowableValues.values;
550         if (this.values != null) {
551           this.valuesString = "'" + this.values.join("' or '") + "'";
552         }
553       }
554       if (obj["enum"] != null) {
555         this.valueType = "string";
556         this.values = obj["enum"];
557         if (this.values != null) {
558           this.valueString = "'" + this.values.join("' or '") + "'";
559         }
560       }
561     }
562
563     SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) {
564       var result;
565       if ((this.refModel != null) && (modelsToIgnore.indexOf(this.refModel.name) === -1)) {
566         result = this.refModel.createJSONSample(modelsToIgnore);
567       } else {
568         if (this.isCollection) {
569           result = this.refDataType;
570         } else {
571           result = this.dataType;
572         }
573       }
574       if (this.isCollection) {
575         return [result];
576       } else {
577         return result;
578       }
579     };
580
581     SwaggerModelProperty.prototype.toString = function() {
582       var req, str;
583       req = this.required ? 'propReq' : 'propOpt';
584       str = '<span class="propName ' + req + '">' + this.name + '</span> (<span class="propType">' + this.dataTypeWithRef + '</span>';
585       if (!this.required) {
586         str += ', <span class="propOptKey">optional</span>';
587       }
588       str += ')';
589       if (this.values != null) {
590         str += " = <span class='propVals'>['" + this.values.join("' or '") + "']</span>";
591       }
592       if (this.descr != null) {
593         str += ': <span class="propDesc">' + this.descr + '</span>';
594       }
595       return str;
596     };
597
598     return SwaggerModelProperty;
599
600   })();
601
602   SwaggerOperation = (function() {
603     function SwaggerOperation(nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces) {
604       var parameter, v, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3,
605         _this = this;
606       this.nickname = nickname;
607       this.path = path;
608       this.method = method;
609       this.parameters = parameters != null ? parameters : [];
610       this.summary = summary;
611       this.notes = notes;
612       this.type = type;
613       this.responseMessages = responseMessages;
614       this.resource = resource;
615       this.consumes = consumes;
616       this.produces = produces;
617       this["do"] = __bind(this["do"], this);
618       if (this.nickname == null) {
619         this.resource.api.fail("SwaggerOperations must have a nickname.");
620       }
621       if (this.path == null) {
622         this.resource.api.fail("SwaggerOperation " + nickname + " is missing path.");
623       }
624       if (this.method == null) {
625         this.resource.api.fail("SwaggerOperation " + nickname + " is missing method.");
626       }
627       this.path = this.path.replace('{format}', 'json');
628       this.method = this.method.toLowerCase();
629       this.isGetMethod = this.method === "get";
630       this.resourceName = this.resource.name;
631       if (((_ref = this.type) != null ? _ref.toLowerCase() : void 0) === 'void') {
632         this.type = void 0;
633       }
634       if (this.type != null) {
635         this.responseClassSignature = this.getSignature(this.type, this.resource.models);
636         this.responseSampleJSON = this.getSampleJSON(this.type, this.resource.models);
637       }
638       this.responseMessages = this.responseMessages || [];
639       _ref1 = this.parameters;
640       for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
641         parameter = _ref1[_i];
642         parameter.name = parameter.name || parameter.type || parameter.dataType;
643         type = parameter.type || parameter.dataType;
644         if (type.toLowerCase() === 'boolean') {
645           parameter.allowableValues = {};
646           parameter.allowableValues.values = ["true", "false"];
647         }
648         parameter.signature = this.getSignature(type, this.resource.models);
649         parameter.sampleJSON = this.getSampleJSON(type, this.resource.models);
650         if (parameter["enum"] != null) {
651           parameter.isList = true;
652           parameter.allowableValues = {};
653           parameter.allowableValues.descriptiveValues = [];
654           _ref2 = parameter["enum"];
655           for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
656             v = _ref2[_j];
657             if ((parameter.defaultValue != null) && parameter.defaultValue === v) {
658               parameter.allowableValues.descriptiveValues.push({
659                 value: v,
660                 isDefault: true
661               });
662             } else {
663               parameter.allowableValues.descriptiveValues.push({
664                 value: v,
665                 isDefault: false
666               });
667             }
668           }
669         }
670         if (parameter.allowableValues != null) {
671           if (parameter.allowableValues.valueType === "RANGE") {
672             parameter.isRange = true;
673           } else {
674             parameter.isList = true;
675           }
676           if (parameter.allowableValues.values != null) {
677             parameter.allowableValues.descriptiveValues = [];
678             _ref3 = parameter.allowableValues.values;
679             for (_k = 0, _len2 = _ref3.length; _k < _len2; _k++) {
680               v = _ref3[_k];
681               if ((parameter.defaultValue != null) && parameter.defaultValue === v) {
682                 parameter.allowableValues.descriptiveValues.push({
683                   value: v,
684                   isDefault: true
685                 });
686               } else {
687                 parameter.allowableValues.descriptiveValues.push({
688                   value: v,
689                   isDefault: false
690                 });
691               }
692             }
693           }
694         }
695       }
696       this.resource[this.nickname] = function(args, callback, error) {
697         return _this["do"](args, callback, error);
698       };
699       this.resource[this.nickname].help = function() {
700         return _this.help();
701       };
702     }
703
704     SwaggerOperation.prototype.isListType = function(type) {
705       if (type.indexOf('[') >= 0) {
706         return type.substring(type.indexOf('[') + 1, type.indexOf(']'));
707       } else {
708         return void 0;
709       }
710     };
711
712     SwaggerOperation.prototype.getSignature = function(type, models) {
713       var isPrimitive, listType;
714       listType = this.isListType(type);
715       isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
716       if (isPrimitive) {
717         return type;
718       } else {
719         if (listType != null) {
720           return models[listType].getMockSignature();
721         } else {
722           return models[type].getMockSignature();
723         }
724       }
725     };
726
727     SwaggerOperation.prototype.getSampleJSON = function(type, models) {
728       var isPrimitive, listType, val;
729       listType = this.isListType(type);
730       isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
731       val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[type].createJSONSample());
732       if (val) {
733         val = listType ? [val] : val;
734         return JSON.stringify(val, null, 2);
735       }
736     };
737
738     SwaggerOperation.prototype["do"] = function(args, opts, callback, error) {
739       var key, param, params, possibleParams, req, requestContentType, responseContentType, value, _i, _len, _ref;
740       if (args == null) {
741         args = {};
742       }
743       if (opts == null) {
744         opts = {};
745       }
746       requestContentType = null;
747       responseContentType = null;
748       if ((typeof args) === "function") {
749         error = opts;
750         callback = args;
751         args = {};
752       }
753       if ((typeof opts) === "function") {
754         error = callback;
755         callback = opts;
756       }
757       if (error == null) {
758         error = function(xhr, textStatus, error) {
759           return console.log(xhr, textStatus, error);
760         };
761       }
762       if (callback == null) {
763         callback = function(data) {
764           var content;
765           content = null;
766           if (data.content != null) {
767             content = data.content.data;
768           } else {
769             content = "no data";
770           }
771           return console.log("default callback: " + content);
772         };
773       }
774       params = {};
775       params.headers = [];
776       if (args.headers != null) {
777         params.headers = args.headers;
778         delete args.headers;
779       }
780       _ref = this.parameters;
781       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
782         param = _ref[_i];
783         if (param.paramType === "header") {
784           if (args[param.name]) {
785             params.headers[param.name] = args[param.name];
786           }
787         }
788       }
789       if (args.body != null) {
790         params.body = args.body;
791         delete args.body;
792       }
793       possibleParams = (function() {
794         var _j, _len1, _ref1, _results;
795         _ref1 = this.parameters;
796         _results = [];
797         for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
798           param = _ref1[_j];
799           if (param.paramType === "form" || param.paramType.toLowerCase() === "file") {
800             _results.push(param);
801           }
802         }
803         return _results;
804       }).call(this);
805       if (possibleParams) {
806         for (key in possibleParams) {
807           value = possibleParams[key];
808           if (args[value.name]) {
809             params[value.name] = args[value.name];
810           }
811         }
812       }
813       req = new SwaggerRequest(this.method, this.urlify(args), params, opts, callback, error, this);
814       if (opts.mock != null) {
815         return req;
816       } else {
817         return true;
818       }
819     };
820
821     SwaggerOperation.prototype.pathJson = function() {
822       return this.path.replace("{format}", "json");
823     };
824
825     SwaggerOperation.prototype.pathXml = function() {
826       return this.path.replace("{format}", "xml");
827     };
828
829     SwaggerOperation.prototype.urlify = function(args) {
830       var param, queryParams, reg, url, _i, _j, _len, _len1, _ref, _ref1;
831       url = this.resource.basePath + this.pathJson();
832       _ref = this.parameters;
833       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
834         param = _ref[_i];
835         if (param.paramType === 'path') {
836           if (args[param.name]) {
837             reg = new RegExp('\{' + param.name + '[^\}]*\}', 'gi');
838             url = url.replace(reg, encodeURIComponent(args[param.name]));
839             delete args[param.name];
840           } else {
841             throw "" + param.name + " is a required path param.";
842           }
843         }
844       }
845       queryParams = "";
846       _ref1 = this.parameters;
847       for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
848         param = _ref1[_j];
849         if (param.paramType === 'query') {
850           if (args[param.name]) {
851             if (queryParams !== "") {
852               queryParams += "&";
853             }
854             queryParams += encodeURIComponent(param.name) + '=' + encodeURIComponent(args[param.name]);
855           }
856         }
857       }
858       if ((queryParams != null) && queryParams.length > 0) {
859         url += "?" + queryParams;
860       }
861       return url;
862     };
863
864     SwaggerOperation.prototype.supportHeaderParams = function() {
865       return this.resource.api.supportHeaderParams;
866     };
867
868     SwaggerOperation.prototype.supportedSubmitMethods = function() {
869       return this.resource.api.supportedSubmitMethods;
870     };
871
872     SwaggerOperation.prototype.getQueryParams = function(args) {
873       return this.getMatchingParams(['query'], args);
874     };
875
876     SwaggerOperation.prototype.getHeaderParams = function(args) {
877       return this.getMatchingParams(['header'], args);
878     };
879
880     SwaggerOperation.prototype.getMatchingParams = function(paramTypes, args) {
881       var matchingParams, name, param, value, _i, _len, _ref, _ref1;
882       matchingParams = {};
883       _ref = this.parameters;
884       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
885         param = _ref[_i];
886         if (args && args[param.name]) {
887           matchingParams[param.name] = args[param.name];
888         }
889       }
890       _ref1 = this.resource.api.headers;
891       for (name in _ref1) {
892         value = _ref1[name];
893         matchingParams[name] = value;
894       }
895       return matchingParams;
896     };
897
898     SwaggerOperation.prototype.help = function() {
899       var msg, parameter, _i, _len, _ref;
900       msg = "";
901       _ref = this.parameters;
902       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
903         parameter = _ref[_i];
904         if (msg !== "") {
905           msg += "\n";
906         }
907         msg += "* " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description;
908       }
909       return msg;
910     };
911
912     return SwaggerOperation;
913
914   })();
915
916   SwaggerRequest = (function() {
917     function SwaggerRequest(type, url, params, opts, successCallback, errorCallback, operation, execution) {
918       var body, e, fields, headers, key, myHeaders, name, obj, param, parent, possibleParams, requestContentType, responseContentType, urlEncoded, value, values,
919         _this = this;
920       this.type = type;
921       this.url = url;
922       this.params = params;
923       this.opts = opts;
924       this.successCallback = successCallback;
925       this.errorCallback = errorCallback;
926       this.operation = operation;
927       this.execution = execution;
928       if (this.type == null) {
929         throw "SwaggerRequest type is required (get/post/put/delete).";
930       }
931       if (this.url == null) {
932         throw "SwaggerRequest url is required.";
933       }
934       if (this.successCallback == null) {
935         throw "SwaggerRequest successCallback is required.";
936       }
937       if (this.errorCallback == null) {
938         throw "SwaggerRequest error callback is required.";
939       }
940       if (this.operation == null) {
941         throw "SwaggerRequest operation is required.";
942       }
943       this.type = this.type.toUpperCase();
944       headers = params.headers;
945       myHeaders = {};
946       body = params.body;
947       parent = params["parent"];
948       requestContentType = "application/json";
949       if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH")) {
950         if (this.opts.requestContentType) {
951           requestContentType = this.opts.requestContentType;
952         }
953       } else {
954         if (((function() {
955           var _i, _len, _ref, _results;
956           _ref = this.operation.parameters;
957           _results = [];
958           for (_i = 0, _len = _ref.length; _i < _len; _i++) {
959             param = _ref[_i];
960             if (param.paramType === "form") {
961               _results.push(param);
962             }
963           }
964           return _results;
965         }).call(this)).length > 0) {
966           type = param.type || param.dataType;
967           if (((function() {
968             var _i, _len, _ref, _results;
969             _ref = this.operation.parameters;
970             _results = [];
971             for (_i = 0, _len = _ref.length; _i < _len; _i++) {
972               param = _ref[_i];
973               if (type.toLowerCase() === "file") {
974                 _results.push(param);
975               }
976             }
977             return _results;
978           }).call(this)).length > 0) {
979             requestContentType = "multipart/form-data";
980           } else {
981             requestContentType = "application/x-www-form-urlencoded";
982           }
983         } else if (this.type !== "DELETE") {
984           requestContentType = null;
985         }
986       }
987       if (requestContentType && this.operation.consumes) {
988         if (this.operation.consumes.indexOf(requestContentType) === -1) {
989           console.log("server doesn't consume " + requestContentType + ", try " + JSON.stringify(this.operation.consumes));
990           if (this.requestContentType === null) {
991             requestContentType = this.operation.consumes[0];
992           }
993         }
994       }
995       responseContentType = null;
996       if (this.type === "POST" || this.type === "GET" || this.type === "PATCH") {
997         if (this.opts.responseContentType) {
998           responseContentType = this.opts.responseContentType;
999         } else {
1000           responseContentType = "application/json";
1001         }
1002       } else {
1003         responseContentType = null;
1004       }
1005       if (responseContentType && this.operation.produces) {
1006         if (this.operation.produces.indexOf(responseContentType) === -1) {
1007           console.log("server can't produce " + responseContentType);
1008         }
1009       }
1010       if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) {
1011         fields = {};
1012         possibleParams = (function() {
1013           var _i, _len, _ref, _results;
1014           _ref = this.operation.parameters;
1015           _results = [];
1016           for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1017             param = _ref[_i];
1018             if (param.paramType === "form") {
1019               _results.push(param);
1020             }
1021           }
1022           return _results;
1023         }).call(this);
1024         values = {};
1025         for (key in possibleParams) {
1026           value = possibleParams[key];
1027           if (this.params[value.name]) {
1028             values[value.name] = this.params[value.name];
1029           }
1030         }
1031         urlEncoded = "";
1032         for (key in values) {
1033           value = values[key];
1034           if (urlEncoded !== "") {
1035             urlEncoded += "&";
1036           }
1037           urlEncoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
1038         }
1039         body = urlEncoded;
1040       }
1041       for (name in headers) {
1042         myHeaders[name] = headers[name];
1043       }
1044       if (requestContentType) {
1045         myHeaders["Content-Type"] = requestContentType;
1046       }
1047       if (responseContentType) {
1048         myHeaders["Accept"] = responseContentType;
1049       }
1050       if (!((headers != null) && (headers.mock != null))) {
1051         obj = {
1052           url: this.url,
1053           method: this.type,
1054           headers: myHeaders,
1055           body: body,
1056           on: {
1057             error: function(response) {
1058               return _this.errorCallback(response, _this.opts.parent);
1059             },
1060             redirect: function(response) {
1061               return _this.successCallback(response, _this.opts.parent);
1062             },
1063             307: function(response) {
1064               return _this.successCallback(response, _this.opts.parent);
1065             },
1066             response: function(response) {
1067               return _this.successCallback(response, _this.opts.parent);
1068             }
1069           }
1070         };
1071         e = {};
1072         if (typeof window !== 'undefined') {
1073           e = window;
1074         } else {
1075           e = exports;
1076         }
1077         e.authorizations.apply(obj);
1078         if (opts.mock == null) {
1079           new SwaggerHttp().execute(obj);
1080         } else {
1081           console.log(obj);
1082           return obj;
1083         }
1084       }
1085     }
1086
1087     SwaggerRequest.prototype.asCurl = function() {
1088       var header_args, k, v;
1089       header_args = (function() {
1090         var _ref, _results;
1091         _ref = this.headers;
1092         _results = [];
1093         for (k in _ref) {
1094           v = _ref[k];
1095           _results.push("--header \"" + k + ": " + v + "\"");
1096         }
1097         return _results;
1098       }).call(this);
1099       return "curl " + (header_args.join(" ")) + " " + this.url;
1100     };
1101
1102     return SwaggerRequest;
1103
1104   })();
1105
1106   SwaggerHttp = (function() {
1107     SwaggerHttp.prototype.Shred = null;
1108
1109     SwaggerHttp.prototype.shred = null;
1110
1111     SwaggerHttp.prototype.content = null;
1112
1113     function SwaggerHttp() {
1114       var identity, toString,
1115         _this = this;
1116       if (typeof window !== 'undefined') {
1117         this.Shred = require("./shred");
1118       } else {
1119         this.Shred = require("shred");
1120       }
1121       this.shred = new this.Shred();
1122       identity = function(x) {
1123         return x;
1124       };
1125       toString = function(x) {
1126         return x.toString();
1127       };
1128       if (typeof window !== 'undefined') {
1129         this.content = require("./shred/content");
1130         this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
1131           parser: identity,
1132           stringify: toString
1133         });
1134       } else {
1135         this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
1136           parser: identity,
1137           stringify: toString
1138         });
1139       }
1140     }
1141
1142     SwaggerHttp.prototype.execute = function(obj) {
1143       return this.shred.request(obj);
1144     };
1145
1146     return SwaggerHttp;
1147
1148   })();
1149
1150   SwaggerAuthorizations = (function() {
1151     SwaggerAuthorizations.prototype.authz = null;
1152
1153     function SwaggerAuthorizations() {
1154       this.authz = {};
1155     }
1156
1157     SwaggerAuthorizations.prototype.add = function(name, auth) {
1158       this.authz[name] = auth;
1159       return auth;
1160     };
1161
1162     SwaggerAuthorizations.prototype.apply = function(obj) {
1163       var key, value, _ref, _results;
1164       _ref = this.authz;
1165       _results = [];
1166       for (key in _ref) {
1167         value = _ref[key];
1168         _results.push(value.apply(obj));
1169       }
1170       return _results;
1171     };
1172
1173     return SwaggerAuthorizations;
1174
1175   })();
1176
1177   ApiKeyAuthorization = (function() {
1178     ApiKeyAuthorization.prototype.type = null;
1179
1180     ApiKeyAuthorization.prototype.name = null;
1181
1182     ApiKeyAuthorization.prototype.value = null;
1183
1184     function ApiKeyAuthorization(name, value, type) {
1185       this.name = name;
1186       this.value = value;
1187       this.type = type;
1188     }
1189
1190     ApiKeyAuthorization.prototype.apply = function(obj) {
1191       if (this.type === "query") {
1192         if (obj.url.indexOf('?') > 0) {
1193           obj.url = obj.url + "&" + this.name + "=" + this.value;
1194         } else {
1195           obj.url = obj.url + "?" + this.name + "=" + this.value;
1196         }
1197         return true;
1198       } else if (this.type === "header") {
1199         return obj.headers[this.name] = this.value;
1200       }
1201     };
1202
1203     return ApiKeyAuthorization;
1204
1205   })();
1206
1207   PasswordAuthorization = (function() {
1208     PasswordAuthorization.prototype.name = null;
1209
1210     PasswordAuthorization.prototype.username = null;
1211
1212     PasswordAuthorization.prototype.password = null;
1213
1214     function PasswordAuthorization(name, username, password) {
1215       this.name = name;
1216       this.username = username;
1217       this.password = password;
1218     }
1219
1220     PasswordAuthorization.prototype.apply = function(obj) {
1221       return obj.headers["Authorization"] = "Basic " + btoa(this.username + ":" + this.password);
1222     };
1223
1224     return PasswordAuthorization;
1225
1226   })();
1227
1228   this.SwaggerApi = SwaggerApi;
1229
1230   this.SwaggerResource = SwaggerResource;
1231
1232   this.SwaggerOperation = SwaggerOperation;
1233
1234   this.SwaggerRequest = SwaggerRequest;
1235
1236   this.SwaggerModelProperty = SwaggerModelProperty;
1237
1238   this.ApiKeyAuthorization = ApiKeyAuthorization;
1239
1240   this.PasswordAuthorization = PasswordAuthorization;
1241
1242   this.authorizations = new SwaggerAuthorizations();
1243
1244 }).call(this);