rack-swagger 0.0.1 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +13 -5
  2. data/.gitignore +1 -1
  3. data/README.md +85 -1
  4. data/Rakefile +30 -0
  5. data/lib/rack/swagger.rb +35 -1
  6. data/lib/rack/swagger/asset_server.rb +22 -0
  7. data/lib/rack/swagger/index_page_server.rb +32 -0
  8. data/lib/rack/swagger/json_server.rb +30 -0
  9. data/lib/rack/swagger/rentpath/logo_small.png +0 -0
  10. data/lib/rack/swagger/rentpath/rentpath.diff +47 -0
  11. data/lib/rack/swagger/routes_to_models.rb +111 -0
  12. data/lib/rack/swagger/server_helpers.rb +55 -0
  13. data/lib/rack/swagger/sinatra_helpers.rb +78 -0
  14. data/lib/rack/swagger/version.rb +1 -1
  15. data/rack-swagger.gemspec +8 -2
  16. data/spec/lib/rack/swagger/asset_server_spec.rb +18 -0
  17. data/spec/lib/rack/swagger/index_page_server_spec.rb +21 -0
  18. data/spec/lib/rack/swagger/routes_to_models_spec.rb +81 -0
  19. data/spec/lib/rack/swagger/server_helpers_spec.rb +44 -0
  20. data/spec/lib/rack/swagger/sinatra_helpers_spec.rb +85 -0
  21. data/spec/spec_helper.rb +25 -0
  22. data/swagger-ui/dist/css/reset.css +125 -0
  23. data/swagger-ui/dist/css/screen.css +1224 -0
  24. data/swagger-ui/dist/css/screen.css.orig +1224 -0
  25. data/swagger-ui/dist/images/explorer_icons.png +0 -0
  26. data/swagger-ui/dist/images/logo_small.png +0 -0
  27. data/swagger-ui/dist/images/pet_store_api.png +0 -0
  28. data/swagger-ui/dist/images/throbber.gif +0 -0
  29. data/swagger-ui/dist/images/wordnik_api.png +0 -0
  30. data/swagger-ui/dist/index.html +105 -0
  31. data/swagger-ui/dist/index.html.orig +105 -0
  32. data/swagger-ui/dist/lib/backbone-min.js +38 -0
  33. data/swagger-ui/dist/lib/handlebars-1.0.0.js +2278 -0
  34. data/swagger-ui/dist/lib/highlight.7.3.pack.js +1 -0
  35. data/swagger-ui/dist/lib/jquery-1.8.0.min.js +2 -0
  36. data/swagger-ui/dist/lib/jquery.ba-bbq.min.js +18 -0
  37. data/swagger-ui/dist/lib/jquery.slideto.min.js +1 -0
  38. data/swagger-ui/dist/lib/jquery.wiggle.min.js +8 -0
  39. data/swagger-ui/dist/lib/shred.bundle.js +2765 -0
  40. data/swagger-ui/dist/lib/shred/content.js +193 -0
  41. data/swagger-ui/dist/lib/swagger-client.js +1477 -0
  42. data/swagger-ui/dist/lib/swagger-oauth.js +211 -0
  43. data/swagger-ui/dist/lib/swagger.js +1678 -0
  44. data/swagger-ui/dist/lib/underscore-min.js +32 -0
  45. data/swagger-ui/dist/o2c.html +15 -0
  46. data/swagger-ui/dist/swagger-ui.js +2477 -0
  47. data/swagger-ui/dist/swagger-ui.min.js +1 -0
  48. data/swagger-ui/master.tar.gz +0 -0
  49. data/swagger-ui/swagger-ui-v2.0.22.tar +0 -0
  50. data/swagger_ui_version.yml +4 -0
  51. data/templates/swagger_ui_version.yml +4 -0
  52. metadata +132 -12
