grape_swagger_ui 0.0.1

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