jellyfish 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,193 +0,0 @@
1
-
2
- // The purpose of the `Content` object is to abstract away the data conversions
3
- // to and from raw content entities as strings. For example, you want to be able
4
- // to pass in a Javascript object and have it be automatically converted into a
5
- // JSON string if the `content-type` is set to a JSON-based media type.
6
- // Conversely, you want to be able to transparently get back a Javascript object
7
- // in the response if the `content-type` is a JSON-based media-type.
8
-
9
- // One limitation of the current implementation is that it [assumes the `charset` is UTF-8](https://github.com/spire-io/shred/issues/5).
10
-
11
- // The `Content` constructor takes an options object, which *must* have either a
12
- // `body` or `data` property and *may* have a `type` property indicating the
13
- // media type. If there is no `type` attribute, a default will be inferred.
14
- var Content = function(options) {
15
- this.body = options.body;
16
- this.data = options.data;
17
- this.type = options.type;
18
- };
19
-
20
- Content.prototype = {
21
- // Treat `toString()` as asking for the `content.body`. That is, the raw content entity.
22
- //
23
- // toString: function() { return this.body; }
24
- //
25
- // Commented out, but I've forgotten why. :/
26
- };
27
-
28
-
29
- // `Content` objects have the following attributes:
30
- Object.defineProperties(Content.prototype,{
31
-
32
- // - **type**. Typically accessed as `content.type`, reflects the `content-type`
33
- // header associated with the request or response. If not passed as an options
34
- // to the constructor or set explicitly, it will infer the type the `data`
35
- // attribute, if possible, and, failing that, will default to `text/plain`.
36
- type: {
37
- get: function() {
38
- if (this._type) {
39
- return this._type;
40
- } else {
41
- if (this._data) {
42
- switch(typeof this._data) {
43
- case "string": return "text/plain";
44
- case "object": return "application/json";
45
- }
46
- }
47
- }
48
- return "text/plain";
49
- },
50
- set: function(value) {
51
- this._type = value;
52
- return this;
53
- },
54
- enumerable: true
55
- },
56
-
57
- // - **data**. Typically accessed as `content.data`, reflects the content entity
58
- // converted into Javascript data. This can be a string, if the `type` is, say,
59
- // `text/plain`, but can also be a Javascript object. The conversion applied is
60
- // based on the `processor` attribute. The `data` attribute can also be set
61
- // directly, in which case the conversion will be done the other way, to infer
62
- // the `body` attribute.
63
- data: {
64
- get: function() {
65
- if (this._body) {
66
- return this.processor.parser(this._body);
67
- } else {
68
- return this._data;
69
- }
70
- },
71
- set: function(data) {
72
- if (this._body&&data) Errors.setDataWithBody(this);
73
- this._data = data;
74
- return this;
75
- },
76
- enumerable: true
77
- },
78
-
79
- // - **body**. Typically accessed as `content.body`, reflects the content entity
80
- // as a UTF-8 string. It is the mirror of the `data` attribute. If you set the
81
- // `data` attribute, the `body` attribute will be inferred and vice-versa. If
82
- // you attempt to set both, an exception is raised.
83
- body: {
84
- get: function() {
85
- if (this._data) {
86
- return this.processor.stringify(this._data);
87
- } else {
88
- return this._body.toString();
89
- }
90
- },
91
- set: function(body) {
92
- if (this._data&&body) Errors.setBodyWithData(this);
93
- this._body = body;
94
- return this;
95
- },
96
- enumerable: true
97
- },
98
-
99
- // - **processor**. The functions that will be used to convert to/from `data` and
100
- // `body` attributes. You can add processors. The two that are built-in are for
101
- // `text/plain`, which is basically an identity transformation and
102
- // `application/json` and other JSON-based media types (including custom media
103
- // types with `+json`). You can add your own processors. See below.
104
- processor: {
105
- get: function() {
106
- var processor = Content.processors[this.type];
107
- if (processor) {
108
- return processor;
109
- } else {
110
- // Return the first processor that matches any part of the
111
- // content type. ex: application/vnd.foobar.baz+json will match json.
112
- var main = this.type.split(";")[0];
113
- var parts = main.split(/\+|\//);
114
- for (var i=0, l=parts.length; i < l; i++) {
115
- processor = Content.processors[parts[i]]
116
- }
117
- return processor || {parser:identity,stringify:toString};
118
- }
119
- },
120
- enumerable: true
121
- },
122
-
123
- // - **length**. Typically accessed as `content.length`, returns the length in
124
- // bytes of the raw content entity.
125
- length: {
126
- get: function() {
127
- if (typeof Buffer !== 'undefined') {
128
- return Buffer.byteLength(this.body);
129
- }
130
- return this.body.length;
131
- }
132
- }
133
- });
134
-
135
- Content.processors = {};
136
-
137
- // The `registerProcessor` function allows you to add your own processors to
138
- // convert content entities. Each processor consists of a Javascript object with
139
- // two properties:
140
- // - **parser**. The function used to parse a raw content entity and convert it
141
- // into a Javascript data type.
142
- // - **stringify**. The function used to convert a Javascript data type into a
143
- // raw content entity.
144
- Content.registerProcessor = function(types,processor) {
145
-
146
- // You can pass an array of types that will trigger this processor, or just one.
147
- // We determine the array via duck-typing here.
148
- if (types.forEach) {
149
- types.forEach(function(type) {
150
- Content.processors[type] = processor;
151
- });
152
- } else {
153
- // If you didn't pass an array, we just use what you pass in.
154
- Content.processors[types] = processor;
155
- }
156
- };
157
-
158
- // Register the identity processor, which is used for text-based media types.
159
- var identity = function(x) { return x; }
160
- , toString = function(x) { return x.toString(); }
161
- Content.registerProcessor(
162
- ["text/html","text/plain","text"],
163
- { parser: identity, stringify: toString });
164
-
165
- // Register the JSON processor, which is used for JSON-based media types.
166
- Content.registerProcessor(
167
- ["application/json; charset=utf-8","application/json","json"],
168
- {
169
- parser: function(string) {
170
- return JSON.parse(string);
171
- },
172
- stringify: function(data) {
173
- return JSON.stringify(data); }});
174
-
175
- var qs = require('querystring');
176
- // Register the post processor, which is used for JSON-based media types.
177
- Content.registerProcessor(
178
- ["application/x-www-form-urlencoded"],
179
- { parser : qs.parse, stringify : qs.stringify });
180
-
181
- // Error functions are defined separately here in an attempt to make the code
182
- // easier to read.
183
- var Errors = {
184
- setDataWithBody: function(object) {
185
- throw new Error("Attempt to set data attribute of a content object " +
186
- "when the body attributes was already set.");
187
- },
188
- setBodyWithData: function(object) {
189
- throw new Error("Attempt to set body attribute of a content object " +
190
- "when the data attributes was already set.");
191
- }
192
- }
193
- module.exports = Content;
@@ -1,2116 +0,0 @@
1
- $(function() {
2
-
3
- // Helper function for vertically aligning DOM elements
4
- // http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/
5
- $.fn.vAlign = function() {
6
- return this.each(function(i){
7
- var ah = $(this).height();
8
- var ph = $(this).parent().height();
9
- var mh = (ph - ah) / 2;
10
- $(this).css('margin-top', mh);
11
- });
12
- };
13
-
14
- $.fn.stretchFormtasticInputWidthToParent = function() {
15
- return this.each(function(i){
16
- var p_width = $(this).closest("form").innerWidth();
17
- var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest("form").css('padding-right'), 10);
18
- var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10);
19
- $(this).css('width', p_width - p_padding - this_padding);
20
- });
21
- };
22
-
23
- $('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent();
24
-
25
- // Vertically center these paragraphs
26
- // Parent may need a min-height for this to work..
27
- $('ul.downplayed li div.content p').vAlign();
28
-
29
- // When a sandbox form is submitted..
30
- $("form.sandbox").submit(function(){
31
-
32
- var error_free = true;
33
-
34
- // Cycle through the forms required inputs
35
- $(this).find("input.required").each(function() {
36
-
37
- // Remove any existing error styles from the input
38
- $(this).removeClass('error');
39
-
40
- // Tack the error style on if the input is empty..
41
- if ($(this).val() == '') {
42
- $(this).addClass('error');
43
- $(this).wiggle();
44
- error_free = false;
45
- }
46
-
47
- });
48
-
49
- return error_free;
50
- });
51
-
52
- });
53
-
54
- function clippyCopiedCallback(a) {
55
- $('#api_key_copied').fadeIn().delay(1000).fadeOut();
56
-
57
- // var b = $("#clippy_tooltip_" + a);
58
- // b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() {
59
- // b.attr("title", "copy to clipboard")
60
- // },
61
- // 500))
62
- }
63
-
64
- // Logging function that accounts for browsers that don't have window.console
65
- log = function(){
66
- log.history = log.history || [];
67
- log.history.push(arguments);
68
- if(this.console){
69
- console.log( Array.prototype.slice.call(arguments) );
70
- }
71
- };
72
-
73
- // Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913)
74
- if (Function.prototype.bind && console && typeof console.log == "object") {
75
- [
76
- "log","info","warn","error","assert","dir","clear","profile","profileEnd"
77
- ].forEach(function (method) {
78
- console[method] = this.bind(console[method], console);
79
- }, Function.prototype.call);
80
- }
81
-
82
- var Docs = {
83
-
84
- shebang: function() {
85
-
86
- // If shebang has an operation nickname in it..
87
- // e.g. /docs/#!/words/get_search
88
- var fragments = $.param.fragment().split('/');
89
- fragments.shift(); // get rid of the bang
90
-
91
- switch (fragments.length) {
92
- case 1:
93
- // Expand all operations for the resource and scroll to it
94
- log('shebang resource:' + fragments[0]);
95
- var dom_id = 'resource_' + fragments[0];
96
-
97
- Docs.expandEndpointListForResource(fragments[0]);
98
- $("#"+dom_id).slideto({highlight: false});
99
- break;
100
- case 2:
101
- // Refer to the endpoint DOM element, e.g. #words_get_search
102
- log('shebang endpoint: ' + fragments.join('_'));
103
-
104
- // Expand Resource
105
- Docs.expandEndpointListForResource(fragments[0]);
106
- $("#"+dom_id).slideto({highlight: false});
107
-
108
- // Expand operation
109
- var li_dom_id = fragments.join('_');
110
- var li_content_dom_id = li_dom_id + "_content";
111
-
112
- log("li_dom_id " + li_dom_id);
113
- log("li_content_dom_id " + li_content_dom_id);
114
-
115
- Docs.expandOperation($('#'+li_content_dom_id));
116
- $('#'+li_dom_id).slideto({highlight: false});
117
- break;
118
- }
119
-
120
- },
121
-
122
- toggleEndpointListForResource: function(resource) {
123
- var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints');
124
- if (elem.is(':visible')) {
125
- Docs.collapseEndpointListForResource(resource);
126
- } else {
127
- Docs.expandEndpointListForResource(resource);
128
- }
129
- },
130
-
131
- // Expand resource
132
- expandEndpointListForResource: function(resource) {
133
- var resource = Docs.escapeResourceName(resource);
134
- if (resource == '') {
135
- $('.resource ul.endpoints').slideDown();
136
- return;
137
- }
138
-
139
- $('li#resource_' + resource).addClass('active');
140
-
141
- var elem = $('li#resource_' + resource + ' ul.endpoints');
142
- elem.slideDown();
143
- },
144
-
145
- // Collapse resource and mark as explicitly closed
146
- collapseEndpointListForResource: function(resource) {
147
- var resource = Docs.escapeResourceName(resource);
148
- $('li#resource_' + resource).removeClass('active');
149
-
150
- var elem = $('li#resource_' + resource + ' ul.endpoints');
151
- elem.slideUp();
152
- },
153
-
154
- expandOperationsForResource: function(resource) {
155
- // Make sure the resource container is open..
156
- Docs.expandEndpointListForResource(resource);
157
-
158
- if (resource == '') {
159
- $('.resource ul.endpoints li.operation div.content').slideDown();
160
- return;
161
- }
162
-
163
- $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
164
- Docs.expandOperation($(this));
165
- });
166
- },
167
-
168
- collapseOperationsForResource: function(resource) {
169
- // Make sure the resource container is open..
170
- Docs.expandEndpointListForResource(resource);
171
-
172
- $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
173
- Docs.collapseOperation($(this));
174
- });
175
- },
176
-
177
- escapeResourceName: function(resource) {
178
- return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&");
179
- },
180
-
181
- expandOperation: function(elem) {
182
- elem.slideDown();
183
- },
184
-
185
- collapseOperation: function(elem) {
186
- elem.slideUp();
187
- }
188
- };(function() {
189
- var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
190
- templates['content_type'] = template(function (Handlebars,depth0,helpers,partials,data) {
191
- this.compilerInfo = [4,'>= 1.0.0'];
192
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
193
- var buffer = "", stack1, functionType="function", self=this;
194
-
195
- function program1(depth0,data) {
196
-
197
- var buffer = "", stack1;
198
- buffer += "\n ";
199
- stack1 = helpers.each.call(depth0, depth0.produces, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
200
- if(stack1 || stack1 === 0) { buffer += stack1; }
201
- buffer += "\n";
202
- return buffer;
203
- }
204
- function program2(depth0,data) {
205
-
206
- var buffer = "", stack1;
207
- buffer += "\n <option value=\"";
208
- stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
209
- if(stack1 || stack1 === 0) { buffer += stack1; }
210
- buffer += "\">";
211
- stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
212
- if(stack1 || stack1 === 0) { buffer += stack1; }
213
- buffer += "</option>\n ";
214
- return buffer;
215
- }
216
-
217
- function program4(depth0,data) {
218
-
219
-
220
- return "\n <option value=\"application/json\">application/json</option>\n";
221
- }
222
-
223
- buffer += "<label for=\"contentType\"></label>\n<select name=\"contentType\">\n";
224
- stack1 = helpers['if'].call(depth0, depth0.produces, {hash:{},inverse:self.program(4, program4, data),fn:self.program(1, program1, data),data:data});
225
- if(stack1 || stack1 === 0) { buffer += stack1; }
226
- buffer += "\n</select>\n";
227
- return buffer;
228
- });
229
- })();
230
-
231
- (function() {
232
- var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
233
- templates['main'] = template(function (Handlebars,depth0,helpers,partials,data) {
234
- this.compilerInfo = [4,'>= 1.0.0'];
235
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
236
- var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
237
-
238
- function program1(depth0,data) {
239
-
240
- var buffer = "", stack1, stack2;
241
- buffer += "\n <div class=\"info_title\">"
242
- + escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.title)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
243
- + "</div>\n <div class=\"info_description\">";
244
- stack2 = ((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.description)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1);
245
- if(stack2 || stack2 === 0) { buffer += stack2; }
246
- buffer += "</div>\n ";
247
- stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.termsOfServiceUrl), {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
248
- if(stack2 || stack2 === 0) { buffer += stack2; }
249
- buffer += "\n ";
250
- stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.contact), {hash:{},inverse:self.noop,fn:self.program(4, program4, data),data:data});
251
- if(stack2 || stack2 === 0) { buffer += stack2; }
252
- buffer += "\n ";
253
- stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.license), {hash:{},inverse:self.noop,fn:self.program(6, program6, data),data:data});
254
- if(stack2 || stack2 === 0) { buffer += stack2; }
255
- buffer += "\n ";
256
- return buffer;
257
- }
258
- function program2(depth0,data) {
259
-
260
- var buffer = "", stack1;
261
- buffer += "<div class=\"info_tos\"><a href=\""
262
- + escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.termsOfServiceUrl)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
263
- + "\">Terms of service</a></div>";
264
- return buffer;
265
- }
266
-
267
- function program4(depth0,data) {
268
-
269
- var buffer = "", stack1;
270
- buffer += "<div class='info_contact'><a href=\"mailto:"
271
- + escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.contact)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
272
- + "\">Contact the developer</a></div>";
273
- return buffer;
274
- }
275
-
276
- function program6(depth0,data) {
277
-
278
- var buffer = "", stack1;
279
- buffer += "<div class='info_license'><a href='"
280
- + escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.licenseUrl)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
281
- + "'>"
282
- + escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.license)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
283
- + "</a></div>";
284
- return buffer;
285
- }
286
-
287
- function program8(depth0,data) {
288
-
289
- var buffer = "", stack1;
290
- buffer += "\n , <span style=\"font-variant: small-caps\">api version</span>: ";
291
- if (stack1 = helpers.apiVersion) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
292
- else { stack1 = depth0.apiVersion; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
293
- buffer += escapeExpression(stack1)
294
- + "\n ";
295
- return buffer;
296
- }
297
-
298
- buffer += "<div class='info' id='api_info'>\n ";
299
- stack1 = helpers['if'].call(depth0, depth0.info, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
300
- if(stack1 || stack1 === 0) { buffer += stack1; }
301
- buffer += "\n</div>\n<div class='container' id='resources_container'>\n <ul id='resources'>\n </ul>\n\n <div class=\"footer\">\n <br>\n <br>\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\">base url</span>: ";
302
- if (stack1 = helpers.basePath) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
303
- else { stack1 = depth0.basePath; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
304
- buffer += escapeExpression(stack1)
305
- + "\n ";
306
- stack1 = helpers['if'].call(depth0, depth0.apiVersion, {hash:{},inverse:self.noop,fn:self.program(8, program8, data),data:data});
307
- if(stack1 || stack1 === 0) { buffer += stack1; }
308
- buffer += "]</h4>\n </div>\n</div>\n";
309
- return buffer;
310
- });
311
- })();
312
-
313
- (function() {
314
- var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
315
- templates['operation'] = template(function (Handlebars,depth0,helpers,partials,data) {
316
- this.compilerInfo = [4,'>= 1.0.0'];
317
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
318
- var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
319
-
320
- function program1(depth0,data) {
321
-
322
- var buffer = "", stack1;
323
- buffer += "\n <h4>Implementation Notes</h4>\n <p>";
324
- if (stack1 = helpers.notes) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
325
- else { stack1 = depth0.notes; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
326
- if(stack1 || stack1 === 0) { buffer += stack1; }
327
- buffer += "</p>\n ";
328
- return buffer;
329
- }
330
-
331
- function program3(depth0,data) {
332
-
333
-
334
- return "\n <h4>Response Class</h4>\n <p><span class=\"model-signature\" /></p>\n <br/>\n <div class=\"response-content-type\" />\n ";
335
- }
336
-
337
- function program5(depth0,data) {
338
-
339
-
340
- return "\n <h4>Parameters</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th style=\"width: 100px; max-width: 100px\">Parameter</th>\n <th style=\"width: 310px; max-width: 310px\">Value</th>\n <th style=\"width: 200px; max-width: 200px\">Description</th>\n <th style=\"width: 100px; max-width: 100px\">Parameter Type</th>\n <th style=\"width: 220px; max-width: 230px\">Data Type</th>\n </tr>\n </thead>\n <tbody class=\"operation-params\">\n\n </tbody>\n </table>\n ";
341
- }
342
-
343
- function program7(depth0,data) {
344
-
345
-
346
- return "\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Error Status Codes</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>HTTP Status Code</th>\n <th>Reason</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n ";
347
- }
348
-
349
- function program9(depth0,data) {
350
-
351
-
352
- return "\n ";
353
- }
354
-
355
- function program11(depth0,data) {
356
-
357
-
358
- return "\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <img alt='Throbber' class='response_throbber' src='images/throbber.gif' style='display:none' />\n </div>\n ";
359
- }
360
-
361
- buffer += "\n <ul class='operations' >\n <li class='";
362
- if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
363
- else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
364
- buffer += escapeExpression(stack1)
365
- + " operation' id='";
366
- if (stack1 = helpers.parentId) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
367
- else { stack1 = depth0.parentId; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
368
- buffer += escapeExpression(stack1)
369
- + "_";
370
- if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
371
- else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
372
- buffer += escapeExpression(stack1)
373
- + "'>\n <div class='heading'>\n <h3>\n <span class='http_method'>\n <a href='#!/";
374
- if (stack1 = helpers.parentId) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
375
- else { stack1 = depth0.parentId; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
376
- buffer += escapeExpression(stack1)
377
- + "/";
378
- if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
379
- else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
380
- buffer += escapeExpression(stack1)
381
- + "' class=\"toggleOperation\">";
382
- if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
383
- else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
384
- buffer += escapeExpression(stack1)
385
- + "</a>\n </span>\n <span class='path'>\n <a href='#!/";
386
- if (stack1 = helpers.parentId) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
387
- else { stack1 = depth0.parentId; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
388
- buffer += escapeExpression(stack1)
389
- + "/";
390
- if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
391
- else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
392
- buffer += escapeExpression(stack1)
393
- + "' class=\"toggleOperation\">";
394
- if (stack1 = helpers.path) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
395
- else { stack1 = depth0.path; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
396
- buffer += escapeExpression(stack1)
397
- + "</a>\n </span>\n </h3>\n <ul class='options'>\n <li>\n <a href='#!/";
398
- if (stack1 = helpers.parentId) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
399
- else { stack1 = depth0.parentId; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
400
- buffer += escapeExpression(stack1)
401
- + "/";
402
- if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
403
- else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
404
- buffer += escapeExpression(stack1)
405
- + "' class=\"toggleOperation\">";
406
- if (stack1 = helpers.summary) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
407
- else { stack1 = depth0.summary; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
408
- if(stack1 || stack1 === 0) { buffer += stack1; }
409
- buffer += "</a>\n </li>\n </ul>\n </div>\n <div class='content' id='";
410
- if (stack1 = helpers.parentId) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
411
- else { stack1 = depth0.parentId; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
412
- buffer += escapeExpression(stack1)
413
- + "_";
414
- if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
415
- else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
416
- buffer += escapeExpression(stack1)
417
- + "_content' style='display:none'>\n ";
418
- stack1 = helpers['if'].call(depth0, depth0.notes, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
419
- if(stack1 || stack1 === 0) { buffer += stack1; }
420
- buffer += "\n ";
421
- stack1 = helpers['if'].call(depth0, depth0.type, {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});
422
- if(stack1 || stack1 === 0) { buffer += stack1; }
423
- buffer += "\n <form accept-charset='UTF-8' class='sandbox'>\n <div style='margin:0;padding:0;display:inline'></div>\n ";
424
- stack1 = helpers['if'].call(depth0, depth0.parameters, {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data});
425
- if(stack1 || stack1 === 0) { buffer += stack1; }
426
- buffer += "\n ";
427
- stack1 = helpers['if'].call(depth0, depth0.responseMessages, {hash:{},inverse:self.noop,fn:self.program(7, program7, data),data:data});
428
- if(stack1 || stack1 === 0) { buffer += stack1; }
429
- buffer += "\n ";
430
- stack1 = helpers['if'].call(depth0, depth0.isReadOnly, {hash:{},inverse:self.program(11, program11, data),fn:self.program(9, program9, data),data:data});
431
- if(stack1 || stack1 === 0) { buffer += stack1; }
432
- buffer += "\n </form>\n <div class='response' style='display:none'>\n <h4>Request URL</h4>\n <div class='block request_url'></div>\n <h4>Response Body</h4>\n <div class='block response_body'></div>\n <h4>Response Code</h4>\n <div class='block response_code'></div>\n <h4>Response Headers</h4>\n <div class='block response_headers'></div>\n </div>\n </div>\n </li>\n </ul>\n";
433
- return buffer;
434
- });
435
- })();
436
-
437
- (function() {
438
- var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
439
- templates['param'] = template(function (Handlebars,depth0,helpers,partials,data) {
440
- this.compilerInfo = [4,'>= 1.0.0'];
441
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
442
- var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
443
-
444
- function program1(depth0,data) {
445
-
446
- var buffer = "", stack1;
447
- buffer += "\n ";
448
- stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(4, program4, data),fn:self.program(2, program2, data),data:data});
449
- if(stack1 || stack1 === 0) { buffer += stack1; }
450
- buffer += "\n ";
451
- return buffer;
452
- }
453
- function program2(depth0,data) {
454
-
455
- var buffer = "", stack1;
456
- buffer += "\n <input type=\"file\" name='";
457
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
458
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
459
- buffer += escapeExpression(stack1)
460
- + "'/>\n <div class=\"parameter-content-type\" />\n ";
461
- return buffer;
462
- }
463
-
464
- function program4(depth0,data) {
465
-
466
- var buffer = "", stack1;
467
- buffer += "\n ";
468
- stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(7, program7, data),fn:self.program(5, program5, data),data:data});
469
- if(stack1 || stack1 === 0) { buffer += stack1; }
470
- buffer += "\n ";
471
- return buffer;
472
- }
473
- function program5(depth0,data) {
474
-
475
- var buffer = "", stack1;
476
- buffer += "\n <textarea class='body-textarea' name='";
477
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
478
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
479
- buffer += escapeExpression(stack1)
480
- + "'>";
481
- if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
482
- else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
483
- buffer += escapeExpression(stack1)
484
- + "</textarea>\n ";
485
- return buffer;
486
- }
487
-
488
- function program7(depth0,data) {
489
-
490
- var buffer = "", stack1;
491
- buffer += "\n <textarea class='body-textarea' name='";
492
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
493
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
494
- buffer += escapeExpression(stack1)
495
- + "'></textarea>\n <br />\n <div class=\"parameter-content-type\" />\n ";
496
- return buffer;
497
- }
498
-
499
- function program9(depth0,data) {
500
-
501
- var buffer = "", stack1;
502
- buffer += "\n ";
503
- stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(12, program12, data),fn:self.program(10, program10, data),data:data});
504
- if(stack1 || stack1 === 0) { buffer += stack1; }
505
- buffer += "\n ";
506
- return buffer;
507
- }
508
- function program10(depth0,data) {
509
-
510
- var buffer = "", stack1;
511
- buffer += "\n <input class='parameter' minlength='0' name='";
512
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
513
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
514
- buffer += escapeExpression(stack1)
515
- + "' placeholder='' type='text' value='";
516
- if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
517
- else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
518
- buffer += escapeExpression(stack1)
519
- + "'/>\n ";
520
- return buffer;
521
- }
522
-
523
- function program12(depth0,data) {
524
-
525
- var buffer = "", stack1;
526
- buffer += "\n <input class='parameter' minlength='0' name='";
527
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
528
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
529
- buffer += escapeExpression(stack1)
530
- + "' placeholder='' type='text' value=''/>\n ";
531
- return buffer;
532
- }
533
-
534
- buffer += "<td class='code'>";
535
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
536
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
537
- buffer += escapeExpression(stack1)
538
- + "</td>\n<td>\n\n ";
539
- stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(9, program9, data),fn:self.program(1, program1, data),data:data});
540
- if(stack1 || stack1 === 0) { buffer += stack1; }
541
- buffer += "\n\n</td>\n<td>";
542
- if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
543
- else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
544
- if(stack1 || stack1 === 0) { buffer += stack1; }
545
- buffer += "</td>\n<td>";
546
- if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
547
- else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
548
- if(stack1 || stack1 === 0) { buffer += stack1; }
549
- buffer += "</td>\n<td>\n <span class=\"model-signature\"></span>\n</td>\n";
550
- return buffer;
551
- });
552
- })();
553
-
554
- (function() {
555
- var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
556
- templates['param_list'] = template(function (Handlebars,depth0,helpers,partials,data) {
557
- this.compilerInfo = [4,'>= 1.0.0'];
558
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
559
- var buffer = "", stack1, stack2, self=this, functionType="function", escapeExpression=this.escapeExpression;
560
-
561
- function program1(depth0,data) {
562
-
563
-
564
- return " multiple='multiple'";
565
- }
566
-
567
- function program3(depth0,data) {
568
-
569
-
570
- return "\n ";
571
- }
572
-
573
- function program5(depth0,data) {
574
-
575
- var buffer = "", stack1;
576
- buffer += "\n ";
577
- stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(8, program8, data),fn:self.program(6, program6, data),data:data});
578
- if(stack1 || stack1 === 0) { buffer += stack1; }
579
- buffer += "\n ";
580
- return buffer;
581
- }
582
- function program6(depth0,data) {
583
-
584
-
585
- return "\n ";
586
- }
587
-
588
- function program8(depth0,data) {
589
-
590
- var buffer = "", stack1;
591
- buffer += "\n ";
592
- stack1 = helpers['if'].call(depth0, depth0.allowMultiple, {hash:{},inverse:self.program(11, program11, data),fn:self.program(9, program9, data),data:data});
593
- if(stack1 || stack1 === 0) { buffer += stack1; }
594
- buffer += "\n ";
595
- return buffer;
596
- }
597
- function program9(depth0,data) {
598
-
599
-
600
- return "\n ";
601
- }
602
-
603
- function program11(depth0,data) {
604
-
605
-
606
- return "\n <option selected=\"\" value=''></option>\n ";
607
- }
608
-
609
- function program13(depth0,data) {
610
-
611
- var buffer = "", stack1;
612
- buffer += "\n ";
613
- stack1 = helpers['if'].call(depth0, depth0.isDefault, {hash:{},inverse:self.program(16, program16, data),fn:self.program(14, program14, data),data:data});
614
- if(stack1 || stack1 === 0) { buffer += stack1; }
615
- buffer += "\n ";
616
- return buffer;
617
- }
618
- function program14(depth0,data) {
619
-
620
- var buffer = "", stack1;
621
- buffer += "\n <option selected=\"\" value='";
622
- if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
623
- else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
624
- buffer += escapeExpression(stack1)
625
- + "'>";
626
- if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
627
- else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
628
- buffer += escapeExpression(stack1)
629
- + " (default)</option>\n ";
630
- return buffer;
631
- }
632
-
633
- function program16(depth0,data) {
634
-
635
- var buffer = "", stack1;
636
- buffer += "\n <option value='";
637
- if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
638
- else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
639
- buffer += escapeExpression(stack1)
640
- + "'>";
641
- if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
642
- else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
643
- buffer += escapeExpression(stack1)
644
- + "</option>\n ";
645
- return buffer;
646
- }
647
-
648
- buffer += "<td class='code'>";
649
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
650
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
651
- buffer += escapeExpression(stack1)
652
- + "</td>\n<td>\n <select ";
653
- stack1 = helpers['if'].call(depth0, depth0.allowMultiple, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
654
- if(stack1 || stack1 === 0) { buffer += stack1; }
655
- buffer += " class='parameter' name='";
656
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
657
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
658
- buffer += escapeExpression(stack1)
659
- + "'>\n ";
660
- stack1 = helpers['if'].call(depth0, depth0.required, {hash:{},inverse:self.program(5, program5, data),fn:self.program(3, program3, data),data:data});
661
- if(stack1 || stack1 === 0) { buffer += stack1; }
662
- buffer += "\n ";
663
- stack2 = helpers.each.call(depth0, ((stack1 = depth0.allowableValues),stack1 == null || stack1 === false ? stack1 : stack1.descriptiveValues), {hash:{},inverse:self.noop,fn:self.program(13, program13, data),data:data});
664
- if(stack2 || stack2 === 0) { buffer += stack2; }
665
- buffer += "\n </select>\n</td>\n<td>";
666
- if (stack2 = helpers.description) { stack2 = stack2.call(depth0, {hash:{},data:data}); }
667
- else { stack2 = depth0.description; stack2 = typeof stack2 === functionType ? stack2.apply(depth0) : stack2; }
668
- if(stack2 || stack2 === 0) { buffer += stack2; }
669
- buffer += "</td>\n<td>";
670
- if (stack2 = helpers.paramType) { stack2 = stack2.call(depth0, {hash:{},data:data}); }
671
- else { stack2 = depth0.paramType; stack2 = typeof stack2 === functionType ? stack2.apply(depth0) : stack2; }
672
- if(stack2 || stack2 === 0) { buffer += stack2; }
673
- buffer += "</td>\n<td><span class=\"model-signature\"></span></td>";
674
- return buffer;
675
- });
676
- })();
677
-
678
- (function() {
679
- var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
680
- templates['param_readonly'] = template(function (Handlebars,depth0,helpers,partials,data) {
681
- this.compilerInfo = [4,'>= 1.0.0'];
682
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
683
- var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
684
-
685
- function program1(depth0,data) {
686
-
687
- var buffer = "", stack1;
688
- buffer += "\n <textarea class='body-textarea' readonly='readonly' name='";
689
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
690
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
691
- buffer += escapeExpression(stack1)
692
- + "'>";
693
- if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
694
- else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
695
- buffer += escapeExpression(stack1)
696
- + "</textarea>\n ";
697
- return buffer;
698
- }
699
-
700
- function program3(depth0,data) {
701
-
702
- var buffer = "", stack1;
703
- buffer += "\n ";
704
- stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(6, program6, data),fn:self.program(4, program4, data),data:data});
705
- if(stack1 || stack1 === 0) { buffer += stack1; }
706
- buffer += "\n ";
707
- return buffer;
708
- }
709
- function program4(depth0,data) {
710
-
711
- var buffer = "", stack1;
712
- buffer += "\n ";
713
- if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
714
- else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
715
- buffer += escapeExpression(stack1)
716
- + "\n ";
717
- return buffer;
718
- }
719
-
720
- function program6(depth0,data) {
721
-
722
-
723
- return "\n (empty)\n ";
724
- }
725
-
726
- buffer += "<td class='code'>";
727
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
728
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
729
- buffer += escapeExpression(stack1)
730
- + "</td>\n<td>\n ";
731
- stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(3, program3, data),fn:self.program(1, program1, data),data:data});
732
- if(stack1 || stack1 === 0) { buffer += stack1; }
733
- buffer += "\n</td>\n<td>";
734
- if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
735
- else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
736
- if(stack1 || stack1 === 0) { buffer += stack1; }
737
- buffer += "</td>\n<td>";
738
- if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
739
- else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
740
- if(stack1 || stack1 === 0) { buffer += stack1; }
741
- buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n";
742
- return buffer;
743
- });
744
- })();
745
-
746
- (function() {
747
- var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
748
- templates['param_readonly_required'] = template(function (Handlebars,depth0,helpers,partials,data) {
749
- this.compilerInfo = [4,'>= 1.0.0'];
750
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
751
- var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
752
-
753
- function program1(depth0,data) {
754
-
755
- var buffer = "", stack1;
756
- buffer += "\n <textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='";
757
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
758
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
759
- buffer += escapeExpression(stack1)
760
- + "'>";
761
- if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
762
- else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
763
- buffer += escapeExpression(stack1)
764
- + "</textarea>\n ";
765
- return buffer;
766
- }
767
-
768
- function program3(depth0,data) {
769
-
770
- var buffer = "", stack1;
771
- buffer += "\n ";
772
- stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(6, program6, data),fn:self.program(4, program4, data),data:data});
773
- if(stack1 || stack1 === 0) { buffer += stack1; }
774
- buffer += "\n ";
775
- return buffer;
776
- }
777
- function program4(depth0,data) {
778
-
779
- var buffer = "", stack1;
780
- buffer += "\n ";
781
- if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
782
- else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
783
- buffer += escapeExpression(stack1)
784
- + "\n ";
785
- return buffer;
786
- }
787
-
788
- function program6(depth0,data) {
789
-
790
-
791
- return "\n (empty)\n ";
792
- }
793
-
794
- buffer += "<td class='code required'>";
795
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
796
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
797
- buffer += escapeExpression(stack1)
798
- + "</td>\n<td>\n ";
799
- stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(3, program3, data),fn:self.program(1, program1, data),data:data});
800
- if(stack1 || stack1 === 0) { buffer += stack1; }
801
- buffer += "\n</td>\n<td>";
802
- if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
803
- else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
804
- if(stack1 || stack1 === 0) { buffer += stack1; }
805
- buffer += "</td>\n<td>";
806
- if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
807
- else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
808
- if(stack1 || stack1 === 0) { buffer += stack1; }
809
- buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n";
810
- return buffer;
811
- });
812
- })();
813
-
814
- (function() {
815
- var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
816
- templates['param_required'] = template(function (Handlebars,depth0,helpers,partials,data) {
817
- this.compilerInfo = [4,'>= 1.0.0'];
818
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
819
- var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
820
-
821
- function program1(depth0,data) {
822
-
823
- var buffer = "", stack1;
824
- buffer += "\n ";
825
- stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(4, program4, data),fn:self.program(2, program2, data),data:data});
826
- if(stack1 || stack1 === 0) { buffer += stack1; }
827
- buffer += "\n ";
828
- return buffer;
829
- }
830
- function program2(depth0,data) {
831
-
832
- var buffer = "", stack1;
833
- buffer += "\n <input type=\"file\" name='";
834
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
835
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
836
- buffer += escapeExpression(stack1)
837
- + "'/>\n ";
838
- return buffer;
839
- }
840
-
841
- function program4(depth0,data) {
842
-
843
- var buffer = "", stack1;
844
- buffer += "\n ";
845
- stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(7, program7, data),fn:self.program(5, program5, data),data:data});
846
- if(stack1 || stack1 === 0) { buffer += stack1; }
847
- buffer += "\n ";
848
- return buffer;
849
- }
850
- function program5(depth0,data) {
851
-
852
- var buffer = "", stack1;
853
- buffer += "\n <textarea class='body-textarea' placeholder='(required)' name='";
854
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
855
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
856
- buffer += escapeExpression(stack1)
857
- + "'>";
858
- if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
859
- else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
860
- buffer += escapeExpression(stack1)
861
- + "</textarea>\n ";
862
- return buffer;
863
- }
864
-
865
- function program7(depth0,data) {
866
-
867
- var buffer = "", stack1;
868
- buffer += "\n <textarea class='body-textarea' placeholder='(required)' name='";
869
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
870
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
871
- buffer += escapeExpression(stack1)
872
- + "'></textarea>\n <br />\n <div class=\"parameter-content-type\" />\n ";
873
- return buffer;
874
- }
875
-
876
- function program9(depth0,data) {
877
-
878
- var buffer = "", stack1;
879
- buffer += "\n ";
880
- stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(12, program12, data),fn:self.program(10, program10, data),data:data});
881
- if(stack1 || stack1 === 0) { buffer += stack1; }
882
- buffer += "\n ";
883
- return buffer;
884
- }
885
- function program10(depth0,data) {
886
-
887
- var buffer = "", stack1;
888
- buffer += "\n <input class='parameter' class='required' type='file' name='";
889
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
890
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
891
- buffer += escapeExpression(stack1)
892
- + "'/>\n ";
893
- return buffer;
894
- }
895
-
896
- function program12(depth0,data) {
897
-
898
- var buffer = "", stack1;
899
- buffer += "\n ";
900
- stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(15, program15, data),fn:self.program(13, program13, data),data:data});
901
- if(stack1 || stack1 === 0) { buffer += stack1; }
902
- buffer += "\n ";
903
- return buffer;
904
- }
905
- function program13(depth0,data) {
906
-
907
- var buffer = "", stack1;
908
- buffer += "\n <input class='parameter required' minlength='1' name='";
909
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
910
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
911
- buffer += escapeExpression(stack1)
912
- + "' placeholder='(required)' type='text' value='";
913
- if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
914
- else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
915
- buffer += escapeExpression(stack1)
916
- + "'/>\n ";
917
- return buffer;
918
- }
919
-
920
- function program15(depth0,data) {
921
-
922
- var buffer = "", stack1;
923
- buffer += "\n <input class='parameter required' minlength='1' name='";
924
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
925
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
926
- buffer += escapeExpression(stack1)
927
- + "' placeholder='(required)' type='text' value=''/>\n ";
928
- return buffer;
929
- }
930
-
931
- buffer += "<td class='code required'>";
932
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
933
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
934
- buffer += escapeExpression(stack1)
935
- + "</td>\n<td>\n ";
936
- stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(9, program9, data),fn:self.program(1, program1, data),data:data});
937
- if(stack1 || stack1 === 0) { buffer += stack1; }
938
- buffer += "\n</td>\n<td>\n <strong>";
939
- if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
940
- else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
941
- if(stack1 || stack1 === 0) { buffer += stack1; }
942
- buffer += "</strong>\n</td>\n<td>";
943
- if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
944
- else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
945
- if(stack1 || stack1 === 0) { buffer += stack1; }
946
- buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n";
947
- return buffer;
948
- });
949
- })();
950
-
951
- (function() {
952
- var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
953
- templates['parameter_content_type'] = template(function (Handlebars,depth0,helpers,partials,data) {
954
- this.compilerInfo = [4,'>= 1.0.0'];
955
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
956
- var buffer = "", stack1, functionType="function", self=this;
957
-
958
- function program1(depth0,data) {
959
-
960
- var buffer = "", stack1;
961
- buffer += "\n ";
962
- stack1 = helpers.each.call(depth0, depth0.consumes, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
963
- if(stack1 || stack1 === 0) { buffer += stack1; }
964
- buffer += "\n";
965
- return buffer;
966
- }
967
- function program2(depth0,data) {
968
-
969
- var buffer = "", stack1;
970
- buffer += "\n <option value=\"";
971
- stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
972
- if(stack1 || stack1 === 0) { buffer += stack1; }
973
- buffer += "\">";
974
- stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
975
- if(stack1 || stack1 === 0) { buffer += stack1; }
976
- buffer += "</option>\n ";
977
- return buffer;
978
- }
979
-
980
- function program4(depth0,data) {
981
-
982
-
983
- return "\n <option value=\"application/json\">application/json</option>\n";
984
- }
985
-
986
- buffer += "<label for=\"parameterContentType\"></label>\n<select name=\"parameterContentType\">\n";
987
- stack1 = helpers['if'].call(depth0, depth0.consumes, {hash:{},inverse:self.program(4, program4, data),fn:self.program(1, program1, data),data:data});
988
- if(stack1 || stack1 === 0) { buffer += stack1; }
989
- buffer += "\n</select>\n";
990
- return buffer;
991
- });
992
- })();
993
-
994
- (function() {
995
- var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
996
- templates['resource'] = template(function (Handlebars,depth0,helpers,partials,data) {
997
- this.compilerInfo = [4,'>= 1.0.0'];
998
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
999
- var buffer = "", stack1, options, functionType="function", escapeExpression=this.escapeExpression, self=this, blockHelperMissing=helpers.blockHelperMissing;
1000
-
1001
- function program1(depth0,data) {
1002
-
1003
-
1004
- return " : ";
1005
- }
1006
-
1007
- buffer += "<div class='heading'>\n <h2>\n <a href='#!/";
1008
- if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
1009
- else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
1010
- buffer += escapeExpression(stack1)
1011
- + "' onclick=\"Docs.toggleEndpointListForResource('";
1012
- if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
1013
- else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
1014
- buffer += escapeExpression(stack1)
1015
- + "');\">";
1016
- if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
1017
- else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
1018
- buffer += escapeExpression(stack1)
1019
- + "</a> ";
1020
- options = {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data};
1021
- if (stack1 = helpers.description) { stack1 = stack1.call(depth0, options); }
1022
- else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
1023
- if (!helpers.description) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
1024
- if(stack1 || stack1 === 0) { buffer += stack1; }
1025
- if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
1026
- else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
1027
- if(stack1 || stack1 === 0) { buffer += stack1; }
1028
- buffer += "\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/";
1029
- if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
1030
- else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
1031
- buffer += escapeExpression(stack1)
1032
- + "' id='endpointListTogger_";
1033
- if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
1034
- else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
1035
- buffer += escapeExpression(stack1)
1036
- + "'\n onclick=\"Docs.toggleEndpointListForResource('";
1037
- if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
1038
- else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
1039
- buffer += escapeExpression(stack1)
1040
- + "');\">Show/Hide</a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.collapseOperationsForResource('";
1041
- if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
1042
- else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
1043
- buffer += escapeExpression(stack1)
1044
- + "'); return false;\">\n List Operations\n </a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.expandOperationsForResource('";
1045
- if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
1046
- else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
1047
- buffer += escapeExpression(stack1)
1048
- + "'); return false;\">\n Expand Operations\n </a>\n </li>\n <li>\n <a href='";
1049
- if (stack1 = helpers.url) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
1050
- else { stack1 = depth0.url; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
1051
- buffer += escapeExpression(stack1)
1052
- + "'>Raw</a>\n </li>\n </ul>\n</div>\n<ul class='endpoints' id='";
1053
- if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
1054
- else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
1055
- buffer += escapeExpression(stack1)
1056
- + "_endpoint_list' style='display:none'>\n\n</ul>\n";
1057
- return buffer;
1058
- });
1059
- })();
1060
-
1061
- (function() {
1062
- var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
1063
- templates['response_content_type'] = template(function (Handlebars,depth0,helpers,partials,data) {
1064
- this.compilerInfo = [4,'>= 1.0.0'];
1065
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
1066
- var buffer = "", stack1, functionType="function", self=this;
1067
-
1068
- function program1(depth0,data) {
1069
-
1070
- var buffer = "", stack1;
1071
- buffer += "\n ";
1072
- stack1 = helpers.each.call(depth0, depth0.produces, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
1073
- if(stack1 || stack1 === 0) { buffer += stack1; }
1074
- buffer += "\n";
1075
- return buffer;
1076
- }
1077
- function program2(depth0,data) {
1078
-
1079
- var buffer = "", stack1;
1080
- buffer += "\n <option value=\"";
1081
- stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
1082
- if(stack1 || stack1 === 0) { buffer += stack1; }
1083
- buffer += "\">";
1084
- stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
1085
- if(stack1 || stack1 === 0) { buffer += stack1; }
1086
- buffer += "</option>\n ";
1087
- return buffer;
1088
- }
1089
-
1090
- function program4(depth0,data) {
1091
-
1092
-
1093
- return "\n <option value=\"application/json\">application/json</option>\n";
1094
- }
1095
-
1096
- buffer += "<label for=\"responseContentType\"></label>\n<select name=\"responseContentType\">\n";
1097
- stack1 = helpers['if'].call(depth0, depth0.produces, {hash:{},inverse:self.program(4, program4, data),fn:self.program(1, program1, data),data:data});
1098
- if(stack1 || stack1 === 0) { buffer += stack1; }
1099
- buffer += "\n</select>\n";
1100
- return buffer;
1101
- });
1102
- })();
1103
-
1104
- (function() {
1105
- var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
1106
- templates['signature'] = template(function (Handlebars,depth0,helpers,partials,data) {
1107
- this.compilerInfo = [4,'>= 1.0.0'];
1108
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
1109
- var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;
1110
-
1111
-
1112
- buffer += "<div>\n<ul class=\"signature-nav\">\n <li><a class=\"description-link\" href=\"#\">Model</a></li>\n <li><a class=\"snippet-link\" href=\"#\">Model Schema</a></li>\n</ul>\n<div>\n\n<div class=\"signature-container\">\n <div class=\"description\">\n ";
1113
- if (stack1 = helpers.signature) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
1114
- else { stack1 = depth0.signature; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
1115
- if(stack1 || stack1 === 0) { buffer += stack1; }
1116
- buffer += "\n </div>\n\n <div class=\"snippet\">\n <pre><code>";
1117
- if (stack1 = helpers.sampleJSON) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
1118
- else { stack1 = depth0.sampleJSON; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
1119
- buffer += escapeExpression(stack1)
1120
- + "</code></pre>\n <small class=\"notice\"></small>\n </div>\n</div>\n\n";
1121
- return buffer;
1122
- });
1123
- })();
1124
-
1125
- (function() {
1126
- var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
1127
- templates['status_code'] = template(function (Handlebars,depth0,helpers,partials,data) {
1128
- this.compilerInfo = [4,'>= 1.0.0'];
1129
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
1130
- var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;
1131
-
1132
-
1133
- buffer += "<td width='15%' class='code'>";
1134
- if (stack1 = helpers.code) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
1135
- else { stack1 = depth0.code; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
1136
- buffer += escapeExpression(stack1)
1137
- + "</td>\n<td>";
1138
- if (stack1 = helpers.message) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
1139
- else { stack1 = depth0.message; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
1140
- if(stack1 || stack1 === 0) { buffer += stack1; }
1141
- buffer += "</td>\n";
1142
- return buffer;
1143
- });
1144
- })();
1145
-
1146
-
1147
-
1148
- // Generated by CoffeeScript 1.6.3
1149
- (function() {
1150
- var ContentTypeView, HeaderView, MainView, OperationView, ParameterContentTypeView, ParameterView, ResourceView, ResponseContentTypeView, SignatureView, StatusCodeView, SwaggerUi, _ref, _ref1, _ref10, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
1151
- __hasProp = {}.hasOwnProperty,
1152
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
1153
-
1154
- SwaggerUi = (function(_super) {
1155
- __extends(SwaggerUi, _super);
1156
-
1157
- function SwaggerUi() {
1158
- _ref = SwaggerUi.__super__.constructor.apply(this, arguments);
1159
- return _ref;
1160
- }
1161
-
1162
- SwaggerUi.prototype.dom_id = "swagger_ui";
1163
-
1164
- SwaggerUi.prototype.options = null;
1165
-
1166
- SwaggerUi.prototype.api = null;
1167
-
1168
- SwaggerUi.prototype.headerView = null;
1169
-
1170
- SwaggerUi.prototype.mainView = null;
1171
-
1172
- SwaggerUi.prototype.initialize = function(options) {
1173
- var _this = this;
1174
- if (options == null) {
1175
- options = {};
1176
- }
1177
- if (options.dom_id != null) {
1178
- this.dom_id = options.dom_id;
1179
- delete options.dom_id;
1180
- }
1181
- if ($('#' + this.dom_id) == null) {
1182
- $('body').append('<div id="' + this.dom_id + '"></div>');
1183
- }
1184
- this.options = options;
1185
- this.options.success = function() {
1186
- return _this.render();
1187
- };
1188
- this.options.progress = function(d) {
1189
- return _this.showMessage(d);
1190
- };
1191
- this.options.failure = function(d) {
1192
- return _this.onLoadFailure(d);
1193
- };
1194
- this.headerView = new HeaderView({
1195
- el: $('#header')
1196
- });
1197
- return this.headerView.on('update-swagger-ui', function(data) {
1198
- return _this.updateSwaggerUi(data);
1199
- });
1200
- };
1201
-
1202
- SwaggerUi.prototype.updateSwaggerUi = function(data) {
1203
- this.options.url = data.url;
1204
- return this.load();
1205
- };
1206
-
1207
- SwaggerUi.prototype.load = function() {
1208
- var url, _ref1;
1209
- if ((_ref1 = this.mainView) != null) {
1210
- _ref1.clear();
1211
- }
1212
- url = this.options.url;
1213
- if (url.indexOf("http") !== 0) {
1214
- url = this.buildUrl(window.location.href.toString(), url);
1215
- }
1216
- this.options.url = url;
1217
- this.headerView.update(url);
1218
- this.api = new SwaggerApi(this.options);
1219
- this.api.build();
1220
- return this.api;
1221
- };
1222
-
1223
- SwaggerUi.prototype.render = function() {
1224
- var _this = this;
1225
- this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...');
1226
- this.mainView = new MainView({
1227
- model: this.api,
1228
- el: $('#' + this.dom_id)
1229
- }).render();
1230
- this.showMessage();
1231
- switch (this.options.docExpansion) {
1232
- case "full":
1233
- Docs.expandOperationsForResource('');
1234
- break;
1235
- case "list":
1236
- Docs.collapseOperationsForResource('');
1237
- }
1238
- if (this.options.onComplete) {
1239
- this.options.onComplete(this.api, this);
1240
- }
1241
- return setTimeout(function() {
1242
- return Docs.shebang();
1243
- }, 400);
1244
- };
1245
-
1246
- SwaggerUi.prototype.buildUrl = function(base, url) {
1247
- var endOfPath, parts;
1248
- log("base is " + base);
1249
- if (url.indexOf("/") === 0) {
1250
- parts = base.split("/");
1251
- base = parts[0] + "//" + parts[2];
1252
- return base + url;
1253
- } else {
1254
- endOfPath = base.length;
1255
- if (base.indexOf("?") > -1) {
1256
- endOfPath = Math.min(endOfPath, base.indexOf("?"));
1257
- }
1258
- if (base.indexOf("#") > -1) {
1259
- endOfPath = Math.min(endOfPath, base.indexOf("#"));
1260
- }
1261
- base = base.substring(0, endOfPath);
1262
- if (base.indexOf("/", base.length - 1) !== -1) {
1263
- return base + url;
1264
- }
1265
- return base + "/" + url;
1266
- }
1267
- };
1268
-
1269
- SwaggerUi.prototype.showMessage = function(data) {
1270
- if (data == null) {
1271
- data = '';
1272
- }
1273
- $('#message-bar').removeClass('message-fail');
1274
- $('#message-bar').addClass('message-success');
1275
- return $('#message-bar').html(data);
1276
- };
1277
-
1278
- SwaggerUi.prototype.onLoadFailure = function(data) {
1279
- var val;
1280
- if (data == null) {
1281
- data = '';
1282
- }
1283
- $('#message-bar').removeClass('message-success');
1284
- $('#message-bar').addClass('message-fail');
1285
- val = $('#message-bar').html(data);
1286
- if (this.options.onFailure != null) {
1287
- this.options.onFailure(data);
1288
- }
1289
- return val;
1290
- };
1291
-
1292
- return SwaggerUi;
1293
-
1294
- })(Backbone.Router);
1295
-
1296
- window.SwaggerUi = SwaggerUi;
1297
-
1298
- HeaderView = (function(_super) {
1299
- __extends(HeaderView, _super);
1300
-
1301
- function HeaderView() {
1302
- _ref1 = HeaderView.__super__.constructor.apply(this, arguments);
1303
- return _ref1;
1304
- }
1305
-
1306
- HeaderView.prototype.events = {
1307
- 'click #show-pet-store-icon': 'showPetStore',
1308
- 'click #show-wordnik-dev-icon': 'showWordnikDev',
1309
- 'click #explore': 'showCustom',
1310
- 'keyup #input_baseUrl': 'showCustomOnKeyup',
1311
- 'keyup #input_apiKey': 'showCustomOnKeyup'
1312
- };
1313
-
1314
- HeaderView.prototype.initialize = function() {};
1315
-
1316
- HeaderView.prototype.showPetStore = function(e) {
1317
- return this.trigger('update-swagger-ui', {
1318
- url: "http://petstore.swagger.wordnik.com/api/api-docs"
1319
- });
1320
- };
1321
-
1322
- HeaderView.prototype.showWordnikDev = function(e) {
1323
- return this.trigger('update-swagger-ui', {
1324
- url: "http://api.wordnik.com/v4/resources.json"
1325
- });
1326
- };
1327
-
1328
- HeaderView.prototype.showCustomOnKeyup = function(e) {
1329
- if (e.keyCode === 13) {
1330
- return this.showCustom();
1331
- }
1332
- };
1333
-
1334
- HeaderView.prototype.showCustom = function(e) {
1335
- if (e != null) {
1336
- e.preventDefault();
1337
- }
1338
- return this.trigger('update-swagger-ui', {
1339
- url: $('#input_baseUrl').val(),
1340
- apiKey: $('#input_apiKey').val()
1341
- });
1342
- };
1343
-
1344
- HeaderView.prototype.update = function(url, apiKey, trigger) {
1345
- if (trigger == null) {
1346
- trigger = false;
1347
- }
1348
- $('#input_baseUrl').val(url);
1349
- if (trigger) {
1350
- return this.trigger('update-swagger-ui', {
1351
- url: url
1352
- });
1353
- }
1354
- };
1355
-
1356
- return HeaderView;
1357
-
1358
- })(Backbone.View);
1359
-
1360
- MainView = (function(_super) {
1361
- __extends(MainView, _super);
1362
-
1363
- function MainView() {
1364
- _ref2 = MainView.__super__.constructor.apply(this, arguments);
1365
- return _ref2;
1366
- }
1367
-
1368
- MainView.prototype.initialize = function() {};
1369
-
1370
- MainView.prototype.render = function() {
1371
- var counter, id, resource, resources, _i, _len, _ref3;
1372
- $(this.el).html(Handlebars.templates.main(this.model));
1373
- resources = {};
1374
- counter = 0;
1375
- _ref3 = this.model.apisArray;
1376
- for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
1377
- resource = _ref3[_i];
1378
- id = resource.name;
1379
- while (typeof resources[id] !== 'undefined') {
1380
- id = id + "_" + counter;
1381
- counter += 1;
1382
- }
1383
- resource.id = id;
1384
- resources[id] = resource;
1385
- this.addResource(resource);
1386
- }
1387
- return this;
1388
- };
1389
-
1390
- MainView.prototype.addResource = function(resource) {
1391
- var resourceView;
1392
- resourceView = new ResourceView({
1393
- model: resource,
1394
- tagName: 'li',
1395
- id: 'resource_' + resource.id,
1396
- className: 'resource'
1397
- });
1398
- return $('#resources').append(resourceView.render().el);
1399
- };
1400
-
1401
- MainView.prototype.clear = function() {
1402
- return $(this.el).html('');
1403
- };
1404
-
1405
- return MainView;
1406
-
1407
- })(Backbone.View);
1408
-
1409
- ResourceView = (function(_super) {
1410
- __extends(ResourceView, _super);
1411
-
1412
- function ResourceView() {
1413
- _ref3 = ResourceView.__super__.constructor.apply(this, arguments);
1414
- return _ref3;
1415
- }
1416
-
1417
- ResourceView.prototype.initialize = function() {};
1418
-
1419
- ResourceView.prototype.render = function() {
1420
- var counter, id, methods, operation, _i, _len, _ref4;
1421
- $(this.el).html(Handlebars.templates.resource(this.model));
1422
- methods = {};
1423
- _ref4 = this.model.operationsArray;
1424
- for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
1425
- operation = _ref4[_i];
1426
- counter = 0;
1427
- id = operation.nickname;
1428
- while (typeof methods[id] !== 'undefined') {
1429
- id = id + "_" + counter;
1430
- counter += 1;
1431
- }
1432
- methods[id] = operation;
1433
- operation.nickname = id;
1434
- operation.parentId = this.model.id;
1435
- this.addOperation(operation);
1436
- }
1437
- return this;
1438
- };
1439
-
1440
- ResourceView.prototype.addOperation = function(operation) {
1441
- var operationView;
1442
- operation.number = this.number;
1443
- operationView = new OperationView({
1444
- model: operation,
1445
- tagName: 'li',
1446
- className: 'endpoint'
1447
- });
1448
- $('.endpoints', $(this.el)).append(operationView.render().el);
1449
- return this.number++;
1450
- };
1451
-
1452
- return ResourceView;
1453
-
1454
- })(Backbone.View);
1455
-
1456
- OperationView = (function(_super) {
1457
- __extends(OperationView, _super);
1458
-
1459
- function OperationView() {
1460
- _ref4 = OperationView.__super__.constructor.apply(this, arguments);
1461
- return _ref4;
1462
- }
1463
-
1464
- OperationView.prototype.invocationUrl = null;
1465
-
1466
- OperationView.prototype.events = {
1467
- 'submit .sandbox': 'submitOperation',
1468
- 'click .submit': 'submitOperation',
1469
- 'click .response_hider': 'hideResponse',
1470
- 'click .toggleOperation': 'toggleOperationContent'
1471
- };
1472
-
1473
- OperationView.prototype.initialize = function() {};
1474
-
1475
- OperationView.prototype.render = function() {
1476
- var contentTypeModel, isMethodSubmissionSupported, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, type, _i, _j, _k, _len, _len1, _len2, _ref5, _ref6, _ref7;
1477
- isMethodSubmissionSupported = true;
1478
- if (!isMethodSubmissionSupported) {
1479
- this.model.isReadOnly = true;
1480
- }
1481
- $(this.el).html(Handlebars.templates.operation(this.model));
1482
- if (this.model.responseClassSignature && this.model.responseClassSignature !== 'string') {
1483
- signatureModel = {
1484
- sampleJSON: this.model.responseSampleJSON,
1485
- isParam: false,
1486
- signature: this.model.responseClassSignature
1487
- };
1488
- responseSignatureView = new SignatureView({
1489
- model: signatureModel,
1490
- tagName: 'div'
1491
- });
1492
- $('.model-signature', $(this.el)).append(responseSignatureView.render().el);
1493
- } else {
1494
- $('.model-signature', $(this.el)).html(this.model.type);
1495
- }
1496
- contentTypeModel = {
1497
- isParam: false
1498
- };
1499
- contentTypeModel.consumes = this.model.consumes;
1500
- contentTypeModel.produces = this.model.produces;
1501
- _ref5 = this.model.parameters;
1502
- for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
1503
- param = _ref5[_i];
1504
- type = param.type || param.dataType;
1505
- if (type.toLowerCase() === 'file') {
1506
- if (!contentTypeModel.consumes) {
1507
- log("set content type ");
1508
- contentTypeModel.consumes = 'multipart/form-data';
1509
- }
1510
- }
1511
- }
1512
- responseContentTypeView = new ResponseContentTypeView({
1513
- model: contentTypeModel
1514
- });
1515
- $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
1516
- _ref6 = this.model.parameters;
1517
- for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
1518
- param = _ref6[_j];
1519
- this.addParameter(param, contentTypeModel.consumes);
1520
- }
1521
- _ref7 = this.model.responseMessages;
1522
- for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
1523
- statusCode = _ref7[_k];
1524
- this.addStatusCode(statusCode);
1525
- }
1526
- return this;
1527
- };
1528
-
1529
- OperationView.prototype.addParameter = function(param, consumes) {
1530
- var paramView;
1531
- param.consumes = consumes;
1532
- paramView = new ParameterView({
1533
- model: param,
1534
- tagName: 'tr',
1535
- readOnly: this.model.isReadOnly
1536
- });
1537
- return $('.operation-params', $(this.el)).append(paramView.render().el);
1538
- };
1539
-
1540
- OperationView.prototype.addStatusCode = function(statusCode) {
1541
- var statusCodeView;
1542
- statusCodeView = new StatusCodeView({
1543
- model: statusCode,
1544
- tagName: 'tr'
1545
- });
1546
- return $('.operation-status', $(this.el)).append(statusCodeView.render().el);
1547
- };
1548
-
1549
- OperationView.prototype.submitOperation = function(e) {
1550
- var error_free, form, isFileUpload, map, o, opts, val, _i, _j, _k, _len, _len1, _len2, _ref5, _ref6, _ref7;
1551
- if (e != null) {
1552
- e.preventDefault();
1553
- }
1554
- form = $('.sandbox', $(this.el));
1555
- error_free = true;
1556
- form.find("input.required").each(function() {
1557
- var _this = this;
1558
- $(this).removeClass("error");
1559
- if (jQuery.trim($(this).val()) === "") {
1560
- $(this).addClass("error");
1561
- $(this).wiggle({
1562
- callback: function() {
1563
- return $(_this).focus();
1564
- }
1565
- });
1566
- return error_free = false;
1567
- }
1568
- });
1569
- if (error_free) {
1570
- map = {};
1571
- opts = {
1572
- parent: this
1573
- };
1574
- isFileUpload = false;
1575
- _ref5 = form.find("input");
1576
- for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
1577
- o = _ref5[_i];
1578
- if ((o.value != null) && jQuery.trim(o.value).length > 0) {
1579
- map[o.name] = o.value;
1580
- }
1581
- if (o.type === "file") {
1582
- isFileUpload = true;
1583
- }
1584
- }
1585
- _ref6 = form.find("textarea");
1586
- for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
1587
- o = _ref6[_j];
1588
- if ((o.value != null) && jQuery.trim(o.value).length > 0) {
1589
- map["body"] = o.value;
1590
- }
1591
- }
1592
- _ref7 = form.find("select");
1593
- for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
1594
- o = _ref7[_k];
1595
- val = this.getSelectedValue(o);
1596
- if ((val != null) && jQuery.trim(val).length > 0) {
1597
- map[o.name] = val;
1598
- }
1599
- }
1600
- opts.responseContentType = $("div select[name=responseContentType]", $(this.el)).val();
1601
- opts.requestContentType = $("div select[name=parameterContentType]", $(this.el)).val();
1602
- $(".response_throbber", $(this.el)).show();
1603
- if (isFileUpload) {
1604
- return this.handleFileUpload(map, form);
1605
- } else {
1606
- return this.model["do"](map, opts, this.showCompleteStatus, this.showErrorStatus, this);
1607
- }
1608
- }
1609
- };
1610
-
1611
- OperationView.prototype.success = function(response, parent) {
1612
- return parent.showCompleteStatus(response);
1613
- };
1614
-
1615
- OperationView.prototype.handleFileUpload = function(map, form) {
1616
- var bodyParam, el, headerParams, o, obj, param, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref5, _ref6, _ref7, _ref8,
1617
- _this = this;
1618
- log("it's a file upload");
1619
- _ref5 = form.serializeArray();
1620
- for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
1621
- o = _ref5[_i];
1622
- if ((o.value != null) && jQuery.trim(o.value).length > 0) {
1623
- map[o.name] = o.value;
1624
- }
1625
- }
1626
- bodyParam = new FormData();
1627
- _ref6 = this.model.parameters;
1628
- for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
1629
- param = _ref6[_j];
1630
- if (param.paramType === 'form') {
1631
- bodyParam.append(param.name, map[param.name]);
1632
- }
1633
- }
1634
- headerParams = {};
1635
- _ref7 = this.model.parameters;
1636
- for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
1637
- param = _ref7[_k];
1638
- if (param.paramType === 'header') {
1639
- headerParams[param.name] = map[param.name];
1640
- }
1641
- }
1642
- log(headerParams);
1643
- _ref8 = form.find('input[type~="file"]');
1644
- for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) {
1645
- el = _ref8[_l];
1646
- bodyParam.append($(el).attr('name'), el.files[0]);
1647
- }
1648
- log(bodyParam);
1649
- this.invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), this.model.urlify(map, false)) : this.model.urlify(map, true);
1650
- $(".request_url", $(this.el)).html("<pre>" + this.invocationUrl + "</pre>");
1651
- obj = {
1652
- type: this.model.method,
1653
- url: this.invocationUrl,
1654
- headers: headerParams,
1655
- data: bodyParam,
1656
- dataType: 'json',
1657
- contentType: false,
1658
- processData: false,
1659
- error: function(data, textStatus, error) {
1660
- return _this.showErrorStatus(_this.wrap(data), _this);
1661
- },
1662
- success: function(data) {
1663
- return _this.showResponse(data, _this);
1664
- },
1665
- complete: function(data) {
1666
- return _this.showCompleteStatus(_this.wrap(data), _this);
1667
- }
1668
- };
1669
- if (window.authorizations) {
1670
- window.authorizations.apply(obj);
1671
- }
1672
- jQuery.ajax(obj);
1673
- return false;
1674
- };
1675
-
1676
- OperationView.prototype.wrap = function(data) {
1677
- var headerArray, headers, i, o, _i, _ref5, _ref6;
1678
- headers = {};
1679
- headerArray = data.getAllResponseHeaders().split(":");
1680
- for (i = _i = 0, _ref5 = headerArray.length / 2, _ref6 = 2.; _ref6 > 0 ? _i <= _ref5 : _i >= _ref5; i = _i += _ref6) {
1681
- headers[headerArray[i]] = headerArray[i + 1];
1682
- }
1683
- o = {};
1684
- o.content = {};
1685
- o.content.data = data.responseText;
1686
- o.headers = headers;
1687
- o.request = {};
1688
- o.request.url = this.invocationUrl;
1689
- o.status = data.status;
1690
- return o;
1691
- };
1692
-
1693
- OperationView.prototype.getSelectedValue = function(select) {
1694
- var opt, options, _i, _len, _ref5;
1695
- if (!select.multiple) {
1696
- return select.value;
1697
- } else {
1698
- options = [];
1699
- _ref5 = select.options;
1700
- for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
1701
- opt = _ref5[_i];
1702
- if (opt.selected) {
1703
- options.push(opt.value);
1704
- }
1705
- }
1706
- if (options.length > 0) {
1707
- return options.join(",");
1708
- } else {
1709
- return null;
1710
- }
1711
- }
1712
- };
1713
-
1714
- OperationView.prototype.hideResponse = function(e) {
1715
- if (e != null) {
1716
- e.preventDefault();
1717
- }
1718
- $(".response", $(this.el)).slideUp();
1719
- return $(".response_hider", $(this.el)).fadeOut();
1720
- };
1721
-
1722
- OperationView.prototype.showResponse = function(response) {
1723
- var prettyJson;
1724
- prettyJson = JSON.stringify(response, null, "\t").replace(/\n/g, "<br>");
1725
- return $(".response_body", $(this.el)).html(escape(prettyJson));
1726
- };
1727
-
1728
- OperationView.prototype.showErrorStatus = function(data, parent) {
1729
- return parent.showStatus(data);
1730
- };
1731
-
1732
- OperationView.prototype.showCompleteStatus = function(data, parent) {
1733
- return parent.showStatus(data);
1734
- };
1735
-
1736
- OperationView.prototype.formatXml = function(xml) {
1737
- var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;
1738
- reg = /(>)(<)(\/*)/g;
1739
- wsexp = /[ ]*(.*)[ ]+\n/g;
1740
- contexp = /(<.+>)(.+\n)/g;
1741
- xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
1742
- pad = 0;
1743
- formatted = '';
1744
- lines = xml.split('\n');
1745
- indent = 0;
1746
- lastType = 'other';
1747
- transitions = {
1748
- 'single->single': 0,
1749
- 'single->closing': -1,
1750
- 'single->opening': 0,
1751
- 'single->other': 0,
1752
- 'closing->single': 0,
1753
- 'closing->closing': -1,
1754
- 'closing->opening': 0,
1755
- 'closing->other': 0,
1756
- 'opening->single': 1,
1757
- 'opening->closing': 0,
1758
- 'opening->opening': 1,
1759
- 'opening->other': 1,
1760
- 'other->single': 0,
1761
- 'other->closing': -1,
1762
- 'other->opening': 0,
1763
- 'other->other': 0
1764
- };
1765
- _fn = function(ln) {
1766
- var fromTo, j, key, padding, type, types, value;
1767
- types = {
1768
- single: Boolean(ln.match(/<.+\/>/)),
1769
- closing: Boolean(ln.match(/<\/.+>/)),
1770
- opening: Boolean(ln.match(/<[^!?].*>/))
1771
- };
1772
- type = ((function() {
1773
- var _results;
1774
- _results = [];
1775
- for (key in types) {
1776
- value = types[key];
1777
- if (value) {
1778
- _results.push(key);
1779
- }
1780
- }
1781
- return _results;
1782
- })())[0];
1783
- type = type === void 0 ? 'other' : type;
1784
- fromTo = lastType + '->' + type;
1785
- lastType = type;
1786
- padding = '';
1787
- indent += transitions[fromTo];
1788
- padding = ((function() {
1789
- var _j, _ref5, _results;
1790
- _results = [];
1791
- for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) {
1792
- _results.push(' ');
1793
- }
1794
- return _results;
1795
- })()).join('');
1796
- if (fromTo === 'opening->closing') {
1797
- return formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
1798
- } else {
1799
- return formatted += padding + ln + '\n';
1800
- }
1801
- };
1802
- for (_i = 0, _len = lines.length; _i < _len; _i++) {
1803
- ln = lines[_i];
1804
- _fn(ln);
1805
- }
1806
- return formatted;
1807
- };
1808
-
1809
- OperationView.prototype.showStatus = function(response) {
1810
- var code, content, contentType, headers, pre, response_body, url;
1811
- if (response.content === void 0) {
1812
- content = response.data;
1813
- url = response.url;
1814
- } else {
1815
- content = response.content.data;
1816
- url = response.request.url;
1817
- }
1818
- headers = response.headers;
1819
- contentType = headers && headers["Content-Type"] ? headers["Content-Type"].split(";")[0].trim() : null;
1820
- if (!content) {
1821
- code = $('<code />').text("no content");
1822
- pre = $('<pre class="json" />').append(code);
1823
- } else if (contentType === "application/json" || /\+json$/.test(contentType)) {
1824
- code = $('<code />').text(JSON.stringify(JSON.parse(content), null, " "));
1825
- pre = $('<pre class="json" />').append(code);
1826
- } else if (contentType === "application/xml" || /\+xml$/.test(contentType)) {
1827
- code = $('<code />').text(this.formatXml(content));
1828
- pre = $('<pre class="xml" />').append(code);
1829
- } else if (contentType === "text/html") {
1830
- code = $('<code />').html(content);
1831
- pre = $('<pre class="xml" />').append(code);
1832
- } else if (/^image\//.test(contentType)) {
1833
- pre = $('<img>').attr('src', url);
1834
- } else {
1835
- code = $('<code />').text(content);
1836
- pre = $('<pre class="json" />').append(code);
1837
- }
1838
- response_body = pre;
1839
- $(".request_url", $(this.el)).html("<pre>" + url + "</pre>");
1840
- $(".response_code", $(this.el)).html("<pre>" + response.status + "</pre>");
1841
- $(".response_body", $(this.el)).html(response_body);
1842
- $(".response_headers", $(this.el)).html("<pre>" + JSON.stringify(response.headers, null, " ").replace(/\n/g, "<br>") + "</pre>");
1843
- $(".response", $(this.el)).slideDown();
1844
- $(".response_hider", $(this.el)).show();
1845
- $(".response_throbber", $(this.el)).hide();
1846
- return hljs.highlightBlock($('.response_body', $(this.el))[0]);
1847
- };
1848
-
1849
- OperationView.prototype.toggleOperationContent = function() {
1850
- var elem;
1851
- elem = $('#' + Docs.escapeResourceName(this.model.parentId) + "_" + this.model.nickname + "_content");
1852
- if (elem.is(':visible')) {
1853
- return Docs.collapseOperation(elem);
1854
- } else {
1855
- return Docs.expandOperation(elem);
1856
- }
1857
- };
1858
-
1859
- return OperationView;
1860
-
1861
- })(Backbone.View);
1862
-
1863
- StatusCodeView = (function(_super) {
1864
- __extends(StatusCodeView, _super);
1865
-
1866
- function StatusCodeView() {
1867
- _ref5 = StatusCodeView.__super__.constructor.apply(this, arguments);
1868
- return _ref5;
1869
- }
1870
-
1871
- StatusCodeView.prototype.initialize = function() {};
1872
-
1873
- StatusCodeView.prototype.render = function() {
1874
- var template;
1875
- template = this.template();
1876
- $(this.el).html(template(this.model));
1877
- return this;
1878
- };
1879
-
1880
- StatusCodeView.prototype.template = function() {
1881
- return Handlebars.templates.status_code;
1882
- };
1883
-
1884
- return StatusCodeView;
1885
-
1886
- })(Backbone.View);
1887
-
1888
- ParameterView = (function(_super) {
1889
- __extends(ParameterView, _super);
1890
-
1891
- function ParameterView() {
1892
- _ref6 = ParameterView.__super__.constructor.apply(this, arguments);
1893
- return _ref6;
1894
- }
1895
-
1896
- ParameterView.prototype.initialize = function() {};
1897
-
1898
- ParameterView.prototype.render = function() {
1899
- var contentTypeModel, isParam, parameterContentTypeView, responseContentTypeView, signatureModel, signatureView, template, type;
1900
- type = this.model.type || this.model.dataType;
1901
- if (this.model.paramType === 'body') {
1902
- this.model.isBody = true;
1903
- }
1904
- if (type.toLowerCase() === 'file') {
1905
- this.model.isFile = true;
1906
- }
1907
- template = this.template();
1908
- $(this.el).html(template(this.model));
1909
- signatureModel = {
1910
- sampleJSON: this.model.sampleJSON,
1911
- isParam: true,
1912
- signature: this.model.signature
1913
- };
1914
- if (this.model.sampleJSON) {
1915
- signatureView = new SignatureView({
1916
- model: signatureModel,
1917
- tagName: 'div'
1918
- });
1919
- $('.model-signature', $(this.el)).append(signatureView.render().el);
1920
- } else {
1921
- $('.model-signature', $(this.el)).html(this.model.signature);
1922
- }
1923
- isParam = false;
1924
- if (this.model.isBody) {
1925
- isParam = true;
1926
- }
1927
- contentTypeModel = {
1928
- isParam: isParam
1929
- };
1930
- contentTypeModel.consumes = this.model.consumes;
1931
- if (isParam) {
1932
- parameterContentTypeView = new ParameterContentTypeView({
1933
- model: contentTypeModel
1934
- });
1935
- $('.parameter-content-type', $(this.el)).append(parameterContentTypeView.render().el);
1936
- } else {
1937
- responseContentTypeView = new ResponseContentTypeView({
1938
- model: contentTypeModel
1939
- });
1940
- $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
1941
- }
1942
- return this;
1943
- };
1944
-
1945
- ParameterView.prototype.template = function() {
1946
- if (this.model.isList) {
1947
- return Handlebars.templates.param_list;
1948
- } else {
1949
- if (this.options.readOnly) {
1950
- if (this.model.required) {
1951
- return Handlebars.templates.param_readonly_required;
1952
- } else {
1953
- return Handlebars.templates.param_readonly;
1954
- }
1955
- } else {
1956
- if (this.model.required) {
1957
- return Handlebars.templates.param_required;
1958
- } else {
1959
- return Handlebars.templates.param;
1960
- }
1961
- }
1962
- }
1963
- };
1964
-
1965
- return ParameterView;
1966
-
1967
- })(Backbone.View);
1968
-
1969
- SignatureView = (function(_super) {
1970
- __extends(SignatureView, _super);
1971
-
1972
- function SignatureView() {
1973
- _ref7 = SignatureView.__super__.constructor.apply(this, arguments);
1974
- return _ref7;
1975
- }
1976
-
1977
- SignatureView.prototype.events = {
1978
- 'click a.description-link': 'switchToDescription',
1979
- 'click a.snippet-link': 'switchToSnippet',
1980
- 'mousedown .snippet': 'snippetToTextArea'
1981
- };
1982
-
1983
- SignatureView.prototype.initialize = function() {};
1984
-
1985
- SignatureView.prototype.render = function() {
1986
- var template;
1987
- template = this.template();
1988
- $(this.el).html(template(this.model));
1989
- this.switchToDescription();
1990
- this.isParam = this.model.isParam;
1991
- if (this.isParam) {
1992
- $('.notice', $(this.el)).text('Click to set as parameter value');
1993
- }
1994
- return this;
1995
- };
1996
-
1997
- SignatureView.prototype.template = function() {
1998
- return Handlebars.templates.signature;
1999
- };
2000
-
2001
- SignatureView.prototype.switchToDescription = function(e) {
2002
- if (e != null) {
2003
- e.preventDefault();
2004
- }
2005
- $(".snippet", $(this.el)).hide();
2006
- $(".description", $(this.el)).show();
2007
- $('.description-link', $(this.el)).addClass('selected');
2008
- return $('.snippet-link', $(this.el)).removeClass('selected');
2009
- };
2010
-
2011
- SignatureView.prototype.switchToSnippet = function(e) {
2012
- if (e != null) {
2013
- e.preventDefault();
2014
- }
2015
- $(".description", $(this.el)).hide();
2016
- $(".snippet", $(this.el)).show();
2017
- $('.snippet-link', $(this.el)).addClass('selected');
2018
- return $('.description-link', $(this.el)).removeClass('selected');
2019
- };
2020
-
2021
- SignatureView.prototype.snippetToTextArea = function(e) {
2022
- var textArea;
2023
- if (this.isParam) {
2024
- if (e != null) {
2025
- e.preventDefault();
2026
- }
2027
- textArea = $('textarea', $(this.el.parentNode.parentNode.parentNode));
2028
- if ($.trim(textArea.val()) === '') {
2029
- return textArea.val(this.model.sampleJSON);
2030
- }
2031
- }
2032
- };
2033
-
2034
- return SignatureView;
2035
-
2036
- })(Backbone.View);
2037
-
2038
- ContentTypeView = (function(_super) {
2039
- __extends(ContentTypeView, _super);
2040
-
2041
- function ContentTypeView() {
2042
- _ref8 = ContentTypeView.__super__.constructor.apply(this, arguments);
2043
- return _ref8;
2044
- }
2045
-
2046
- ContentTypeView.prototype.initialize = function() {};
2047
-
2048
- ContentTypeView.prototype.render = function() {
2049
- var template;
2050
- template = this.template();
2051
- $(this.el).html(template(this.model));
2052
- $('label[for=contentType]', $(this.el)).text('Response Content Type');
2053
- return this;
2054
- };
2055
-
2056
- ContentTypeView.prototype.template = function() {
2057
- return Handlebars.templates.content_type;
2058
- };
2059
-
2060
- return ContentTypeView;
2061
-
2062
- })(Backbone.View);
2063
-
2064
- ResponseContentTypeView = (function(_super) {
2065
- __extends(ResponseContentTypeView, _super);
2066
-
2067
- function ResponseContentTypeView() {
2068
- _ref9 = ResponseContentTypeView.__super__.constructor.apply(this, arguments);
2069
- return _ref9;
2070
- }
2071
-
2072
- ResponseContentTypeView.prototype.initialize = function() {};
2073
-
2074
- ResponseContentTypeView.prototype.render = function() {
2075
- var template;
2076
- template = this.template();
2077
- $(this.el).html(template(this.model));
2078
- $('label[for=responseContentType]', $(this.el)).text('Response Content Type');
2079
- return this;
2080
- };
2081
-
2082
- ResponseContentTypeView.prototype.template = function() {
2083
- return Handlebars.templates.response_content_type;
2084
- };
2085
-
2086
- return ResponseContentTypeView;
2087
-
2088
- })(Backbone.View);
2089
-
2090
- ParameterContentTypeView = (function(_super) {
2091
- __extends(ParameterContentTypeView, _super);
2092
-
2093
- function ParameterContentTypeView() {
2094
- _ref10 = ParameterContentTypeView.__super__.constructor.apply(this, arguments);
2095
- return _ref10;
2096
- }
2097
-
2098
- ParameterContentTypeView.prototype.initialize = function() {};
2099
-
2100
- ParameterContentTypeView.prototype.render = function() {
2101
- var template;
2102
- template = this.template();
2103
- $(this.el).html(template(this.model));
2104
- $('label[for=parameterContentType]', $(this.el)).text('Parameter content type:');
2105
- return this;
2106
- };
2107
-
2108
- ParameterContentTypeView.prototype.template = function() {
2109
- return Handlebars.templates.parameter_content_type;
2110
- };
2111
-
2112
- return ParameterContentTypeView;
2113
-
2114
- })(Backbone.View);
2115
-
2116
- }).call(this);