@@ -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,1678 @@
1
+ // swagger.js
2
+ // version 2.0.41
3
+
4
+ (function () {
5
+
6
+ var __bind = function (fn, me) {
7
+ return function () {
8
+ return fn.apply(me, arguments);
9
+ };
10
+ };
11
+
12
+ var log = function () {
13
+ log.history = log.history || [];
14
+ log.history.push(arguments);
15
+ if (this.console) {
16
+ console.log(Array.prototype.slice.call(arguments)[0]);
17
+ }
18
+ };
19
+
20
+ // if you want to apply conditional formatting of parameter values
21
+ var parameterMacro = function (value) {
22
+ return value;
23
+ }
24
+
25
+ // if you want to apply conditional formatting of model property values
26
+ var modelPropertyMacro = function (value) {
27
+ return value;
28
+ }
29
+
30
+ if (!Array.prototype.indexOf) {
31
+ Array.prototype.indexOf = function (obj, start) {
32
+ for (var i = (start || 0), j = this.length; i < j; i++) {
33
+ if (this[i] === obj) { return i; }
34
+ }
35
+ return -1;
36
+ }
37
+ }
38
+
39
+ if (!('filter' in Array.prototype)) {
40
+ Array.prototype.filter = function (filter, that /*opt*/) {
41
+ var other = [], v;
42
+ for (var i = 0, n = this.length; i < n; i++)
43
+ if (i in this && filter.call(that, v = this[i], i, this))
44
+ other.push(v);
45
+ return other;
46
+ };
47
+ }
48
+
49
+ if (!('map' in Array.prototype)) {
50
+ Array.prototype.map = function (mapper, that /*opt*/) {
51
+ var other = new Array(this.length);
52
+ for (var i = 0, n = this.length; i < n; i++)
53
+ if (i in this)
54
+ other[i] = mapper.call(that, this[i], i, this);
55
+ return other;
56
+ };
57
+ }
58
+
59
+ Object.keys = Object.keys || (function () {
60
+ var hasOwnProperty = Object.prototype.hasOwnProperty,
61
+ hasDontEnumBug = !{ toString: null }.propertyIsEnumerable("toString"),
62
+ DontEnums = [
63
+ 'toString',
64
+ 'toLocaleString',
65
+ 'valueOf',
66
+ 'hasOwnProperty',
67
+ 'isPrototypeOf',
68
+ 'propertyIsEnumerable',
69
+ 'constructor'
70
+ ],
71
+ DontEnumsLength = DontEnums.length;
72
+
73
+ return function (o) {
74
+ if (typeof o != "object" && typeof o != "function" || o === null)
75
+ throw new TypeError("Object.keys called on a non-object");
76
+
77
+ var result = [];
78
+ for (var name in o) {
79
+ if (hasOwnProperty.call(o, name))
80
+ result.push(name);
81
+ }
82
+
83
+ if (hasDontEnumBug) {
84
+ for (var i = 0; i < DontEnumsLength; i++) {
85
+ if (hasOwnProperty.call(o, DontEnums[i]))
86
+ result.push(DontEnums[i]);
87
+ }
88
+ }
89
+
90
+ return result;
91
+ };
92
+ })();
93
+
94
+ var SwaggerApi = function (url, options) {
95
+ this.isBuilt = false;
96
+ this.url = null;
97
+ this.debug = false;
98
+ this.basePath = null;
99
+ this.authorizations = null;
100
+ this.authorizationScheme = null;
101
+ this.info = null;
102
+ this.useJQuery = false;
103
+ this.modelsArray = [];
104
+ this.isValid;
105
+
106
+ options = (options || {});
107
+ if (url)
108
+ if (url.url)
109
+ options = url;
110
+ else
111
+ this.url = url;
112
+ else
113
+ options = url;
114
+
115
+ if (options.url != null)
116
+ this.url = options.url;
117
+
118
+ if (options.success != null)
119
+ this.success = options.success;
120
+
121
+ if (typeof options.useJQuery === 'boolean')
122
+ this.useJQuery = options.useJQuery;
123
+
124
+ this.failure = options.failure != null ? options.failure : function () { };
125
+ this.progress = options.progress != null ? options.progress : function () { };
126
+ if (options.success != null) {
127
+ this.build();
128
+ this.isBuilt = true;
129
+ }
130
+ }
131
+
132
+ SwaggerApi.prototype.build = function () {
133
+ if (this.isBuilt)
134
+ return this;
135
+ var _this = this;
136
+ this.progress('fetching resource list: ' + this.url);
137
+ var obj = {
138
+ useJQuery: this.useJQuery,
139
+ url: this.url,
140
+ method: "get",
141
+ headers: {
142
+ accept: "application/json,application/json;charset=\"utf-8\",*/*"
143
+ },
144
+ on: {
145
+ error: function (response) {
146
+ if (_this.url.substring(0, 4) !== 'http') {
147
+ return _this.fail('Please specify the protocol for ' + _this.url);
148
+ } else if (response.status === 0) {
149
+ return _this.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.');
150
+ } else if (response.status === 404) {
151
+ return _this.fail('Can\'t read swagger JSON from ' + _this.url);
152
+ } else {
153
+ return _this.fail(response.status + ' : ' + response.statusText + ' ' + _this.url);
154
+ }
155
+ },
156
+ response: function (resp) {
157
+ var responseObj = resp.obj || JSON.parse(resp.data);
158
+ _this.swaggerVersion = responseObj.swaggerVersion;
159
+ if (_this.swaggerVersion === "1.2") {
160
+ return _this.buildFromSpec(responseObj);
161
+ } else {
162
+ return _this.buildFrom1_1Spec(responseObj);
163
+ }
164
+ }
165
+ }
166
+ };
167
+ var e = (typeof window !== 'undefined' ? window : exports);
168
+ e.authorizations.apply(obj);
169
+ new SwaggerHttp().execute(obj);
170
+ return this;
171
+ };
172
+
173
+ SwaggerApi.prototype.buildFromSpec = function (response) {
174
+ if (response.apiVersion != null) {
175
+ this.apiVersion = response.apiVersion;
176
+ }
177
+ this.apis = {};
178
+ this.apisArray = [];
179
+ this.consumes = response.consumes;
180
+ this.produces = response.produces;
181
+ this.authSchemes = response.authorizations;
182
+ if (response.info != null) {
183
+ this.info = response.info;
184
+ }
185
+ var isApi = false;
186
+ var i;
187
+ for (i = 0; i < response.apis.length; i++) {
188
+ var api = response.apis[i];
189
+ if (api.operations) {
190
+ var j;
191
+ for (j = 0; j < api.operations.length; j++) {
192
+ operation = api.operations[j];
193
+ isApi = true;
194
+ }
195
+ }
196
+ }
197
+ if (response.basePath)
198
+ this.basePath = response.basePath;
199
+ else if (this.url.indexOf('?') > 0)
200
+ this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
201
+ else
202
+ this.basePath = this.url;
203
+
204
+ if (isApi) {
205
+ var newName = response.resourcePath.replace(/\//g, '');
206
+ this.resourcePath = response.resourcePath;
207
+ var res = new SwaggerResource(response, this);
208
+ this.apis[newName] = res;
209
+ this.apisArray.push(res);
210
+ } else {
211
+ var k;
212
+ for (k = 0; k < response.apis.length; k++) {
213
+ var resource = response.apis[k];
214
+ var res = new SwaggerResource(resource, this);
215
+ this.apis[res.name] = res;
216
+ this.apisArray.push(res);
217
+ }
218
+ }
219
+ this.isValid = true;
220
+ if (this.success) {
221
+ this.success();
222
+ }
223
+ return this;
224
+ };
225
+
226
+ SwaggerApi.prototype.buildFrom1_1Spec = function (response) {
227
+ log("This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info");
228
+ if (response.apiVersion != null)
229
+ this.apiVersion = response.apiVersion;
230
+ this.apis = {};
231
+ this.apisArray = [];
232
+ this.produces = response.produces;
233
+ if (response.info != null) {
234
+ this.info = response.info;
235
+ }
236
+ var isApi = false;
237
+ for (var i = 0; i < response.apis.length; i++) {
238
+ var api = response.apis[i];
239
+ if (api.operations) {
240
+ for (var j = 0; j < api.operations.length; j++) {
241
+ operation = api.operations[j];
242
+ isApi = true;
243
+ }
244
+ }
245
+ }
246
+ if (response.basePath) {
247
+ this.basePath = response.basePath;
248
+ } else if (this.url.indexOf('?') > 0) {
249
+ this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
250
+ } else {
251
+ this.basePath = this.url;
252
+ }
253
+ if (isApi) {
254
+ var newName = response.resourcePath.replace(/\//g, '');
255
+ this.resourcePath = response.resourcePath;
256
+ var res = new SwaggerResource(response, this);
257
+ this.apis[newName] = res;
258
+ this.apisArray.push(res);
259
+ } else {
260
+ for (k = 0; k < response.apis.length; k++) {
261
+ resource = response.apis[k];
262
+ var res = new SwaggerResource(resource, this);
263
+ this.apis[res.name] = res;
264
+ this.apisArray.push(res);
265
+ }
266
+ }
267
+ this.isValid = true;
268
+ if (this.success) {
269
+ this.success();
270
+ }
271
+ return this;
272
+ };
273
+
274
+ SwaggerApi.prototype.selfReflect = function () {
275
+ var resource, resource_name, _ref;
276
+ if (this.apis == null) {
277
+ return false;
278
+ }
279
+ _ref = this.apis;
280
+ for (resource_name in _ref) {
281
+ resource = _ref[resource_name];
282
+ if (resource.ready == null) {
283
+ return false;
284
+ }
285
+ }
286
+ this.setConsolidatedModels();
287
+ this.ready = true;
288
+ if (this.success != null) {
289
+ return this.success();
290
+ }
291
+ };
292
+
293
+ SwaggerApi.prototype.fail = function (message) {
294
+ this.failure(message);
295
+ throw message;
296
+ };
297
+
298
+ SwaggerApi.prototype.setConsolidatedModels = function () {
299
+ var model, modelName, resource, resource_name, _i, _len, _ref, _ref1, _results;
300
+ this.models = {};
301
+ _ref = this.apis;
302
+ for (resource_name in _ref) {
303
+ resource = _ref[resource_name];
304
+ for (modelName in resource.models) {
305
+ if (this.models[modelName] == null) {
306
+ this.models[modelName] = resource.models[modelName];
307
+ this.modelsArray.push(resource.models[modelName]);
308
+ }
309
+ }
310
+ }
311
+ _ref1 = this.modelsArray;
312
+ _results = [];
313
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
314
+ model = _ref1[_i];
315
+ _results.push(model.setReferencedModels(this.models));
316
+ }
317
+ return _results;
318
+ };
319
+
320
+ SwaggerApi.prototype.help = function () {
321
+ var operation, operation_name, parameter, resource, resource_name, _i, _len, _ref, _ref1, _ref2;
322
+ _ref = this.apis;
323
+ for (resource_name in _ref) {
324
+ resource = _ref[resource_name];
325
+ log(resource_name);
326
+ _ref1 = resource.operations;
327
+ for (operation_name in _ref1) {
328
+ operation = _ref1[operation_name];
329
+ log(" " + operation.nickname);
330
+ _ref2 = operation.parameters;
331
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
332
+ parameter = _ref2[_i];
333
+ log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
334
+ }
335
+ }
336
+ }
337
+ return this;
338
+ };
339
+
340
+ var SwaggerResource = function (resourceObj, api) {
341
+ var _this = this;
342
+ this.api = api;
343
+ this.api = this.api;
344
+ var consumes = (this.consumes | []);
345
+ var produces = (this.produces | []);
346
+ this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
347
+ this.description = resourceObj.description;
348
+
349
+ var parts = this.path.split("/");
350
+ this.name = parts[parts.length - 1].replace('.{format}', '');
351
+ this.basePath = this.api.basePath;
352
+ this.operations = {};
353
+ this.operationsArray = [];
354
+ this.modelsArray = [];
355
+ this.models = {};
356
+ this.rawModels = {};
357
+ this.useJQuery = (typeof api.useJQuery !== 'undefined' ? api.useJQuery : null);
358
+
359
+ if ((resourceObj.apis != null) && (this.api.resourcePath != null)) {
360
+ this.addApiDeclaration(resourceObj);
361
+ } else {
362
+ if (this.path == null) {
363
+ this.api.fail("SwaggerResources must have a path.");
364
+ }
365
+ if (this.path.substring(0, 4) === 'http') {
366
+ this.url = this.path.replace('{format}', 'json');
367
+ } else {
368
+ this.url = this.api.basePath + this.path.replace('{format}', 'json');
369
+ }
370
+ this.api.progress('fetching resource ' + this.name + ': ' + this.url);
371
+ var obj = {
372
+ url: this.url,
373
+ method: "get",
374
+ useJQuery: this.useJQuery,
375
+ headers: {
376
+ accept: "application/json,application/json;charset=\"utf-8\",*/*"
377
+ },
378
+ on: {
379
+ response: function (resp) {
380
+ var responseObj = resp.obj || JSON.parse(resp.data);
381
+ return _this.addApiDeclaration(responseObj);
382
+ },
383
+ error: function (response) {
384
+ return _this.api.fail("Unable to read api '" +
385
+ _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")");
386
+ }
387
+ }
388
+ };
389
+ var e = typeof window !== 'undefined' ? window : exports;
390
+ e.authorizations.apply(obj);
391
+ new SwaggerHttp().execute(obj);
392
+ }
393
+ }
394
+
395
+ SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) {
396
+ var pos, url;
397
+ url = this.api.basePath;
398
+ pos = url.lastIndexOf(relativeBasePath);
399
+ var parts = url.split("/");
400
+ var rootUrl = parts[0] + "//" + parts[2];
401
+
402
+ if (relativeBasePath.indexOf("http") === 0)
403
+ return relativeBasePath;
404
+ if (relativeBasePath === "/")
405
+ return rootUrl;
406
+ if (relativeBasePath.substring(0, 1) == "/") {
407
+ // use root + relative
408
+ return rootUrl + relativeBasePath;
409
+ }
410
+ else {
411
+ var pos = this.basePath.lastIndexOf("/");
412
+ var base = this.basePath.substring(0, pos);
413
+ if (base.substring(base.length - 1) == "/")
414
+ return base + relativeBasePath;
415
+ else
416
+ return base + "/" + relativeBasePath;
417
+ }
418
+ };
419
+
420
+ SwaggerResource.prototype.addApiDeclaration = function (response) {
421
+ if (response.produces != null)
422
+ this.produces = response.produces;
423
+ if (response.consumes != null)
424
+ this.consumes = response.consumes;
425
+ if ((response.basePath != null) && response.basePath.replace(/\s/g, '').length > 0)
426
+ this.basePath = response.basePath.indexOf("http") === -1 ? this.getAbsoluteBasePath(response.basePath) : response.basePath;
427
+
428
+ this.addModels(response.models);
429
+ if (response.apis) {
430
+ for (var i = 0 ; i < response.apis.length; i++) {
431
+ var endpoint = response.apis[i];
432
+ this.addOperations(endpoint.path, endpoint.operations, response.consumes, response.produces);
433
+ }
434
+ }
435
+ this.api[this.name] = this;
436
+ this.ready = true;
437
+ return this.api.selfReflect();
438
+ };
439
+
440
+ SwaggerResource.prototype.addModels = function (models) {
441
+ if (models != null) {
442
+ var modelName;
443
+ for (modelName in models) {
444
+ if (this.models[modelName] == null) {
445
+ var swaggerModel = new SwaggerModel(modelName, models[modelName]);
446
+ this.modelsArray.push(swaggerModel);
447
+ this.models[modelName] = swaggerModel;
448
+ this.rawModels[modelName] = models[modelName];
449
+ }
450
+ }
451
+ var output = [];
452
+ for (var i = 0; i < this.modelsArray.length; i++) {
453
+ var model = this.modelsArray[i];
454
+ output.push(model.setReferencedModels(this.models));
455
+ }
456
+ return output;
457
+ }
458
+ };
459
+
460
+ SwaggerResource.prototype.addOperations = function (resource_path, ops, consumes, produces) {
461
+ if (ops) {
462
+ var output = [];
463
+ for (var i = 0; i < ops.length; i++) {
464
+ var o = ops[i];
465
+ consumes = this.consumes;
466
+ produces = this.produces;
467
+ if (o.consumes != null)
468
+ consumes = o.consumes;
469
+ else
470
+ consumes = this.consumes;
471
+
472
+ if (o.produces != null)
473
+ produces = o.produces;
474
+ else
475
+ produces = this.produces;
476
+ var type = (o.type || o.responseClass);
477
+
478
+ if (type === "array") {
479
+ ref = null;
480
+ if (o.items)
481
+ ref = o.items["type"] || o.items["$ref"];
482
+ type = "array[" + ref + "]";
483
+ }
484
+ var responseMessages = o.responseMessages;
485
+ var method = o.method;
486
+ if (o.httpMethod) {
487
+ method = o.httpMethod;
488
+ }
489
+ if (o.supportedContentTypes) {
490
+ consumes = o.supportedContentTypes;
491
+ }
492
+ if (o.errorResponses) {
493
+ responseMessages = o.errorResponses;
494
+ for (var j = 0; j < responseMessages.length; j++) {
495
+ r = responseMessages[j];
496
+ r.message = r.reason;
497
+ r.reason = null;
498
+ }
499
+ }
500
+ o.nickname = this.sanitize(o.nickname);
501
+ var op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, type, responseMessages, this, consumes, produces, o.authorizations);
502
+ this.operations[op.nickname] = op;
503
+ output.push(this.operationsArray.push(op));
504
+ }
505
+ return output;
506
+ }
507
+ };
508
+
509
+ SwaggerResource.prototype.sanitize = function (nickname) {
510
+ var op;
511
+ op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|.\/?,\\'""-]/g, '_');
512
+ op = op.replace(/((_){2,})/g, '_');
513
+ op = op.replace(/^(_)*/g, '');
514
+ op = op.replace(/([_])*$/g, '');
515
+ return op;
516
+ };
517
+
518
+ SwaggerResource.prototype.help = function () {
519
+ var op = this.operations;
520
+ var output = [];
521
+ var operation_name;
522
+ for (operation_name in op) {
523
+ operation = op[operation_name];
524
+ var msg = " " + operation.nickname;
525
+ for (var i = 0; i < operation.parameters; i++) {
526
+ parameter = operation.parameters[i];
527
+ msg.concat(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
528
+ }
529
+ output.push(msg);
530
+ }
531
+ return output;
532
+ };
533
+
534
+ var SwaggerModel = function (modelName, obj) {
535
+ this.name = obj.id != null ? obj.id : modelName;
536
+ this.properties = [];
537
+ var propertyName;
538
+ for (propertyName in obj.properties) {
539
+ if (obj.required != null) {
540
+ var value;
541
+ for (value in obj.required) {
542
+ if (propertyName === obj.required[value]) {
543
+ obj.properties[propertyName].required = true;
544
+ }
545
+ }
546
+ }
547
+ var prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]);
548
+ this.properties.push(prop);
549
+ }
550
+ }
551
+
552
+ SwaggerModel.prototype.setReferencedModels = function (allModels) {
553
+ var results = [];
554
+ for (var i = 0; i < this.properties.length; i++) {
555
+ var property = this.properties[i];
556
+ var type = property.type || property.dataType;
557
+ if (allModels[type] != null)
558
+ results.push(property.refModel = allModels[type]);
559
+ else if ((property.refDataType != null) && (allModels[property.refDataType] != null))
560
+ results.push(property.refModel = allModels[property.refDataType]);
561
+ else
562
+ results.push(void 0);
563
+ }
564
+ return results;
565
+ };
566
+
567
+ SwaggerModel.prototype.getMockSignature = function (modelsToIgnore) {
568
+ var propertiesStr = [];
569
+ for (var i = 0; i < this.properties.length; i++) {
570
+ var prop = this.properties[i];
571
+ propertiesStr.push(prop.toString());
572
+ }
573
+
574
+ var strong = '<span class="strong">';
575
+ var stronger = '<span class="stronger">';
576
+ var strongClose = '</span>';
577
+ var classOpen = strong + this.name + ' {' + strongClose;
578
+ var classClose = strong + '}' + strongClose;
579
+ var returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;
580
+ if (!modelsToIgnore)
581
+ modelsToIgnore = [];
582
+ modelsToIgnore.push(this.name);
583
+
584
+ for (var i = 0; i < this.properties.length; i++) {
585
+ var prop = this.properties[i];
586
+ if ((prop.refModel != null) && modelsToIgnore.indexOf(prop.refModel.name) === -1) {
587
+ returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));
588
+ }
589
+ }
590
+ return returnVal;
591
+ };
592
+
593
+ SwaggerModel.prototype.createJSONSample = function (modelsToIgnore) {
594
+ if (sampleModels[this.name]) {
595
+ return sampleModels[this.name];
596
+ }
597
+ else {
598
+ var result = {};
599
+ var modelsToIgnore = (modelsToIgnore || [])
600
+ modelsToIgnore.push(this.name);
601
+ for (var i = 0; i < this.properties.length; i++) {
602
+ var prop = this.properties[i];
603
+ result[prop.name] = prop.getSampleValue(modelsToIgnore);
604
+ }
605
+ modelsToIgnore.pop(this.name);
606
+ return result;
607
+ }
608
+ };
609
+
610
+ var SwaggerModelProperty = function (name, obj) {
611
+ this.name = name;
612
+ this.dataType = obj.type || obj.dataType || obj["$ref"];
613
+ this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
614
+ this.descr = obj.description;
615
+ this.required = obj.required;
616
+ this.defaultValue = modelPropertyMacro(obj.defaultValue);
617
+ if (obj.items != null) {
618
+ if (obj.items.type != null) {
619
+ this.refDataType = obj.items.type;
620
+ }
621
+ if (obj.items.$ref != null) {
622
+ this.refDataType = obj.items.$ref;
623
+ }
624
+ }
625
+ this.dataTypeWithRef = this.refDataType != null ? (this.dataType + '[' + this.refDataType + ']') : this.dataType;
626
+ if (obj.allowableValues != null) {
627
+ this.valueType = obj.allowableValues.valueType;
628
+ this.values = obj.allowableValues.values;
629
+ if (this.values != null) {
630
+ this.valuesString = "'" + this.values.join("' or '") + "'";
631
+ }
632
+ }
633
+ if (obj["enum"] != null) {
634
+ this.valueType = "string";
635
+ this.values = obj["enum"];
636
+ if (this.values != null) {
637
+ this.valueString = "'" + this.values.join("' or '") + "'";
638
+ }
639
+ }
640
+ }
641
+
642
+ SwaggerModelProperty.prototype.getSampleValue = function (modelsToIgnore) {
643
+ var result;
644
+ if ((this.refModel != null) && (modelsToIgnore.indexOf(this.refModel.name) === -1)) {
645
+ result = this.refModel.createJSONSample(modelsToIgnore);
646
+ } else {
647
+ if (this.isCollection) {
648
+ result = this.toSampleValue(this.refDataType);
649
+ } else {
650
+ result = this.toSampleValue(this.dataType);
651
+ }
652
+ }
653
+ if (this.isCollection) {
654
+ return [result];
655
+ } else {
656
+ return result;
657
+ }
658
+ };
659
+
660
+ SwaggerModelProperty.prototype.toSampleValue = function (value) {
661
+ var result;
662
+ if ((typeof this.defaultValue !== 'undefined') && this.defaultValue !== null) {
663
+ result = this.defaultValue;
664
+ } else if (value === "integer") {
665
+ result = 0;
666
+ } else if (value === "boolean") {
667
+ result = false;
668
+ } else if (value === "double" || value === "number") {
669
+ result = 0.0;
670
+ } else if (value === "string") {
671
+ result = "";
672
+ } else {
673
+ result = value;
674
+ }
675
+ return result;
676
+ };
677
+
678
+ SwaggerModelProperty.prototype.toString = function () {
679
+ var req = this.required ? 'propReq' : 'propOpt';
680
+ var str = '<span class="propName ' + req + '">' + this.name + '</span> (<span class="propType">' + this.dataTypeWithRef + '</span>';
681
+ if (!this.required) {
682
+ str += ', <span class="propOptKey">optional</span>';
683
+ }
684
+ str += ')';
685
+ if (this.values != null) {
686
+ str += " = <span class='propVals'>['" + this.values.join("' or '") + "']</span>";
687
+ }
688
+ if (this.descr != null) {
689
+ str += ': <span class="propDesc">' + this.descr + '</span>';
690
+ }
691
+ return str;
692
+ };
693
+
694
+ var SwaggerOperation = function (nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces, authorizations) {
695
+ var _this = this;
696
+
697
+ var errors = [];
698
+ this.nickname = (nickname || errors.push("SwaggerOperations must have a nickname."));
699
+ this.path = (path || errors.push("SwaggerOperation " + nickname + " is missing path."));
700
+ this.method = (method || errors.push("SwaggerOperation " + nickname + " is missing method."));
701
+ this.parameters = parameters != null ? parameters : [];
702
+ this.summary = summary;
703
+ this.notes = notes;
704
+ this.type = type;
705
+ this.responseMessages = (responseMessages || []);
706
+ this.resource = (resource || errors.push("Resource is required"));
707
+ this.consumes = consumes;
708
+ this.produces = produces;
709
+ this.authorizations = authorizations;
710
+ this["do"] = __bind(this["do"], this);
711
+
712
+ if (errors.length > 0) {
713
+ console.error('SwaggerOperation errors', errors, arguments);
714
+ this.resource.api.fail(errors);
715
+ }
716
+
717
+ this.path = this.path.replace('{format}', 'json');
718
+ this.method = this.method.toLowerCase();
719
+ this.isGetMethod = this.method === "get";
720
+
721
+ this.resourceName = this.resource.name;
722
+ if (typeof this.type !== 'undefined' && this.type === 'void')
723
+ this.type = null;
724
+ else {
725
+ this.responseClassSignature = this.getSignature(this.type, this.resource.models);
726
+ this.responseSampleJSON = this.getSampleJSON(this.type, this.resource.models);
727
+ }
728
+
729
+ for (var i = 0; i < this.parameters.length; i++) {
730
+ var param = this.parameters[i];
731
+ // might take this away
732
+ param.name = param.name || param.type || param.dataType;
733
+
734
+ // for 1.1 compatibility
735
+ var type = param.type || param.dataType;
736
+ if (type === 'array') {
737
+ type = 'array[' + (param.items.$ref ? param.items.$ref : param.items.type) + ']';
738
+ }
739
+ param.type = type;
740
+
741
+ if (type.toLowerCase() === 'boolean') {
742
+ param.allowableValues = {};
743
+ param.allowableValues.values = ["true", "false"];
744
+ }
745
+ param.signature = this.getSignature(type, this.resource.models);
746
+ param.sampleJSON = this.getSampleJSON(type, this.resource.models);
747
+
748
+ var enumValue = param["enum"];
749
+ if (enumValue != null) {
750
+ param.isList = true;
751
+ param.allowableValues = {};
752
+ param.allowableValues.descriptiveValues = [];
753
+
754
+ for (var j = 0; j < enumValue.length; j++) {
755
+ var v = enumValue[j];
756
+ if (param.defaultValue != null) {
757
+ param.allowableValues.descriptiveValues.push({
758
+ value: String(v),
759
+ isDefault: (v === param.defaultValue)
760
+ });
761
+ }
762
+ else {
763
+ param.allowableValues.descriptiveValues.push({
764
+ value: String(v),
765
+ isDefault: false
766
+ });
767
+ }
768
+ }
769
+ }
770
+ else if (param.allowableValues != null) {
771
+ if (param.allowableValues.valueType === "RANGE")
772
+ param.isRange = true;
773
+ else
774
+ param.isList = true;
775
+ if (param.allowableValues != null) {
776
+ param.allowableValues.descriptiveValues = [];
777
+ if (param.allowableValues.values) {
778
+ for (var j = 0; j < param.allowableValues.values.length; j++) {
779
+ var v = param.allowableValues.values[j];
780
+ if (param.defaultValue != null) {
781
+ param.allowableValues.descriptiveValues.push({
782
+ value: String(v),
783
+ isDefault: (v === param.defaultValue)
784
+ });
785
+ }
786
+ else {
787
+ param.allowableValues.descriptiveValues.push({
788
+ value: String(v),
789
+ isDefault: false
790
+ });
791
+ }
792
+ }
793
+ }
794
+ }
795
+ }
796
+ param.defaultValue = parameterMacro(param.defaultValue);
797
+ }
798
+ this.resource[this.nickname] = function (args, callback, error) {
799
+ return _this["do"](args, callback, error);
800
+ };
801
+ this.resource[this.nickname].help = function () {
802
+ return _this.help();
803
+ };
804
+ }
805
+
806
+ SwaggerOperation.prototype.isListType = function (type) {
807
+ if (type && type.indexOf('[') >= 0) {
808
+ return type.substring(type.indexOf('[') + 1, type.indexOf(']'));
809
+ } else {
810
+ return void 0;
811
+ }
812
+ };
813
+
814
+ SwaggerOperation.prototype.getSignature = function (type, models) {
815
+ var isPrimitive, listType;
816
+ listType = this.isListType(type);
817
+ isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
818
+ if (isPrimitive) {
819
+ return type;
820
+ } else {
821
+ if (listType != null) {
822
+ return models[listType].getMockSignature();
823
+ } else {
824
+ return models[type].getMockSignature();
825
+ }
826
+ }
827
+ };
828
+
829
+ SwaggerOperation.prototype.getSampleJSON = function (type, models) {
830
+ var isPrimitive, listType, val;
831
+ listType = this.isListType(type);
832
+ isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
833
+ val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[type].createJSONSample());
834
+ if (val) {
835
+ val = listType ? [val] : val;
836
+ if (typeof val == "string")
837
+ return val;
838
+ else if (typeof val === "object") {
839
+ var t = val;
840
+ if (val instanceof Array && val.length > 0) {
841
+ t = val[0];
842
+ }
843
+ if (t.nodeName) {
844
+ var xmlString = new XMLSerializer().serializeToString(t);
845
+ return this.formatXml(xmlString);
846
+ }
847
+ else
848
+ return JSON.stringify(val, null, 2);
849
+ }
850
+ else
851
+ return val;
852
+ }
853
+ };
854
+
855
+ SwaggerOperation.prototype["do"] = function (args, opts, callback, error) {
856
+ var key, param, params, possibleParams, req, requestContentType, responseContentType, value, _i, _len, _ref;
857
+ if (args == null) {
858
+ args = {};
859
+ }
860
+ if (opts == null) {
861
+ opts = {};
862
+ }
863
+ requestContentType = null;
864
+ responseContentType = null;
865
+ if ((typeof args) === "function") {
866
+ error = opts;
867
+ callback = args;
868
+ args = {};
869
+ }
870
+ if ((typeof opts) === "function") {
871
+ error = callback;
872
+ callback = opts;
873
+ }
874
+ if (error == null) {
875
+ error = function (xhr, textStatus, error) {
876
+ return log(xhr, textStatus, error);
877
+ };
878
+ }
879
+ if (callback == null) {
880
+ callback = function (response) {
881
+ var content;
882
+ content = null;
883
+ if (response != null) {
884
+ content = response.data;
885
+ } else {
886
+ content = "no data";
887
+ }
888
+ return log("default callback: " + content);
889
+ };
890
+ }
891
+ params = {};
892
+ params.headers = [];
893
+ if (args.headers != null) {
894
+ params.headers = args.headers;
895
+ delete args.headers;
896
+ }
897
+
898
+ var possibleParams = [];
899
+ for (var i = 0; i < this.parameters.length; i++) {
900
+ var param = this.parameters[i];
901
+ if (param.paramType === 'header') {
902
+ if (args[param.name])
903
+ params.headers[param.name] = args[param.name];
904
+ }
905
+ else if (param.paramType === 'form' || param.paramType.toLowerCase() === 'file')
906
+ possibleParams.push(param);
907
+ }
908
+
909
+ if (args.body != null) {
910
+ params.body = args.body;
911
+ delete args.body;
912
+ }
913
+
914
+ if (possibleParams) {
915
+ var key;
916
+ for (key in possibleParams) {
917
+ var value = possibleParams[key];
918
+ if (args[value.name]) {
919
+ params[value.name] = args[value.name];
920
+ }
921
+ }
922
+ }
923
+
924
+ req = new SwaggerRequest(this.method, this.urlify(args), params, opts, callback, error, this);
925
+ if (opts.mock != null) {
926
+ return req;
927
+ } else {
928
+ return true;
929
+ }
930
+ };
931
+
932
+ SwaggerOperation.prototype.pathJson = function () {
933
+ return this.path.replace("{format}", "json");
934
+ };
935
+
936
+ SwaggerOperation.prototype.pathXml = function () {
937
+ return this.path.replace("{format}", "xml");
938
+ };
939
+
940
+ SwaggerOperation.prototype.encodePathParam = function (pathParam) {
941
+ var encParts, part, parts, _i, _len;
942
+ pathParam = pathParam.toString();
943
+ if (pathParam.indexOf("/") === -1) {
944
+ return encodeURIComponent(pathParam);
945
+ } else {
946
+ parts = pathParam.split("/");
947
+ encParts = [];
948
+ for (_i = 0, _len = parts.length; _i < _len; _i++) {
949
+ part = parts[_i];
950
+ encParts.push(encodeURIComponent(part));
951
+ }
952
+ return encParts.join("/");
953
+ }
954
+ };
955
+
956
+ SwaggerOperation.prototype.urlify = function (args) {
957
+ var url = this.resource.basePath + this.pathJson();
958
+ var params = this.parameters;
959
+ for (var i = 0; i < params.length; i++) {
960
+ var param = params[i];
961
+ if (param.paramType === 'path') {
962
+ if (args[param.name]) {
963
+ // apply path params and remove from args
964
+ var reg = new RegExp('\\{\\s*?' + param.name + '.*?\\}(?=\\s*?(\\/|$))', 'gi');
965
+ url = url.replace(reg, this.encodePathParam(args[param.name]));
966
+ delete args[param.name];
967
+ }
968
+ else
969
+ throw "" + param.name + " is a required path param.";
970
+ }
971
+ }
972
+
973
+ var queryParams = "";
974
+ for (var i = 0; i < params.length; i++) {
975
+ var param = params[i];
976
+ if (param.paramType === 'query') {
977
+ if (args[param.name] !== undefined) {
978
+ var value = args[param.name];
979
+ if (queryParams !== '')
980
+ queryParams += '&';
981
+ if (Array.isArray(value)) {
982
+ var j;
983
+ var output = '';
984
+ for(j = 0; j < value.length; j++) {
985
+ if(j > 0)
986
+ output += ',';
987
+ output += encodeURIComponent(value[j]);
988
+ }
989
+ queryParams += encodeURIComponent(param.name) + '=' + output;
990
+ }
991
+ else {
992
+ queryParams += encodeURIComponent(param.name) + '=' + encodeURIComponent(args[param.name]);
993
+ }
994
+ }
995
+ }
996
+ }
997
+ if ((queryParams != null) && queryParams.length > 0)
998
+ url += '?' + queryParams;
999
+ return url;
1000
+ };
1001
+
1002
+ SwaggerOperation.prototype.supportHeaderParams = function () {
1003
+ return this.resource.api.supportHeaderParams;
1004
+ };
1005
+
1006
+ SwaggerOperation.prototype.supportedSubmitMethods = function () {
1007
+ return this.resource.api.supportedSubmitMethods;
1008
+ };
1009
+
1010
+ SwaggerOperation.prototype.getQueryParams = function (args) {
1011
+ return this.getMatchingParams(['query'], args);
1012
+ };
1013
+
1014
+ SwaggerOperation.prototype.getHeaderParams = function (args) {
1015
+ return this.getMatchingParams(['header'], args);
1016
+ };
1017
+
1018
+ SwaggerOperation.prototype.getMatchingParams = function (paramTypes, args) {
1019
+ var matchingParams = {};
1020
+ var params = this.parameters;
1021
+ for (var i = 0; i < params.length; i++) {
1022
+ param = params[i];
1023
+ if (args && args[param.name])
1024
+ matchingParams[param.name] = args[param.name];
1025
+ }
1026
+ var headers = this.resource.api.headers;
1027
+ var name;
1028
+ for (name in headers) {
1029
+ var value = headers[name];
1030
+ matchingParams[name] = value;
1031
+ }
1032
+ return matchingParams;
1033
+ };
1034
+
1035
+ SwaggerOperation.prototype.help = function () {
1036
+ var msg = "";
1037
+ var params = this.parameters;
1038
+ for (var i = 0; i < params.length; i++) {
1039
+ var param = params[i];
1040
+ if (msg !== "")
1041
+ msg += "\n";
1042
+ msg += "* " + param.name + (param.required ? ' (required)' : '') + " - " + param.description;
1043
+ }
1044
+ return msg;
1045
+ };
1046
+
1047
+
1048
+ SwaggerOperation.prototype.formatXml = function (xml) {
1049
+ var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;
1050
+ reg = /(>)(<)(\/*)/g;
1051
+ wsexp = /[ ]*(.*)[ ]+\n/g;
1052
+ contexp = /(<.+>)(.+\n)/g;
1053
+ xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
1054
+ pad = 0;
1055
+ formatted = '';
1056
+ lines = xml.split('\n');
1057
+ indent = 0;
1058
+ lastType = 'other';
1059
+ transitions = {
1060
+ 'single->single': 0,
1061
+ 'single->closing': -1,
1062
+ 'single->opening': 0,
1063
+ 'single->other': 0,
1064
+ 'closing->single': 0,
1065
+ 'closing->closing': -1,
1066
+ 'closing->opening': 0,
1067
+ 'closing->other': 0,
1068
+ 'opening->single': 1,
1069
+ 'opening->closing': 0,
1070
+ 'opening->opening': 1,
1071
+ 'opening->other': 1,
1072
+ 'other->single': 0,
1073
+ 'other->closing': -1,
1074
+ 'other->opening': 0,
1075
+ 'other->other': 0
1076
+ };
1077
+ _fn = function (ln) {
1078
+ var fromTo, j, key, padding, type, types, value;
1079
+ types = {
1080
+ single: Boolean(ln.match(/<.+\/>/)),
1081
+ closing: Boolean(ln.match(/<\/.+>/)),
1082
+ opening: Boolean(ln.match(/<[^!?].*>/))
1083
+ };
1084
+ type = ((function () {
1085
+ var _results;
1086
+ _results = [];
1087
+ for (key in types) {
1088
+ value = types[key];
1089
+ if (value) {
1090
+ _results.push(key);
1091
+ }
1092
+ }
1093
+ return _results;
1094
+ })())[0];
1095
+ type = type === void 0 ? 'other' : type;
1096
+ fromTo = lastType + '->' + type;
1097
+ lastType = type;
1098
+ padding = '';
1099
+ indent += transitions[fromTo];
1100
+ padding = ((function () {
1101
+ var _j, _ref5, _results;
1102
+ _results = [];
1103
+ for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) {
1104
+ _results.push(' ');
1105
+ }
1106
+ return _results;
1107
+ })()).join('');
1108
+ if (fromTo === 'opening->closing') {
1109
+ return formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
1110
+ } else {
1111
+ return formatted += padding + ln + '\n';
1112
+ }
1113
+ };
1114
+ for (_i = 0, _len = lines.length; _i < _len; _i++) {
1115
+ ln = lines[_i];
1116
+ _fn(ln);
1117
+ }
1118
+ return formatted;
1119
+ };
1120
+
1121
+ var SwaggerRequest = function (type, url, params, opts, successCallback, errorCallback, operation, execution) {
1122
+ var _this = this;
1123
+ var errors = [];
1124
+ this.useJQuery = (typeof operation.resource.useJQuery !== 'undefined' ? operation.resource.useJQuery : null);
1125
+ this.type = (type || errors.push("SwaggerRequest type is required (get/post/put/delete/patch/options)."));
1126
+ this.url = (url || errors.push("SwaggerRequest url is required."));
1127
+ this.params = params;
1128
+ this.opts = opts;
1129
+ this.successCallback = (successCallback || errors.push("SwaggerRequest successCallback is required."));
1130
+ this.errorCallback = (errorCallback || errors.push("SwaggerRequest error callback is required."));
1131
+ this.operation = (operation || errors.push("SwaggerRequest operation is required."));
1132
+ this.execution = execution;
1133
+ this.headers = (params.headers || {});
1134
+
1135
+ if (errors.length > 0) {
1136
+ throw errors;
1137
+ }
1138
+
1139
+ this.type = this.type.toUpperCase();
1140
+
1141
+ // set request, response content type headers
1142
+ var headers = this.setHeaders(params, this.operation);
1143
+ var body = params.body;
1144
+
1145
+ // encode the body for form submits
1146
+ if (headers["Content-Type"]) {
1147
+ var values = {};
1148
+ var i;
1149
+ var operationParams = this.operation.parameters;
1150
+ for (i = 0; i < operationParams.length; i++) {
1151
+ var param = operationParams[i];
1152
+ if (param.paramType === "form")
1153
+ values[param.name] = param;
1154
+ }
1155
+
1156
+ if (headers["Content-Type"].indexOf("application/x-www-form-urlencoded") === 0) {
1157
+ var encoded = "";
1158
+ var key, value;
1159
+ for (key in values) {
1160
+ value = this.params[key];
1161
+ if (typeof value !== 'undefined') {
1162
+ if (encoded !== "")
1163
+ encoded += "&";
1164
+ encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
1165
+ }
1166
+ }
1167
+ body = encoded;
1168
+ }
1169
+ else if (headers["Content-Type"].indexOf("multipart/form-data") === 0) {
1170
+ // encode the body for form submits
1171
+ var data = "";
1172
+ var boundary = "----SwaggerFormBoundary" + Date.now();
1173
+ var key, value;
1174
+ for (key in values) {
1175
+ value = this.params[key];
1176
+ if (typeof value !== 'undefined') {
1177
+ data += '--' + boundary + '\n';
1178
+ data += 'Content-Disposition: form-data; name="' + key + '"';
1179
+ data += '\n\n';
1180
+ data += value + "\n";
1181
+ }
1182
+ }
1183
+ data += "--" + boundary + "--\n";
1184
+ headers["Content-Type"] = "multipart/form-data; boundary=" + boundary;
1185
+ body = data;
1186
+ }
1187
+ }
1188
+
1189
+ var obj;
1190
+ if (!((this.headers != null) && (this.headers.mock != null))) {
1191
+ obj = {
1192
+ url: this.url,
1193
+ method: this.type,
1194
+ headers: headers,
1195
+ body: body,
1196
+ useJQuery: this.useJQuery,
1197
+ on: {
1198
+ error: function (response) {
1199
+ return _this.errorCallback(response, _this.opts.parent);
1200
+ },
1201
+ redirect: function (response) {
1202
+ return _this.successCallback(response, _this.opts.parent);
1203
+ },
1204
+ 307: function (response) {
1205
+ return _this.successCallback(response, _this.opts.parent);
1206
+ },
1207
+ response: function (response) {
1208
+ return _this.successCallback(response, _this.opts.parent);
1209
+ }
1210
+ }
1211
+ };
1212
+ var e;
1213
+ if (typeof window !== 'undefined') {
1214
+ e = window;
1215
+ } else {
1216
+ e = exports;
1217
+ }
1218
+ var status = e.authorizations.apply(obj, this.operation.authorizations);
1219
+ if (opts.mock == null) {
1220
+ if (status !== false) {
1221
+ new SwaggerHttp().execute(obj);
1222
+ } else {
1223
+ obj.canceled = true;
1224
+ }
1225
+ } else {
1226
+ return obj;
1227
+ }
1228
+ }
1229
+ return obj;
1230
+ };
1231
+
1232
+ SwaggerRequest.prototype.setHeaders = function (params, operation) {
1233
+ // default type
1234
+ var accepts = "application/json";
1235
+ var consumes = "application/json";
1236
+
1237
+ var allDefinedParams = this.operation.parameters;
1238
+ var definedFormParams = [];
1239
+ var definedFileParams = [];
1240
+ var body = params.body;
1241
+ var headers = {};
1242
+
1243
+ // get params from the operation and set them in definedFileParams, definedFormParams, headers
1244
+ var i;
1245
+ for (i = 0; i < allDefinedParams.length; i++) {
1246
+ var param = allDefinedParams[i];
1247
+ if (param.paramType === "form")
1248
+ definedFormParams.push(param);
1249
+ else if (param.paramType === "file")
1250
+ definedFileParams.push(param);
1251
+ else if (param.paramType === "header" && this.params.headers) {
1252
+ var key = param.name;
1253
+ var headerValue = this.params.headers[param.name];
1254
+ if (typeof this.params.headers[param.name] !== 'undefined')
1255
+ headers[key] = headerValue;
1256
+ }
1257
+ }
1258
+
1259
+ // if there's a body, need to set the accepts header via requestContentType
1260
+ if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH" || this.type === "DELETE")) {
1261
+ if (this.opts.requestContentType)
1262
+ consumes = this.opts.requestContentType;
1263
+ } else {
1264
+ // if any form params, content type must be set
1265
+ if (definedFormParams.length > 0) {
1266
+ if (definedFileParams.length > 0)
1267
+ consumes = "multipart/form-data";
1268
+ else
1269
+ consumes = "application/x-www-form-urlencoded";
1270
+ }
1271
+ else if (this.type === "DELETE")
1272
+ body = "{}";
1273
+ else if (this.type != "DELETE")
1274
+ accepts = null;
1275
+ }
1276
+
1277
+ if (consumes && this.operation.consumes) {
1278
+ if (this.operation.consumes.indexOf(consumes) === -1) {
1279
+ log("server doesn't consume " + consumes + ", try " + JSON.stringify(this.operation.consumes));
1280
+ consumes = this.operation.consumes[0];
1281
+ }
1282
+ }
1283
+
1284
+ if (this.opts.responseContentType) {
1285
+ accepts = this.opts.responseContentType;
1286
+ } else {
1287
+ accepts = "application/json";
1288
+ }
1289
+ if (accepts && this.operation.produces) {
1290
+ if (this.operation.produces.indexOf(accepts) === -1) {
1291
+ log("server can't produce " + accepts);
1292
+ accepts = this.operation.produces[0];
1293
+ }
1294
+ }
1295
+
1296
+ if ((consumes && body !== "") || (consumes === "application/x-www-form-urlencoded"))
1297
+ headers["Content-Type"] = consumes;
1298
+ if (accepts)
1299
+ headers["Accept"] = accepts;
1300
+ return headers;
1301
+ }
1302
+
1303
+ SwaggerRequest.prototype.asCurl = function () {
1304
+ var results = [];
1305
+ if (this.headers) {
1306
+ var key;
1307
+ for (key in this.headers) {
1308
+ results.push("--header \"" + key + ": " + this.headers[v] + "\"");
1309
+ }
1310
+ }
1311
+ return "curl " + (results.join(" ")) + " " + this.url;
1312
+ };
1313
+
1314
+ /**
1315
+ * SwaggerHttp is a wrapper for executing requests
1316
+ */
1317
+ var SwaggerHttp = function () { };
1318
+
1319
+ SwaggerHttp.prototype.execute = function (obj) {
1320
+ if (obj && (typeof obj.useJQuery === 'boolean'))
1321
+ this.useJQuery = obj.useJQuery;
1322
+ else
1323
+ this.useJQuery = this.isIE8();
1324
+
1325
+ if (this.useJQuery)
1326
+ return new JQueryHttpClient().execute(obj);
1327
+ else
1328
+ return new ShredHttpClient().execute(obj);
1329
+ }
1330
+
1331
+ SwaggerHttp.prototype.isIE8 = function () {
1332
+ var detectedIE = false;
1333
+ if (typeof navigator !== 'undefined' && navigator.userAgent) {
1334
+ nav = navigator.userAgent.toLowerCase();
1335
+ if (nav.indexOf('msie') !== -1) {
1336
+ var version = parseInt(nav.split('msie')[1]);
1337
+ if (version <= 8) {
1338
+ detectedIE = true;
1339
+ }
1340
+ }
1341
+ }
1342
+ return detectedIE;
1343
+ };
1344
+
1345
+ /*
1346
+ * JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic.
1347
+ * NOTE: when jQuery is available it will export both '$' and 'jQuery' to the global space.
1348
+ * Since we are using closures here we need to alias it for internal use.
1349
+ */
1350
+ var JQueryHttpClient = function (options) {
1351
+ "use strict";
1352
+ if (!jQuery) {
1353
+ var jQuery = window.jQuery;
1354
+ }
1355
+ }
1356
+
1357
+ JQueryHttpClient.prototype.execute = function (obj) {
1358
+ var cb = obj.on;
1359
+ var request = obj;
1360
+
1361
+ obj.type = obj.method;
1362
+ obj.cache = false;
1363
+
1364
+ obj.beforeSend = function (xhr) {
1365
+ var key, results;
1366
+ if (obj.headers) {
1367
+ results = [];
1368
+ var key;
1369
+ for (key in obj.headers) {
1370
+ if (key.toLowerCase() === "content-type") {
1371
+ results.push(obj.contentType = obj.headers[key]);
1372
+ } else if (key.toLowerCase() === "accept") {
1373
+ results.push(obj.accepts = obj.headers[key]);
1374
+ } else {
1375
+ results.push(xhr.setRequestHeader(key, obj.headers[key]));
1376
+ }
1377
+ }
1378
+ return results;
1379
+ }
1380
+ };
1381
+
1382
+ obj.data = obj.body;
1383
+ obj.complete = function (response, textStatus, opts) {
1384
+ var headers = {},
1385
+ headerArray = response.getAllResponseHeaders().split("\n");
1386
+
1387
+ for (var i = 0; i < headerArray.length; i++) {
1388
+ var toSplit = headerArray[i].trim();
1389
+ if (toSplit.length === 0)
1390
+ continue;
1391
+ var separator = toSplit.indexOf(":");
1392
+ if (separator === -1) {
1393
+ // Name but no value in the header
1394
+ headers[toSplit] = null;
1395
+ continue;
1396
+ }
1397
+ var name = toSplit.substring(0, separator).trim(),
1398
+ value = toSplit.substring(separator + 1).trim();
1399
+ headers[name] = value;
1400
+ }
1401
+
1402
+ var out = {
1403
+ url: request.url,
1404
+ method: request.method,
1405
+ status: response.status,
1406
+ data: response.responseText,
1407
+ headers: headers
1408
+ };
1409
+
1410
+ var contentType = (headers["content-type"] || headers["Content-Type"] || null)
1411
+
1412
+ if (contentType != null) {
1413
+ if (contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
1414
+ if (response.responseText && response.responseText !== "")
1415
+ out.obj = JSON.parse(response.responseText);
1416
+ else
1417
+ out.obj = {}
1418
+ }
1419
+ }
1420
+
1421
+ if (response.status >= 200 && response.status < 300)
1422
+ cb.response(out);
1423
+ else if (response.status === 0 || (response.status >= 400 && response.status < 599))
1424
+ cb.error(out);
1425
+ else
1426
+ return cb.response(out);
1427
+ };
1428
+
1429
+ jQuery.support.cors = true;
1430
+ return jQuery.ajax(obj);
1431
+ }
1432
+
1433
+ /*
1434
+ * ShredHttpClient is a light-weight, node or browser HTTP client
1435
+ */
1436
+ var ShredHttpClient = function (options) {
1437
+ this.options = (options || {});
1438
+ this.isInitialized = false;
1439
+
1440
+ var identity, toString;
1441
+
1442
+ if (typeof window !== 'undefined') {
1443
+ this.Shred = require("./shred");
1444
+ this.content = require("./shred/content");
1445
+ }
1446
+ else
1447
+ this.Shred = require("shred");
1448
+ this.shred = new this.Shred();
1449
+ }
1450
+
1451
+ ShredHttpClient.prototype.initShred = function () {
1452
+ this.isInitialized = true;
1453
+ this.registerProcessors(this.shred);
1454
+ }
1455
+
1456
+ ShredHttpClient.prototype.registerProcessors = function (shred) {
1457
+ var identity = function (x) {
1458
+ return x;
1459
+ };
1460
+ var toString = function (x) {
1461
+ return x.toString();
1462
+ };
1463
+
1464
+ if (typeof window !== 'undefined') {
1465
+ this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
1466
+ parser: identity,
1467
+ stringify: toString
1468
+ });
1469
+ } else {
1470
+ this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
1471
+ parser: identity,
1472
+ stringify: toString
1473
+ });
1474
+ }
1475
+ }
1476
+
1477
+ ShredHttpClient.prototype.execute = function (obj) {
1478
+ if (!this.isInitialized)
1479
+ this.initShred();
1480
+
1481
+ var cb = obj.on, res;
1482
+
1483
+ var transform = function (response) {
1484
+ var out = {
1485
+ headers: response._headers,
1486
+ url: response.request.url,
1487
+ method: response.request.method,
1488
+ status: response.status,
1489
+ data: response.content.data
1490
+ };
1491
+
1492
+ var contentType = (response._headers["content-type"] || response._headers["Content-Type"] || null)
1493
+
1494
+ if (contentType != null) {
1495
+ if (contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
1496
+ if (response.content.data && response.content.data !== "")
1497
+ out.obj = JSON.parse(response.content.data);
1498
+ else
1499
+ out.obj = {}
1500
+ }
1501
+ }
1502
+ return out;
1503
+ };
1504
+
1505
+ // Transform an error into a usable response-like object
1506
+ var transformError = function (error) {
1507
+ var out = {
1508
+ // Default to a status of 0 - The client will treat this as a generic permissions sort of error
1509
+ status: 0,
1510
+ data: error.message || error
1511
+ };
1512
+
1513
+ if (error.code) {
1514
+ out.obj = error;
1515
+
1516
+ if (error.code === 'ENOTFOUND' || error.code === 'ECONNREFUSED') {
1517
+ // We can tell the client that this should be treated as a missing resource and not as a permissions thing
1518
+ out.status = 404;
1519
+ }
1520
+ }
1521
+
1522
+ return out;
1523
+ };
1524
+
1525
+ var res = {
1526
+ error: function (response) {
1527
+ if (obj)
1528
+ return cb.error(transform(response));
1529
+ },
1530
+ // Catch the Shred error raised when the request errors as it is made (i.e. No Response is coming)
1531
+ request_error: function (err) {
1532
+ if (obj)
1533
+ return cb.error(transformError(err));
1534
+ },
1535
+ redirect: function (response) {
1536
+ if (obj)
1537
+ return cb.redirect(transform(response));
1538
+ },
1539
+ 307: function (response) {
1540
+ if (obj)
1541
+ return cb.redirect(transform(response));
1542
+ },
1543
+ response: function (response) {
1544
+ if (obj)
1545
+ return cb.response(transform(response));
1546
+ }
1547
+ };
1548
+ if (obj) {
1549
+ obj.on = res;
1550
+ }
1551
+ return this.shred.request(obj);
1552
+ };
1553
+
1554
+ /**
1555
+ * SwaggerAuthorizations applys the correct authorization to an operation being executed
1556
+ */
1557
+ var SwaggerAuthorizations = function () {
1558
+ this.authz = {};
1559
+ };
1560
+
1561
+ SwaggerAuthorizations.prototype.add = function (name, auth) {
1562
+ this.authz[name] = auth;
1563
+ return auth;
1564
+ };
1565
+
1566
+ SwaggerAuthorizations.prototype.remove = function (name) {
1567
+ return delete this.authz[name];
1568
+ };
1569
+
1570
+ SwaggerAuthorizations.prototype.apply = function (obj, authorizations) {
1571
+ var status = null;
1572
+ var key, value, result;
1573
+
1574
+ // if the "authorizations" key is undefined, or has an empty array, add all keys
1575
+ if (typeof authorizations === 'undefined' || Object.keys(authorizations).length == 0) {
1576
+ for (key in this.authz) {
1577
+ value = this.authz[key];
1578
+ result = value.apply(obj, authorizations);
1579
+ if (result === true)
1580
+ status = true;
1581
+ }
1582
+ }
1583
+ else {
1584
+ for (name in authorizations) {
1585
+ for (key in this.authz) {
1586
+ if (key == name) {
1587
+ value = this.authz[key];
1588
+ result = value.apply(obj, authorizations);
1589
+ if (result === true)
1590
+ status = true;
1591
+ }
1592
+ }
1593
+ }
1594
+ }
1595
+
1596
+ return status;
1597
+ };
1598
+
1599
+ /**
1600
+ * ApiKeyAuthorization allows a query param or header to be injected
1601
+ */
1602
+ var ApiKeyAuthorization = function (name, value, type, delimiter) {
1603
+ this.name = name;
1604
+ this.value = value;
1605
+ this.type = type;
1606
+ this.delimiter = delimiter;
1607
+ };
1608
+
1609
+ ApiKeyAuthorization.prototype.apply = function (obj, authorizations) {
1610
+ if (this.type === "query") {
1611
+ if (obj.url.indexOf('?') > 0)
1612
+ obj.url = obj.url + "&" + this.name + "=" + this.value;
1613
+ else
1614
+ obj.url = obj.url + "?" + this.name + "=" + this.value;
1615
+ return true;
1616
+ } else if (this.type === "header") {
1617
+ if (typeof obj.headers[this.name] !== 'undefined') {
1618
+ if (typeof this.delimiter !== 'undefined')
1619
+ obj.headers[this.name] = obj.headers[this.name] + this.delimiter + this.value;
1620
+ }
1621
+ else
1622
+ obj.headers[this.name] = this.value;
1623
+ return true;
1624
+ }
1625
+ };
1626
+
1627
+ var CookieAuthorization = function (cookie) {
1628
+ this.cookie = cookie;
1629
+ }
1630
+
1631
+ CookieAuthorization.prototype.apply = function (obj, authorizations) {
1632
+ obj.cookieJar = obj.cookieJar || CookieJar();
1633
+ obj.cookieJar.setCookie(this.cookie);
1634
+ return true;
1635
+ }
1636
+
1637
+ /**
1638
+ * Password Authorization is a basic auth implementation
1639
+ */
1640
+ var PasswordAuthorization = function (name, username, password) {
1641
+ this.name = name;
1642
+ this.username = username;
1643
+ this.password = password;
1644
+ this._btoa = null;
1645
+ if (typeof window !== 'undefined')
1646
+ this._btoa = btoa;
1647
+ else
1648
+ this._btoa = require("btoa");
1649
+ };
1650
+
1651
+ PasswordAuthorization.prototype.apply = function (obj, authorizations) {
1652
+ var base64encoder = this._btoa;
1653
+ obj.headers["Authorization"] = "Basic " + base64encoder(this.username + ":" + this.password);
1654
+ return true;
1655
+ };
1656
+
1657
+ var e = (typeof window !== 'undefined' ? window : exports);
1658
+
1659
+ var sampleModels = {};
1660
+ var cookies = {};
1661
+
1662
+ e.SampleModels = sampleModels;
1663
+ e.SwaggerHttp = SwaggerHttp;
1664
+ e.SwaggerRequest = SwaggerRequest;
1665
+ e.authorizations = new SwaggerAuthorizations();
1666
+ e.ApiKeyAuthorization = ApiKeyAuthorization;
1667
+ e.PasswordAuthorization = PasswordAuthorization;
1668
+ e.CookieAuthorization = CookieAuthorization;
1669
+ e.JQueryHttpClient = JQueryHttpClient;
1670
+ e.ShredHttpClient = ShredHttpClient;
1671
+ e.SwaggerOperation = SwaggerOperation;
1672
+ e.SwaggerModel = SwaggerModel;
1673
+ e.SwaggerModelProperty = SwaggerModelProperty;
1674
+ e.SwaggerResource = SwaggerResource;
1675
+ e.SwaggerApi = SwaggerApi;
1676
+ e.log = log;
1677
+
1678
+ })();