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