grape-swagger-rails 0.0.8 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +3 -0
  3. data/.travis.yml +10 -0
  4. data/Gemfile +1 -2
  5. data/README.md +35 -21
  6. data/Rakefile +25 -0
  7. data/app/assets/images/grape_swagger_rails/explorer_icons.png +0 -0
  8. data/app/assets/javascripts/grape_swagger_rails/application.js +2 -13
  9. data/app/assets/javascripts/grape_swagger_rails/swagger-oauth.js +211 -0
  10. data/app/assets/javascripts/grape_swagger_rails/swagger-ui.min.js +1 -1
  11. data/app/assets/javascripts/grape_swagger_rails/swagger.js +1521 -1398
  12. data/app/assets/stylesheets/grape_swagger_rails/application.css +4 -13
  13. data/app/assets/stylesheets/grape_swagger_rails/reset.css +125 -0
  14. data/app/assets/stylesheets/grape_swagger_rails/screen.css.erb +545 -391
  15. data/app/controllers/grape_swagger_rails/application_controller.rb +3 -3
  16. data/app/views/grape_swagger_rails/application/index.html.erb +13 -7
  17. data/grape-swagger-rails.gemspec +21 -8
  18. data/lib/grape-swagger-rails.rb +16 -13
  19. data/lib/grape-swagger-rails/engine.rb +1 -0
  20. data/lib/grape-swagger-rails/version.rb +1 -1
  21. data/lib/javascripts/base64.js +134 -0
  22. data/lib/tasks/swagger_ui.rake +98 -0
  23. data/spec/dummy/.gitignore +16 -0
  24. data/spec/dummy/Rakefile +5 -0
  25. data/spec/dummy/app/api/api.rb +31 -0
  26. data/spec/dummy/app/assets/javascripts/application.js +3 -0
  27. data/spec/dummy/app/assets/stylesheets/application.css +4 -0
  28. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  29. data/spec/dummy/app/controllers/welcome_controller.rb +4 -0
  30. data/spec/dummy/app/views/layouts/_messages.html.erb +5 -0
  31. data/spec/dummy/app/views/layouts/application.html.erb +16 -0
  32. data/spec/dummy/app/views/welcome/index.html.erb +3 -0
  33. data/spec/dummy/bin/bundle +3 -0
  34. data/spec/dummy/bin/rails +8 -0
  35. data/spec/dummy/bin/rake +8 -0
  36. data/spec/dummy/bin/spring +18 -0
  37. data/spec/dummy/config.ru +4 -0
  38. data/spec/dummy/config/application.rb +23 -0
  39. data/spec/dummy/config/boot.rb +10 -0
  40. data/spec/dummy/config/environment.rb +3 -0
  41. data/spec/dummy/config/environments/development.rb +34 -0
  42. data/spec/dummy/config/environments/production.rb +79 -0
  43. data/spec/dummy/config/environments/test.rb +39 -0
  44. data/spec/dummy/config/initializers/assets.rb +1 -0
  45. data/spec/dummy/config/initializers/cookies_serializer.rb +1 -0
  46. data/spec/dummy/config/initializers/session_store.rb +1 -0
  47. data/spec/dummy/config/initializers/swagger.rb +3 -0
  48. data/spec/dummy/config/routes.rb +5 -0
  49. data/spec/dummy/config/secrets.yml +8 -0
  50. data/spec/dummy/public/.gitignore +2 -0
  51. data/spec/dummy/public/404.html +67 -0
  52. data/spec/dummy/public/422.html +67 -0
  53. data/spec/dummy/public/500.html +66 -0
  54. data/spec/dummy/public/favicon.ico +0 -0
  55. data/spec/dummy/public/robots.txt +5 -0
  56. data/spec/dummy/vendor/assets/javascripts/.keep +0 -0
  57. data/spec/dummy/vendor/assets/stylesheets/.keep +0 -0
  58. data/spec/features/grape-swagger-rails_spec.rb +15 -0
  59. data/spec/features/swagger_spec.rb +116 -0
  60. data/spec/features/welcome_spec.rb +10 -0
  61. data/spec/spec_helper.rb +15 -0
  62. data/spec/support/capybara.rb +5 -0
  63. data/spec/support/rails.rb +1 -0
  64. metadata +283 -31
  65. data/app/assets/javascripts/grape_swagger_rails/swagger-ui.js.erb +0 -2129
  66. data/app/assets/stylesheets/grape_swagger_rails/highlight.default.css +0 -135
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2bfe13ae83fc3b7f7cfb25f755c82eb07edf7eaa
4
- data.tar.gz: 3f9a15bf857253b985ede095b3dcfbbf9d0d6a17
3
+ metadata.gz: 5f70ee5fb99887f9c43af71656d1c66077922cc5
4
+ data.tar.gz: e82ff7b00d8e820589319bc23b5f532b3765e2a3
5
5
  SHA512:
6
- metadata.gz: 48c7269055cf898aa636b0999b14079819ec29753c789ad327b25909abac89c9754efab47105a4710e95944dae69dba91cc4daefe60bdf79750c5bdfa978e299
7
- data.tar.gz: 4be87ec4ad572c8efdcab73b5251d085774ed1430c76d88d6a910efbfe98eebd98f5d257ec8a42b94b913a50b03acb0b5f485cbbb8b0c13cc46f986ca7c79de5
6
+ metadata.gz: 50ccf22315d6f4ff1a2c3928397340b5e0cdcf06997bcfd2e82ca00b8cded414e8a5217674f686bba78021ff906cf5a1237eb5210f40e4530f213a12e5583265
7
+ data.tar.gz: 71db67f88d81052c230fa42e89209a02bc8b27df9d573de2c068bf6abe83a137992e2d92030c3217b3acff4e9074cea73091fabce20072a1a4519f39750a5fd4
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require spec_helper
3
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ before_install:
2
+ - "export DISPLAY=:99.0"
3
+ - "sh -e /etc/init.d/xvfb start"
4
+
5
+ language: ruby
6
+
7
+ cache: bundler
8
+
9
+ rvm:
10
+ - 2.1.2
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in grape-swagger-rails.gemspec
4
- gemspec
3
+ gemspec
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # GrapeSwaggerRails
2
2
 
3
+ [![Build Status](https://travis-ci.org/BrandyMint/grape-swagger-rails.svg)](https://travis-ci.org/BrandyMint/grape-swagger-rails)
4
+
3
5
  Swagger UI as Rails Engine for grape-swagger gem
4
6
 
5
7
  ## Installation
@@ -26,21 +28,26 @@ Add this line to `./config/routes.rb`:
26
28
  mount GrapeSwaggerRails::Engine => '/swagger'
27
29
  ```
28
30
 
29
- Create an initializer (e.g. `./config/initializer/swagger.rb`) and specify the URL to your Swagger API schema:
31
+ Create an initializer (e.g. `./config/initializers/swagger.rb`) and specify the URL to your Swagger API schema and app:
30
32
 
31
33
  ```ruby
32
34
  GrapeSwaggerRails.options.url = '/swagger_doc.json'
33
- GrapeSwaggerRails.options.app_name = 'Swagger'
34
35
  GrapeSwaggerRails.options.app_url = 'http://swagger.wordnik.com'
35
36
  ```
36
37
 
38
+ You can set the app name, default is "Swagger".
39
+
40
+ ``` ruby
41
+ GrapeSwaggerRails.options.app_name = 'Swagger'
42
+ ```
43
+
37
44
  You can specify additional headers to add to each request:
38
45
 
39
46
  ```ruby
40
47
  GrapeSwaggerRails.options.headers['Special-Header'] = 'Some Secret Value'
41
48
  ```
42
49
 
43
- Using the `headers` option above, you could hard-code Basic Authentication credentials.
50
+ Using the `headers` option above, you could hard-code Basic Authentication credentials.
44
51
  Alternatively, you can configure Basic Authentication through the UI, as described below.
45
52
 
46
53
  ### Basic Authentication
@@ -48,7 +55,7 @@ Alternatively, you can configure Basic Authentication through the UI, as describ
48
55
  If your application uses Basic Authentication, you can setup Swagger to send the username and password to the server with each request to your API:
49
56
 
50
57
  ```ruby
51
- GrapeSwaggerRails.options.api_auth = 'basic'
58
+ GrapeSwaggerRails.options.api_auth = 'basic' # Or 'bearer' for OAuth
52
59
  GrapeSwaggerRails.options.api_key_name = 'Authorization'
53
60
  GrapeSwaggerRails.options.api_key_type = 'header'
54
61
  ```
@@ -57,36 +64,42 @@ Now you can specify the username and password to your API in the Swagger "API ke
57
64
 
58
65
  username:password
59
66
 
60
- The javascript that loads on the Swagger page automatically encodes the username and password and adds the authorization header to your API request.
67
+ The javascript that loads on the Swagger page automatically encodes the username and password and adds the authorization header to your API request.
61
68
  See the official Swagger documentation about [Custom Header Parameters](https://github.com/wordnik/swagger-ui#custom-header-parameters---for-basic-auth-etc)
62
69
 
63
- ### Swagger UI Authorization
70
+ ### API Token Authentication
64
71
 
65
- You may want to authenticate users before displaying the Swagger UI, particularly when the API is protected by Basic Authentication.
66
- Use the `authenticate_with` option to inspect the request to the Swagger UI:
72
+ If your application uses token authentication passed as a query param, you can setup Swagger to send the API token along with each request to your API:
67
73
 
68
74
  ```ruby
69
- GrapeSwaggerRails.options.authenticate_with do |request|
70
- # 1. Inspect the `request` or access the Swagger UI controller via `self`
71
- # 2. Check `current_user` or `can? :access, :api`, etc....
72
- # 3. return a boolean value
73
- end
75
+ GrapeSwaggerRails.options.api_key_name = 'api_token'
76
+ GrapeSwaggerRails.options.api_key_type = 'query'
74
77
  ```
75
78
 
76
- The block above is stored in the `authentication_proc` option:
79
+ You can use the ```api_key``` input box to fill in your API token.
80
+ ### Swagger UI Authorization
81
+
82
+ You may want to authenticate users before displaying the Swagger UI, particularly when the API is protected by Basic Authentication.
83
+ Use the `before` option to inspect the request before Swagger UI:
77
84
 
78
85
  ```ruby
79
- GrapeSwaggerRails.options.authentication_proc: Proc.new{|request| # return a boolean value}
86
+ GrapeSwaggerRails.options.before_filter do |request|
87
+ # 1. Inspect the `request` or access the Swagger UI controller via `self`.
88
+ # 2. Check `current_user` or `can? :access, :api`, etc.
89
+ # 3. Redirect or error in case of failure.
90
+ end
80
91
  ```
81
92
 
82
- ## Known problems
93
+ ### Updating Swagger UI from Dist
83
94
 
84
- To avoid problems with the validation parameters in `POST` request using this gem,
85
- please use the head version:
95
+ To update Swagger UI from its [distribution](https://github.com/wordnik/swagger-ui), run 'bundle exec rake swagger_ui:dist:update'. Examine the changes carefully.
86
96
 
87
- ```ruby
88
- gem 'grape-swagger', :git=>'git://github.com/jhecking/grape-swagger.git'
89
- ```
97
+ ##Contributors
98
+
99
+ * unloved (https://github.com/unloved)
100
+ * dapi (https://github.com/dapi)
101
+ * joelvh (https://github.com/joelvh)
102
+ * dblock (https://github.com/dblock)
90
103
 
91
104
  ## Contributing
92
105
 
@@ -95,3 +108,4 @@ gem 'grape-swagger', :git=>'git://github.com/jhecking/grape-swagger.git'
95
108
  3. Commit your changes (`git commit -am 'Add some feature'`)
96
109
  4. Push to the branch (`git push origin my-new-feature`)
97
110
  5. Create new Pull Request
111
+
data/Rakefile CHANGED
@@ -1 +1,26 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+
4
+ #!/usr/bin/env rake
5
+ begin
6
+ require 'bundler/setup'
7
+ rescue LoadError
8
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
9
+ end
10
+
11
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
12
+
13
+ load 'rails/tasks/engine.rake'
14
+ Bundler::GemHelper.install_tasks
15
+
16
+ Dir[File.join(File.dirname(__FILE__), 'lib/tasks/**/*.rake')].each do |f|
17
+ load f
18
+ end
19
+
20
+ require 'rspec/core'
21
+ require 'rspec/core/rake_task'
22
+
23
+ desc "Run all specs."
24
+ RSpec::Core::RakeTask.new(:spec)
25
+
26
+ task :default => :spec
@@ -1,15 +1,3 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // the compiled file.
9
- //
10
- // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
- // GO AFTER THE REQUIRES BELOW.
12
- //
13
1
  //= require ./shred.bundle
14
2
  //= require ./jquery-1.8.0.min
15
3
  //= require ./jquery.slideto.min
@@ -19,6 +7,7 @@
19
7
  //= require ./underscore-min
20
8
  //= require ./backbone-min
21
9
  //= require ./swagger
22
- //= require ./swagger-ui
10
+ //= require ./swagger-ui.min
23
11
  //= require ./highlight.7.3.pack
12
+ //= require ./swagger-oauth
24
13
  //= require ./base64
@@ -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
+ }
@@ -1 +1 @@
1
- $(function(){$.fn.vAlign=function(){return this.each(function(c){var a=$(this).height();var d=$(this).parent().height();var b=(d-a)/2;$(this).css("margin-top",b)})};$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(b){var d=$(this).closest("form").innerWidth();var c=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10);var a=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",d-c-a)})};$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent();$("ul.downplayed li div.content p").vAlign();$("form.sandbox").submit(function(){var a=true;$(this).find("input.required").each(function(){$(this).removeClass("error");if($(this).val()==""){$(this).addClass("error");$(this).wiggle();a=false}});return a})});function clippyCopiedCallback(b){$("#api_key_copied").fadeIn().delay(1000).fadeOut()}function log(){if(window.console){console.log.apply(console,arguments)}}if(Function.prototype.bind&&console&&typeof console.log=="object"){["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(a){console[a]=this.bind(console[a],console)},Function.prototype.call)}var Docs={shebang:function(){var b=$.param.fragment().split("/");b.shift();switch(b.length){case 1:var d="resource_"+b[0];Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});break;case 2:Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});var c=b.join("_");var a=c+"_content";Docs.expandOperation($("#"+a));$("#"+c).slideto({highlight:false});break}},toggleEndpointListForResource:function(b){var a=$("li#resource_"+Docs.escapeResourceName(b)+" ul.endpoints");if(a.is(":visible")){Docs.collapseEndpointListForResource(b)}else{Docs.expandEndpointListForResource(b)}},expandEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);if(b==""){$(".resource ul.endpoints").slideDown();return}$("li#resource_"+b).addClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideDown()},collapseEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);$("li#resource_"+b).removeClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideUp()},expandOperationsForResource:function(a){Docs.expandEndpointListForResource(a);if(a==""){$(".resource ul.endpoints li.operation div.content").slideDown();return}$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(a){Docs.expandEndpointListForResource(a);$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(a){return a.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g,"\\$&")},expandOperation:function(a){a.slideDown()},collapseOperation:function(a){a.slideUp()}};(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.produces,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n <option value="';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+='">';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+="</option>\n ";return o}function n(p,o){return'\n <option value="application/json">application/json</option>\n'}i+='<label for="contentType"></label>\n<select name="contentType">\n';c=f["if"].call(l,l.produces,{hash:{},inverse:m.program(4,n,j),fn:m.program(1,e,j),data:j});if(c||c===0){i+=c}i+="\n</select>\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.main=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",c,h="function",j=this.escapeExpression,p=this;function e(v,u){var r="",t,s;r+='\n <div class="info_title">'+j(((t=((t=v.info),t==null||t===false?t:t.title)),typeof t===h?t.apply(v):t))+'</div>\n <div class="info_description">';s=((t=((t=v.info),t==null||t===false?t:t.description)),typeof t===h?t.apply(v):t);if(s||s===0){r+=s}r+="</div>\n ";s=f["if"].call(v,((t=v.info),t==null||t===false?t:t.termsOfServiceUrl),{hash:{},inverse:p.noop,fn:p.program(2,d,u),data:u});if(s||s===0){r+=s}r+="\n ";s=f["if"].call(v,((t=v.info),t==null||t===false?t:t.contact),{hash:{},inverse:p.noop,fn:p.program(4,q,u),data:u});if(s||s===0){r+=s}r+="\n ";s=f["if"].call(v,((t=v.info),t==null||t===false?t:t.license),{hash:{},inverse:p.noop,fn:p.program(6,o,u),data:u});if(s||s===0){r+=s}r+="\n ";return r}function d(u,t){var r="",s;r+='<div class="info_tos"><a href="'+j(((s=((s=u.info),s==null||s===false?s:s.termsOfServiceUrl)),typeof s===h?s.apply(u):s))+'">Terms of service</a></div>';return r}function q(u,t){var r="",s;r+="<div class='info_contact'><a href=\"mailto:"+j(((s=((s=u.info),s==null||s===false?s:s.contact)),typeof s===h?s.apply(u):s))+'">Contact the developer</a></div>';return r}function o(u,t){var r="",s;r+="<div class='info_license'><a href='"+j(((s=((s=u.info),s==null||s===false?s:s.licenseUrl)),typeof s===h?s.apply(u):s))+"'>"+j(((s=((s=u.info),s==null||s===false?s:s.license)),typeof s===h?s.apply(u):s))+"</a></div>";return r}function n(u,t){var r="",s;r+='\n , <span style="font-variant: small-caps">api version</span>: ';if(s=f.apiVersion){s=s.call(u,{hash:{},data:t})}else{s=u.apiVersion;s=typeof s===h?s.apply(u):s}r+=j(s)+"\n ";return r}i+="<div class='info' id='api_info'>\n ";c=f["if"].call(m,m.info,{hash:{},inverse:p.noop,fn:p.program(1,e,k),data:k});if(c||c===0){i+=c}i+="\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>: ";if(c=f.basePath){c=c.call(m,{hash:{},data:k})}else{c=m.basePath;c=typeof c===h?c.apply(m):c}i+=j(c)+"\n ";c=f["if"].call(m,m.apiVersion,{hash:{},inverse:p.noop,fn:p.program(8,n,k),data:k});if(c||c===0){i+=c}i+="]</h4>\n </div>\n</div>\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(h,n,g,m,l){this.compilerInfo=[4,">= 1.0.0"];g=this.merge(g,h.helpers);l=l||{};var j="",d,i="function",k=this.escapeExpression,r=this;function f(v,u){var s="",t;s+="\n <h4>Implementation Notes</h4>\n <p>";if(t=g.notes){t=t.call(v,{hash:{},data:u})}else{t=v.notes;t=typeof t===i?t.apply(v):t}if(t||t===0){s+=t}s+="</p>\n ";return s}function c(t,s){return'\n <h4>Response Class</h4>\n <p><span class="model-signature" /></p>\n <br/>\n <div class="response-content-type" />\n '}function q(t,s){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 '}function p(t,s){return"\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Error Status Codes</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>HTTP Status Code</th>\n <th>Reason</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n "}function o(t,s){return"\n "}function e(t,s){return"\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <img alt='Throbber' class='response_throbber' src='images/throbber.gif' style='display:none' />\n </div>\n "}j+="\n <ul class='operations' >\n <li class='";if(d=g.method){d=d.call(n,{hash:{},data:l})}else{d=n.method;d=typeof d===i?d.apply(n):d}j+=k(d)+" operation' id='";if(d=g.resourceName){d=d.call(n,{hash:{},data:l})}else{d=n.resourceName;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.nickname){d=d.call(n,{hash:{},data:l})}else{d=n.nickname;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.method){d=d.call(n,{hash:{},data:l})}else{d=n.method;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.number){d=d.call(n,{hash:{},data:l})}else{d=n.number;d=typeof d===i?d.apply(n):d}j+=k(d)+"'>\n <div class='heading'>\n <h3>\n <span class='http_method'>\n <a href='#!/";if(d=g.resourceName){d=d.call(n,{hash:{},data:l})}else{d=n.resourceName;d=typeof d===i?d.apply(n):d}j+=k(d)+"/";if(d=g.nickname){d=d.call(n,{hash:{},data:l})}else{d=n.nickname;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.method){d=d.call(n,{hash:{},data:l})}else{d=n.method;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.number){d=d.call(n,{hash:{},data:l})}else{d=n.number;d=typeof d===i?d.apply(n):d}j+=k(d)+'\' class="toggleOperation">';if(d=g.method){d=d.call(n,{hash:{},data:l})}else{d=n.method;d=typeof d===i?d.apply(n):d}j+=k(d)+"</a>\n </span>\n <span class='path'>\n <a href='#!/";if(d=g.resourceName){d=d.call(n,{hash:{},data:l})}else{d=n.resourceName;d=typeof d===i?d.apply(n):d}j+=k(d)+"/";if(d=g.nickname){d=d.call(n,{hash:{},data:l})}else{d=n.nickname;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.method){d=d.call(n,{hash:{},data:l})}else{d=n.method;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.number){d=d.call(n,{hash:{},data:l})}else{d=n.number;d=typeof d===i?d.apply(n):d}j+=k(d)+'\' class="toggleOperation">';if(d=g.path){d=d.call(n,{hash:{},data:l})}else{d=n.path;d=typeof d===i?d.apply(n):d}j+=k(d)+"</a>\n </span>\n </h3>\n <ul class='options'>\n <li>\n <a href='#!/";if(d=g.resourceName){d=d.call(n,{hash:{},data:l})}else{d=n.resourceName;d=typeof d===i?d.apply(n):d}j+=k(d)+"/";if(d=g.nickname){d=d.call(n,{hash:{},data:l})}else{d=n.nickname;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.method){d=d.call(n,{hash:{},data:l})}else{d=n.method;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.number){d=d.call(n,{hash:{},data:l})}else{d=n.number;d=typeof d===i?d.apply(n):d}j+=k(d)+'\' class="toggleOperation">';if(d=g.summary){d=d.call(n,{hash:{},data:l})}else{d=n.summary;d=typeof d===i?d.apply(n):d}if(d||d===0){j+=d}j+="</a>\n </li>\n </ul>\n </div>\n <div class='content' id='";if(d=g.resourceName){d=d.call(n,{hash:{},data:l})}else{d=n.resourceName;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.nickname){d=d.call(n,{hash:{},data:l})}else{d=n.nickname;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.method){d=d.call(n,{hash:{},data:l})}else{d=n.method;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.number){d=d.call(n,{hash:{},data:l})}else{d=n.number;d=typeof d===i?d.apply(n):d}j+=k(d)+"_content' style='display:none'>\n ";d=g["if"].call(n,n.notes,{hash:{},inverse:r.noop,fn:r.program(1,f,l),data:l});if(d||d===0){j+=d}j+="\n ";d=g["if"].call(n,n.type,{hash:{},inverse:r.noop,fn:r.program(3,c,l),data:l});if(d||d===0){j+=d}j+="\n <form accept-charset='UTF-8' class='sandbox'>\n <div style='margin:0;padding:0;display:inline'></div>\n ";d=g["if"].call(n,n.parameters,{hash:{},inverse:r.noop,fn:r.program(5,q,l),data:l});if(d||d===0){j+=d}j+="\n ";d=g["if"].call(n,n.responseMessages,{hash:{},inverse:r.noop,fn:r.program(7,p,l),data:l});if(d||d===0){j+=d}j+="\n ";d=g["if"].call(n,n.isReadOnly,{hash:{},inverse:r.program(11,e,l),fn:r.program(9,o,l),data:l});if(d||d===0){j+=d}j+="\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";return j})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(f,q,o,j,s){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);s=s||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(x,w){var u="",v;u+="\n ";v=o["if"].call(x,x.isFile,{hash:{},inverse:n.program(4,k,w),fn:n.program(2,l,w),data:w});if(v||v===0){u+=v}u+="\n ";return u}function l(x,w){var u="",v;u+='\n <input type="file" name=\'';if(v=o.name){v=v.call(x,{hash:{},data:w})}else{v=x.name;v=typeof v===d?v.apply(x):v}u+=c(v)+'\'/>\n <div class="parameter-content-type" />\n ';return u}function k(x,w){var u="",v;u+="\n ";v=o["if"].call(x,x.defaultValue,{hash:{},inverse:n.program(7,h,w),fn:n.program(5,i,w),data:w});if(v||v===0){u+=v}u+="\n ";return u}function i(x,w){var u="",v;u+="\n <textarea class='body-textarea' name='";if(v=o.name){v=v.call(x,{hash:{},data:w})}else{v=x.name;v=typeof v===d?v.apply(x):v}u+=c(v)+"'>";if(v=o.defaultValue){v=v.call(x,{hash:{},data:w})}else{v=x.defaultValue;v=typeof v===d?v.apply(x):v}u+=c(v)+"</textarea>\n ";return u}function h(x,w){var u="",v;u+="\n <textarea class='body-textarea' name='";if(v=o.name){v=v.call(x,{hash:{},data:w})}else{v=x.name;v=typeof v===d?v.apply(x):v}u+=c(v)+'\'></textarea>\n <br />\n <div class="parameter-content-type" />\n ';return u}function e(x,w){var u="",v;u+="\n ";v=o["if"].call(x,x.defaultValue,{hash:{},inverse:n.program(12,r,w),fn:n.program(10,t,w),data:w});if(v||v===0){u+=v}u+="\n ";return u}function t(x,w){var u="",v;u+="\n <input class='parameter' minlength='0' name='";if(v=o.name){v=v.call(x,{hash:{},data:w})}else{v=x.name;v=typeof v===d?v.apply(x):v}u+=c(v)+"' placeholder='' type='text' value='";if(v=o.defaultValue){v=v.call(x,{hash:{},data:w})}else{v=x.defaultValue;v=typeof v===d?v.apply(x):v}u+=c(v)+"'/>\n ";return u}function r(x,w){var u="",v;u+="\n <input class='parameter' minlength='0' name='";if(v=o.name){v=v.call(x,{hash:{},data:w})}else{v=x.name;v=typeof v===d?v.apply(x):v}u+=c(v)+"' placeholder='' type='text' value=''/>\n ";return u}p+="<td class='code'>";if(g=o.name){g=g.call(q,{hash:{},data:s})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"</td>\n<td>\n\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,s),fn:n.program(1,m,s),data:s});if(g||g===0){p+=g}p+="\n\n</td>\n<td>";if(g=o.description){g=g.call(q,{hash:{},data:s})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="</td>\n<td>";if(g=o.paramType){g=g.call(q,{hash:{},data:s})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='</td>\n<td>\n <span class="model-signature"></span>\n</td>\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(g,r,p,l,w){this.compilerInfo=[4,">= 1.0.0"];p=this.merge(p,g.helpers);w=w||{};var q="",i,e,o=this,d="function",c=this.escapeExpression;function n(y,x){return" multiple='multiple'"}function m(y,x){return"\n "}function k(A,z){var x="",y;x+="\n ";y=p["if"].call(A,A.defaultValue,{hash:{},inverse:o.program(8,h,z),fn:o.program(6,j,z),data:z});if(y||y===0){x+=y}x+="\n ";return x}function j(y,x){return"\n "}function h(A,z){var x="",y;x+="\n ";y=p["if"].call(A,A.allowMultiple,{hash:{},inverse:o.program(11,v,z),fn:o.program(9,f,z),data:z});if(y||y===0){x+=y}x+="\n ";return x}function f(y,x){return"\n "}function v(y,x){return"\n <option selected=\"\" value=''></option>\n "}function u(A,z){var x="",y;x+="\n ";y=p["if"].call(A,A.isDefault,{hash:{},inverse:o.program(16,s,z),fn:o.program(14,t,z),data:z});if(y||y===0){x+=y}x+="\n ";return x}function t(A,z){var x="",y;x+='\n <option selected="" value=\'';if(y=p.value){y=y.call(A,{hash:{},data:z})}else{y=A.value;y=typeof y===d?y.apply(A):y}x+=c(y)+"'>";if(y=p.value){y=y.call(A,{hash:{},data:z})}else{y=A.value;y=typeof y===d?y.apply(A):y}x+=c(y)+" (default)</option>\n ";return x}function s(A,z){var x="",y;x+="\n <option value='";if(y=p.value){y=y.call(A,{hash:{},data:z})}else{y=A.value;y=typeof y===d?y.apply(A):y}x+=c(y)+"'>";if(y=p.value){y=y.call(A,{hash:{},data:z})}else{y=A.value;y=typeof y===d?y.apply(A):y}x+=c(y)+"</option>\n ";return x}q+="<td class='code'>";if(i=p.name){i=i.call(r,{hash:{},data:w})}else{i=r.name;i=typeof i===d?i.apply(r):i}q+=c(i)+"</td>\n<td>\n <select ";i=p["if"].call(r,r.allowMultiple,{hash:{},inverse:o.noop,fn:o.program(1,n,w),data:w});if(i||i===0){q+=i}q+=" class='parameter' name='";if(i=p.name){i=i.call(r,{hash:{},data:w})}else{i=r.name;i=typeof i===d?i.apply(r):i}q+=c(i)+"'>\n ";i=p["if"].call(r,r.required,{hash:{},inverse:o.program(5,k,w),fn:o.program(3,m,w),data:w});if(i||i===0){q+=i}q+="\n ";e=p.each.call(r,((i=r.allowableValues),i==null||i===false?i:i.descriptiveValues),{hash:{},inverse:o.noop,fn:o.program(13,u,w),data:w});if(e||e===0){q+=e}q+="\n </select>\n</td>\n<td>";if(e=p.description){e=e.call(r,{hash:{},data:w})}else{e=r.description;e=typeof e===d?e.apply(r):e}if(e||e===0){q+=e}q+="</td>\n<td>";if(e=p.paramType){e=e.call(r,{hash:{},data:w})}else{e=r.paramType;e=typeof e===d?e.apply(r):e}if(e||e===0){q+=e}q+='</td>\n<td><span class="model-signature"></span></td>';return q})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n <textarea class='body-textarea' readonly='readonly' name='";if(r=f.name){r=r.call(t,{hash:{},data:s})}else{r=t.name;r=typeof r===h?r.apply(t):r}q+=j(r)+"'>";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"</textarea>\n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t.defaultValue,{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="<td class='code'>";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"</td>\n<td>\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n</td>\n<td>";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="</td>\n<td>";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='</td>\n<td><span class="model-signature"></span></td>\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n <textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='";if(r=f.name){r=r.call(t,{hash:{},data:s})}else{r=t.name;r=typeof r===h?r.apply(t):r}q+=j(r)+"'>";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"</textarea>\n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t.defaultValue,{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="<td class='code required'>";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"</td>\n<td>\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n</td>\n<td>";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="</td>\n<td>";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='</td>\n<td><span class="model-signature"></span></td>\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(f,q,o,j,u){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);u=u||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(4,k,y),fn:n.program(2,l,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function l(z,y){var w="",x;w+='\n <input type="file" name=\'';if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"'/>\n ";return w}function k(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.defaultValue,{hash:{},inverse:n.program(7,h,y),fn:n.program(5,i,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function i(z,y){var w="",x;w+="\n <textarea class='body-textarea' placeholder='(required)' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"'>";if(x=o.defaultValue){x=x.call(z,{hash:{},data:y})}else{x=z.defaultValue;x=typeof x===d?x.apply(z):x}w+=c(x)+"</textarea>\n ";return w}function h(z,y){var w="",x;w+="\n <textarea class='body-textarea' placeholder='(required)' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+'\'></textarea>\n <br />\n <div class="parameter-content-type" />\n ';return w}function e(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(12,t,y),fn:n.program(10,v,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function v(z,y){var w="",x;w+="\n <input class='parameter' class='required' type='file' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"'/>\n ";return w}function t(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.defaultValue,{hash:{},inverse:n.program(15,r,y),fn:n.program(13,s,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function s(z,y){var w="",x;w+="\n <input class='parameter required' minlength='1' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"' placeholder='(required)' type='text' value='";if(x=o.defaultValue){x=x.call(z,{hash:{},data:y})}else{x=z.defaultValue;x=typeof x===d?x.apply(z):x}w+=c(x)+"'/>\n ";return w}function r(z,y){var w="",x;w+="\n <input class='parameter required' minlength='1' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"' placeholder='(required)' type='text' value=''/>\n ";return w}p+="<td class='code required'>";if(g=o.name){g=g.call(q,{hash:{},data:u})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"</td>\n<td>\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,u),fn:n.program(1,m,u),data:u});if(g||g===0){p+=g}p+="\n</td>\n<td>\n <strong>";if(g=o.description){g=g.call(q,{hash:{},data:u})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="</strong>\n</td>\n<td>";if(g=o.paramType){g=g.call(q,{hash:{},data:u})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='</td>\n<td><span class="model-signature"></span></td>\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.parameter_content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.consumes,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n <option value="';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+='">';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+="</option>\n ";return o}function n(p,o){return'\n <option value="application/json">application/json</option>\n'}i+='<label for="parameterContentType"></label>\n<select name="parameterContentType">\n';c=f["if"].call(l,l.consumes,{hash:{},inverse:m.program(4,n,j),fn:m.program(1,e,j),data:j});if(c||c===0){i+=c}i+="\n</select>\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.resource=b(function(f,l,e,k,j){this.compilerInfo=[4,">= 1.0.0"];e=this.merge(e,f.helpers);j=j||{};var h="",c,o,g="function",i=this.escapeExpression,n=this,m=e.blockHelperMissing;function d(q,p){return" : "}h+="<div class='heading'>\n <h2>\n <a href='#!/";if(c=e.name){c=c.call(l,{hash:{},data:j})}else{c=l.name;c=typeof c===g?c.apply(l):c}h+=i(c)+"' onclick=\"Docs.toggleEndpointListForResource('";if(c=e.name){c=c.call(l,{hash:{},data:j})}else{c=l.name;c=typeof c===g?c.apply(l):c}h+=i(c)+"');\">";if(c=e.name){c=c.call(l,{hash:{},data:j})}else{c=l.name;c=typeof c===g?c.apply(l):c}h+=i(c)+"</a> ";o={hash:{},inverse:n.noop,fn:n.program(1,d,j),data:j};if(c=e.description){c=c.call(l,o)}else{c=l.description;c=typeof c===g?c.apply(l):c}if(!e.description){c=m.call(l,c,o)}if(c||c===0){h+=c}if(c=e.description){c=c.call(l,{hash:{},data:j})}else{c=l.description;c=typeof c===g?c.apply(l):c}if(c||c===0){h+=c}h+="\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/";if(c=e.name){c=c.call(l,{hash:{},data:j})}else{c=l.name;c=typeof c===g?c.apply(l):c}h+=i(c)+"' id='endpointListTogger_";if(c=e.name){c=c.call(l,{hash:{},data:j})}else{c=l.name;c=typeof c===g?c.apply(l):c}h+=i(c)+"'\n onclick=\"Docs.toggleEndpointListForResource('";if(c=e.name){c=c.call(l,{hash:{},data:j})}else{c=l.name;c=typeof c===g?c.apply(l):c}h+=i(c)+"');\">Show/Hide</a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.collapseOperationsForResource('";if(c=e.name){c=c.call(l,{hash:{},data:j})}else{c=l.name;c=typeof c===g?c.apply(l):c}h+=i(c)+"'); return false;\">\n List Operations\n </a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.expandOperationsForResource('";if(c=e.name){c=c.call(l,{hash:{},data:j})}else{c=l.name;c=typeof c===g?c.apply(l):c}h+=i(c)+"'); return false;\">\n Expand Operations\n </a>\n </li>\n <li>\n <a href='";if(c=e.url){c=c.call(l,{hash:{},data:j})}else{c=l.url;c=typeof c===g?c.apply(l):c}h+=i(c)+"'>Raw</a>\n </li>\n </ul>\n</div>\n<ul class='endpoints' id='";if(c=e.name){c=c.call(l,{hash:{},data:j})}else{c=l.name;c=typeof c===g?c.apply(l):c}h+=i(c)+"_endpoint_list' style='display:none'>\n\n</ul>\n";return h})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.response_content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.produces,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n <option value="';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+='">';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+="</option>\n ";return o}function n(p,o){return'\n <option value="application/json">application/json</option>\n'}i+='<label for="responseContentType"></label>\n<select name="responseContentType">\n';c=f["if"].call(l,l.produces,{hash:{},inverse:m.program(4,n,j),fn:m.program(1,e,j),data:j});if(c||c===0){i+=c}i+="\n</select>\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.signature=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+='<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 ';if(c=d.signature){c=c.call(k,{hash:{},data:i})}else{c=k.signature;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+='\n </div>\n\n <div class="snippet">\n <pre><code>';if(c=d.sampleJSON){c=c.call(k,{hash:{},data:i})}else{c=k.sampleJSON;c=typeof c===f?c.apply(k):c}g+=h(c)+'</code></pre>\n <small class="notice"></small>\n </div>\n</div>\n\n';return g})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.status_code=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+="<td width='15%' class='code'>";if(c=d.code){c=c.call(k,{hash:{},data:i})}else{c=k.code;c=typeof c===f?c.apply(k):c}g+=h(c)+"</td>\n<td>";if(c=d.message){c=c.call(k,{hash:{},data:i})}else{c=k.message;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+="</td>\n";return g})})();(function(){var j,r,u,o,l,k,n,m,i,p,s,q,h,c,g,f,e,d,b,a,x,w,t={}.hasOwnProperty,v=function(B,z){for(var y in z){if(t.call(z,y)){B[y]=z[y]}}function A(){this.constructor=B}A.prototype=z.prototype;B.prototype=new A();B.__super__=z.prototype;return B};s=(function(z){v(y,z);function y(){q=y.__super__.constructor.apply(this,arguments);return q}y.prototype.dom_id="swagger_ui";y.prototype.options=null;y.prototype.api=null;y.prototype.headerView=null;y.prototype.mainView=null;y.prototype.initialize=function(A){var B=this;if(A==null){A={}}if(A.dom_id!=null){this.dom_id=A.dom_id;delete A.dom_id}if($("#"+this.dom_id)==null){$("body").append('<div id="'+this.dom_id+'"></div>')}this.options=A;this.options.success=function(){return B.render()};this.options.progress=function(C){return B.showMessage(C)};this.options.failure=function(C){return B.onLoadFailure(C)};this.headerView=new r({el:$("#header")});return this.headerView.on("update-swagger-ui",function(C){return B.updateSwaggerUi(C)})};y.prototype.updateSwaggerUi=function(A){this.options.url=A.url;return this.load()};y.prototype.load=function(){var B,A;if((A=this.mainView)!=null){A.clear()}B=this.options.url;if(B.indexOf("http")!==0){B=this.buildUrl(window.location.href.toString(),B)}this.options.url=B;this.headerView.update(B);this.api=new SwaggerApi(this.options);this.api.build();return this.api};y.prototype.render=function(){var A=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new u({model:this.api,el:$("#"+this.dom_id)}).render();this.showMessage();switch(this.options.docExpansion){case"full":Docs.expandOperationsForResource("");break;case"list":Docs.collapseOperationsForResource("")}if(this.options.onComplete){this.options.onComplete(this.api,this)}return setTimeout(function(){return Docs.shebang()},400)};y.prototype.buildUrl=function(C,A){var B,D;log("base is "+C);if(A.indexOf("/")===0){D=C.split("/");C=D[0]+"//"+D[2];return C+A}else{B=C.length;if(C.indexOf("?")>-1){B=Math.min(B,C.indexOf("?"))}if(C.indexOf("#")>-1){B=Math.min(B,C.indexOf("#"))}C=C.substring(0,B);if(C.indexOf("/",C.length-1)!==-1){return C+A}return C+"/"+A}};y.prototype.showMessage=function(A){if(A==null){A=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(A)};y.prototype.onLoadFailure=function(A){var B;if(A==null){A=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");B=$("#message-bar").html(A);if(this.options.onFailure!=null){this.options.onFailure(A)}return B};return y})(Backbone.Router);window.SwaggerUi=s;r=(function(z){v(y,z);function y(){h=y.__super__.constructor.apply(this,arguments);return h}y.prototype.events={"click #show-pet-store-icon":"showPetStore","click #show-wordnik-dev-icon":"showWordnikDev","click #explore":"showCustom","keyup #input_baseUrl":"showCustomOnKeyup","keyup #input_apiKey":"showCustomOnKeyup"};y.prototype.initialize=function(){};y.prototype.showPetStore=function(A){return this.trigger("update-swagger-ui",{url:"http://petstore.swagger.wordnik.com/api/api-docs"})};y.prototype.showWordnikDev=function(A){return this.trigger("update-swagger-ui",{url:"http://api.wordnik.com/v4/resources.json"})};y.prototype.showCustomOnKeyup=function(A){if(A.keyCode===13){return this.showCustom()}};y.prototype.showCustom=function(A){if(A!=null){A.preventDefault()}return this.trigger("update-swagger-ui",{url:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};y.prototype.update=function(B,C,A){if(A==null){A=false}$("#input_baseUrl").val(B);if(A){return this.trigger("update-swagger-ui",{url:B})}};return y})(Backbone.View);u=(function(y){v(z,y);function z(){g=z.__super__.constructor.apply(this,arguments);return g}z.prototype.initialize=function(){};z.prototype.render=function(){var C,B,A,D;$(this.el).html(Handlebars.templates.main(this.model));D=this.model.apisArray;for(B=0,A=D.length;B<A;B++){C=D[B];this.addResource(C)}return this};z.prototype.addResource=function(B){var A;A=new n({model:B,tagName:"li",id:"resource_"+B.name,className:"resource"});return $("#resources").append(A.render().el)};z.prototype.clear=function(){return $(this.el).html("")};return z})(Backbone.View);n=(function(z){v(y,z);function y(){f=y.__super__.constructor.apply(this,arguments);return f}y.prototype.initialize=function(){};y.prototype.render=function(){var B,C,A,D;$(this.el).html(Handlebars.templates.resource(this.model));this.number=0;D=this.model.operationsArray;for(C=0,A=D.length;C<A;C++){B=D[C];this.addOperation(B)}return this};y.prototype.addOperation=function(A){var B;A.number=this.number;B=new o({model:A,tagName:"li",className:"endpoint"});$(".endpoints",$(this.el)).append(B.render().el);return this.number++};return y})(Backbone.View);o=(function(z){v(y,z);function y(){e=y.__super__.constructor.apply(this,arguments);return e}y.prototype.invocationUrl=null;y.prototype.events={"submit .sandbox":"submitOperation","click .submit":"submitOperation","click .response_hider":"hideResponse","click .toggleOperation":"toggleOperationContent"};y.prototype.initialize=function(){};y.prototype.render=function(){var A,P,G,M,K,Q,L,N,J,I,H,O,E,C,F,D,B;P=true;if(!P){this.model.isReadOnly=true}$(this.el).html(Handlebars.templates.operation(this.model));if(this.model.responseClassSignature&&this.model.responseClassSignature!=="string"){Q={sampleJSON:this.model.responseSampleJSON,isParam:false,signature:this.model.responseClassSignature};K=new i({model:Q,tagName:"div"});$(".model-signature",$(this.el)).append(K.render().el)}else{$(".model-signature",$(this.el)).html(this.model.type)}A={isParam:false};A.consumes=this.model.consumes;A.produces=this.model.produces;F=this.model.parameters;for(J=0,O=F.length;J<O;J++){G=F[J];N=G.type||G.dataType;if(N.toLowerCase()==="file"){if(!A.consumes){log("set content type ");A.consumes="multipart/form-data"}}}M=new m({model:A});$(".response-content-type",$(this.el)).append(M.render().el);D=this.model.parameters;for(I=0,E=D.length;I<E;I++){G=D[I];this.addParameter(G,A.consumes)}B=this.model.responseMessages;for(H=0,C=B.length;H<C;H++){L=B[H];this.addStatusCode(L)}return this};y.prototype.addParameter=function(C,A){var B;C.consumes=A;B=new k({model:C,tagName:"tr",readOnly:this.model.isReadOnly});return $(".operation-params",$(this.el)).append(B.render().el)};y.prototype.addStatusCode=function(B){var A;A=new p({model:B,tagName:"tr"});return $(".operation-status",$(this.el)).append(A.render().el)};y.prototype.submitOperation=function(O){var Q,G,N,D,I,A,J,M,L,K,P,F,C,H,E,B;if(O!=null){O.preventDefault()}G=$(".sandbox",$(this.el));Q=true;G.find("input.required").each(function(){var R=this;$(this).removeClass("error");if(jQuery.trim($(this).val())===""){$(this).addClass("error");$(this).wiggle({callback:function(){return $(R).focus()}});return Q=false}});if(Q){D={};A={parent:this};N=false;H=G.find("input");for(M=0,P=H.length;M<P;M++){I=H[M];if((I.value!=null)&&jQuery.trim(I.value).length>0){D[I.name]=I.value}if(I.type==="file"){N=true}}E=G.find("textarea");for(L=0,F=E.length;L<F;L++){I=E[L];if((I.value!=null)&&jQuery.trim(I.value).length>0){D.body=I.value}}B=G.find("select");for(K=0,C=B.length;K<C;K++){I=B[K];J=this.getSelectedValue(I);if((J!=null)&&jQuery.trim(J).length>0){D[I.name]=J}}A.responseContentType=$("div select[name=responseContentType]",$(this.el)).val();A.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val();$(".response_throbber",$(this.el)).show();if(N){return this.handleFileUpload(D,G)}else{return this.model["do"](D,A,this.showCompleteStatus,this.showErrorStatus,this)}}};y.prototype.success=function(A,B){return B.showCompleteStatus(A)};y.prototype.handleFileUpload=function(Q,I){var M,H,C,N,L,K,J,G,E,D,P,T,S,R,F,B,A,U,O=this;log("it's a file upload");F=I.serializeArray();for(J=0,P=F.length;J<P;J++){N=F[J];if((N.value!=null)&&jQuery.trim(N.value).length>0){Q[N.name]=N.value}}M=new FormData();B=this.model.parameters;for(G=0,T=B.length;G<T;G++){K=B[G];if(K.paramType==="form"){M.append(K.name,Q[K.name])}}C={};A=this.model.parameters;for(E=0,S=A.length;E<S;E++){K=A[E];if(K.paramType==="header"){C[K.name]=Q[K.name]}}log(C);U=I.find('input[type~="file"]');for(D=0,R=U.length;D<R;D++){H=U[D];M.append($(H).attr("name"),H.files[0])}log(M);this.invocationUrl=this.model.supportHeaderParams()?(C=this.model.getHeaderParams(Q),this.model.urlify(Q,false)):this.model.urlify(Q,true);$(".request_url",$(this.el)).html("<pre>"+this.invocationUrl+"</pre>");L={type:this.model.method,url:this.invocationUrl,headers:C,data:M,dataType:"json",contentType:false,processData:false,error:function(W,X,V){return O.showErrorStatus(O.wrap(W),O)},success:function(V){return O.showResponse(V,O)},complete:function(V){return O.showCompleteStatus(O.wrap(V),O)}};if(window.authorizations){window.authorizations.apply(L)}jQuery.ajax(L);return false};y.prototype.wrap=function(A){var B,C=this;B={};B.content={};B.content.data=A.responseText;B.getHeaders=function(){return{"Content-Type":A.headers("Content-Type")}};B.request={};B.request.url=this.invocationUrl;B.status=A.status;return B};y.prototype.getSelectedValue=function(A){var D,C,F,B,E;if(!A.multiple){return A.value}else{C=[];E=A.options;for(F=0,B=E.length;F<B;F++){D=E[F];if(D.selected){C.push(D.value)}}if(C.length>0){return C.join(",")}else{return null}}};y.prototype.hideResponse=function(A){if(A!=null){A.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};y.prototype.showResponse=function(A){var B;B=JSON.stringify(A,null,"\t").replace(/\n/g,"<br>");return $(".response_body",$(this.el)).html(escape(B))};y.prototype.showErrorStatus=function(B,A){return A.showStatus(B)};y.prototype.showCompleteStatus=function(B,A){return A.showStatus(B)};y.prototype.formatXml=function(H){var D,G,B,I,N,J,C,A,L,M,F,E,K;A=/(>)(<)(\/*)/g;M=/[ ]*(.*)[ ]+\n/g;D=/(<.+>)(.+\n)/g;H=H.replace(A,"$1\n$2$3").replace(M,"$1\n").replace(D,"$1\n$2");C=0;G="";N=H.split("\n");B=0;I="other";L={"single->single":0,"single->closing":-1,"single->opening":0,"single->other":0,"closing->single":0,"closing->closing":-1,"closing->opening":0,"closing->other":0,"opening->single":1,"opening->closing":0,"opening->opening":1,"opening->other":1,"other->single":0,"other->closing":-1,"other->opening":0,"other->other":0};F=function(T){var P,O,R,V,S,Q,U;Q={single:Boolean(T.match(/<.+\/>/)),closing:Boolean(T.match(/<\/.+>/)),opening:Boolean(T.match(/<[^!?].*>/))};S=((function(){var W;W=[];for(R in Q){U=Q[R];if(U){W.push(R)}}return W})())[0];S=S===void 0?"other":S;P=I+"->"+S;I=S;V="";B+=L[P];V=((function(){var X,Y,W;W=[];for(O=X=0,Y=B;0<=Y?X<Y:X>Y;O=0<=Y?++X:--X){W.push(" ")}return W})()).join("");if(P==="opening->closing"){return G=G.substr(0,G.length-1)+T+"\n"}else{return G+=V+T+"\n"}};for(E=0,K=N.length;E<K;E++){J=N[E];F(J)}return G};y.prototype.showStatus=function(A){var D,C,G,F,E,B;C=A.data;F=A.headers;G=F["Content-Type"]?F["Content-Type"].split(";")[0].trim():null;if(!C){D=$("<code />").text("no content");E=$('<pre class="json" />').append(D)}else{if(G==="application/json"||/\+json$/.test(G)){D=$("<code />").text(JSON.stringify(JSON.parse(C),null," "));E=$('<pre class="json" />').append(D)}else{if(G==="application/xml"||/\+xml$/.test(G)){D=$("<code />").text(this.formatXml(C));E=$('<pre class="xml" />').append(D)}else{if(G==="text/html"){D=$("<code />").html(C);E=$('<pre class="xml" />').append(D)}else{if(/^image\//.test(G)){E=$("<img>").attr("src",A.url)}else{D=$("<code />").text(C);E=$('<pre class="json" />').append(D)}}}}}B=E;$(".request_url",$(this.el)).html("<pre>"+A.url+"</pre>");$(".response_code",$(this.el)).html("<pre>"+A.status+"</pre>");$(".response_body",$(this.el)).html(B);$(".response_headers",$(this.el)).html("<pre>"+JSON.stringify(A.headers,null," ").replace(/\n/g,"<br>")+"</pre>");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();return hljs.highlightBlock($(".response_body",$(this.el))[0])};y.prototype.toggleOperationContent=function(){var A;A=$("#"+Docs.escapeResourceName(this.model.resourceName)+"_"+this.model.nickname+"_"+this.model.method+"_"+this.model.number+"_content");if(A.is(":visible")){return Docs.collapseOperation(A)}else{return Docs.expandOperation(A)}};return y})(Backbone.View);p=(function(z){v(y,z);function y(){d=y.__super__.constructor.apply(this,arguments);return d}y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));return this};y.prototype.template=function(){return Handlebars.templates.status_code};return y})(Backbone.View);k=(function(z){v(y,z);function y(){b=y.__super__.constructor.apply(this,arguments);return b}y.prototype.initialize=function(){};y.prototype.render=function(){var G,A,C,F,B,H,E,D;D=this.model.type||this.model.dataType;if(this.model.paramType==="body"){this.model.isBody=true}if(D.toLowerCase()==="file"){this.model.isFile=true}E=this.template();$(this.el).html(E(this.model));B={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){H=new i({model:B,tagName:"div"});$(".model-signature",$(this.el)).append(H.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}A=false;if(this.model.isBody){A=true}G={isParam:A};G.consumes=this.model.consumes;if(A){C=new l({model:G});$(".parameter-content-type",$(this.el)).append(C.render().el)}else{F=new m({model:G});$(".response-content-type",$(this.el)).append(F.render().el)}return this};y.prototype.template=function(){if(this.model.isList){return Handlebars.templates.param_list}else{if(this.options.readOnly){if(this.model.required){return Handlebars.templates.param_readonly_required}else{return Handlebars.templates.param_readonly}}else{if(this.model.required){return Handlebars.templates.param_required}else{return Handlebars.templates.param}}}};return y})(Backbone.View);i=(function(z){v(y,z);function y(){a=y.__super__.constructor.apply(this,arguments);return a}y.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));this.switchToDescription();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};y.prototype.template=function(){return Handlebars.templates.signature};y.prototype.switchToDescription=function(A){if(A!=null){A.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};y.prototype.switchToSnippet=function(A){if(A!=null){A.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};y.prototype.snippetToTextArea=function(A){var B;if(this.isParam){if(A!=null){A.preventDefault()}B=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(B.val())===""){return B.val(this.model.sampleJSON)}}};return y})(Backbone.View);j=(function(y){v(z,y);function z(){x=z.__super__.constructor.apply(this,arguments);return x}z.prototype.initialize=function(){};z.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=contentType]",$(this.el)).text("Response Content Type");return this};z.prototype.template=function(){return Handlebars.templates.content_type};return z})(Backbone.View);m=(function(y){v(z,y);function z(){w=z.__super__.constructor.apply(this,arguments);return w}z.prototype.initialize=function(){};z.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=responseContentType]",$(this.el)).text("Response Content Type");return this};z.prototype.template=function(){return Handlebars.templates.response_content_type};return z})(Backbone.View);l=(function(z){v(y,z);function y(){c=y.__super__.constructor.apply(this,arguments);return c}y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:");return this};y.prototype.template=function(){return Handlebars.templates.parameter_content_type};return y})(Backbone.View)}).call(this);
1
+ $(function(){$.fn.vAlign=function(){return this.each(function(c){var a=$(this).height();var d=$(this).parent().height();var b=(d-a)/2;$(this).css("margin-top",b)})};$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(b){var d=$(this).closest("form").innerWidth();var c=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10);var a=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",d-c-a)})};$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent();$("ul.downplayed li div.content p").vAlign();$("form.sandbox").submit(function(){var a=true;$(this).find("input.required").each(function(){$(this).removeClass("error");if($(this).val()==""){$(this).addClass("error");$(this).wiggle();a=false}});return a})});function clippyCopiedCallback(b){$("#api_key_copied").fadeIn().delay(1000).fadeOut()}log=function(){log.history=log.history||[];log.history.push(arguments);if(this.console){console.log(Array.prototype.slice.call(arguments)[0])}};if(Function.prototype.bind&&console&&typeof console.log=="object"){["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(a){console[a]=this.bind(console[a],console)},Function.prototype.call)}var Docs={shebang:function(){var b=$.param.fragment().split("/");b.shift();switch(b.length){case 1:log("shebang resource:"+b[0]);var d="resource_"+b[0];Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});break;case 2:log("shebang endpoint: "+b.join("_"));Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});var c=b.join("_");var a=c+"_content";log("li_dom_id "+c);log("li_content_dom_id "+a);Docs.expandOperation($("#"+a));$("#"+c).slideto({highlight:false});break}},toggleEndpointListForResource:function(b){var a=$("li#resource_"+Docs.escapeResourceName(b)+" ul.endpoints");if(a.is(":visible")){Docs.collapseEndpointListForResource(b)}else{Docs.expandEndpointListForResource(b)}},expandEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);if(b==""){$(".resource ul.endpoints").slideDown();return}$("li#resource_"+b).addClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideDown()},collapseEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);$("li#resource_"+b).removeClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideUp()},expandOperationsForResource:function(a){Docs.expandEndpointListForResource(a);if(a==""){$(".resource ul.endpoints li.operation div.content").slideDown();return}$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(a){Docs.expandEndpointListForResource(a);$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(a){return a.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g,"\\$&")},expandOperation:function(a){a.slideDown()},collapseOperation:function(a){a.slideUp()}};(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.produces,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n <option value="';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+='">';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+="</option>\n ";return o}function n(p,o){return'\n <option value="application/json">application/json</option>\n'}i+='<label for="contentType"></label>\n<select name="contentType">\n';c=f["if"].call(l,l.produces,{hash:{},inverse:m.program(4,n,j),fn:m.program(1,e,j),data:j});if(c||c===0){i+=c}i+="\n</select>\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.main=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",c,h="function",j=this.escapeExpression,p=this;function e(v,u){var r="",t,s;r+='\n <div class="info_title">'+j(((t=((t=v.info),t==null||t===false?t:t.title)),typeof t===h?t.apply(v):t))+'</div>\n <div class="info_description">';s=((t=((t=v.info),t==null||t===false?t:t.description)),typeof t===h?t.apply(v):t);if(s||s===0){r+=s}r+="</div>\n ";s=f["if"].call(v,((t=v.info),t==null||t===false?t:t.termsOfServiceUrl),{hash:{},inverse:p.noop,fn:p.program(2,d,u),data:u});if(s||s===0){r+=s}r+="\n ";s=f["if"].call(v,((t=v.info),t==null||t===false?t:t.contact),{hash:{},inverse:p.noop,fn:p.program(4,q,u),data:u});if(s||s===0){r+=s}r+="\n ";s=f["if"].call(v,((t=v.info),t==null||t===false?t:t.license),{hash:{},inverse:p.noop,fn:p.program(6,o,u),data:u});if(s||s===0){r+=s}r+="\n ";return r}function d(u,t){var r="",s;r+='<div class="info_tos"><a href="'+j(((s=((s=u.info),s==null||s===false?s:s.termsOfServiceUrl)),typeof s===h?s.apply(u):s))+'">Terms of service</a></div>';return r}function q(u,t){var r="",s;r+="<div class='info_contact'><a href=\"mailto:"+j(((s=((s=u.info),s==null||s===false?s:s.contact)),typeof s===h?s.apply(u):s))+'">Contact the developer</a></div>';return r}function o(u,t){var r="",s;r+="<div class='info_license'><a href='"+j(((s=((s=u.info),s==null||s===false?s:s.licenseUrl)),typeof s===h?s.apply(u):s))+"'>"+j(((s=((s=u.info),s==null||s===false?s:s.license)),typeof s===h?s.apply(u):s))+"</a></div>";return r}function n(u,t){var r="",s;r+='\n , <span style="font-variant: small-caps">api version</span>: ';if(s=f.apiVersion){s=s.call(u,{hash:{},data:t})}else{s=u.apiVersion;s=typeof s===h?s.apply(u):s}r+=j(s)+"\n ";return r}i+="<div class='info' id='api_info'>\n ";c=f["if"].call(m,m.info,{hash:{},inverse:p.noop,fn:p.program(1,e,k),data:k});if(c||c===0){i+=c}i+="\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>: ";if(c=f.basePath){c=c.call(m,{hash:{},data:k})}else{c=m.basePath;c=typeof c===h?c.apply(m):c}i+=j(c)+"\n ";c=f["if"].call(m,m.apiVersion,{hash:{},inverse:p.noop,fn:p.program(8,n,k),data:k});if(c||c===0){i+=c}i+="]</h4>\n </div>\n</div>\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(g,s,q,m,y){this.compilerInfo=[4,">= 1.0.0"];q=this.merge(q,g.helpers);y=y||{};var r="",i,f,e="function",d=this.escapeExpression,p=this,c=q.blockHelperMissing;function o(C,B){var z="",A;z+="\n <h4>Implementation Notes</h4>\n <p>";if(A=q.notes){A=A.call(C,{hash:{},data:B})}else{A=C.notes;A=typeof A===e?A.apply(C):A}if(A||A===0){z+=A}z+="</p>\n ";return z}function n(A,z){return'\n <div class="auth">\n <span class="api-ic ic-error"></span>'}function l(C,B){var z="",A;z+='\n <div id="api_information_panel" style="top: 526px; left: 776px; display: none;">\n ';A=q.each.call(C,C,{hash:{},inverse:p.noop,fn:p.program(6,k,B),data:B});if(A||A===0){z+=A}z+="\n </div>\n ";return z}function k(D,C){var z="",B,A;z+="\n <div title='";A=((B=D.description),typeof B===e?B.apply(D):B);if(A||A===0){z+=A}z+="'>"+d(((B=D.scope),typeof B===e?B.apply(D):B))+"</div>\n ";return z}function h(A,z){return"</div>"}function x(A,z){return'\n <div class=\'access\'>\n <span class="api-ic ic-off" title="click to authenticate"></span>\n </div>\n '}function w(A,z){return'\n <h4>Response Class</h4>\n <p><span class="model-signature" /></p>\n <br/>\n <div class="response-content-type" />\n '}function v(A,z){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 '}function u(A,z){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 "}function t(A,z){return"\n "}function j(A,z){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 "}r+="\n <ul class='operations' >\n <li class='";if(i=q.method){i=i.call(s,{hash:{},data:y})}else{i=s.method;i=typeof i===e?i.apply(s):i}r+=d(i)+" operation' id='";if(i=q.parentId){i=i.call(s,{hash:{},data:y})}else{i=s.parentId;i=typeof i===e?i.apply(s):i}r+=d(i)+"_";if(i=q.nickname){i=i.call(s,{hash:{},data:y})}else{i=s.nickname;i=typeof i===e?i.apply(s):i}r+=d(i)+"'>\n <div class='heading'>\n <h3>\n <span class='http_method'>\n <a href='#!/";if(i=q.parentId){i=i.call(s,{hash:{},data:y})}else{i=s.parentId;i=typeof i===e?i.apply(s):i}r+=d(i)+"/";if(i=q.nickname){i=i.call(s,{hash:{},data:y})}else{i=s.nickname;i=typeof i===e?i.apply(s):i}r+=d(i)+'\' class="toggleOperation">';if(i=q.method){i=i.call(s,{hash:{},data:y})}else{i=s.method;i=typeof i===e?i.apply(s):i}r+=d(i)+"</a>\n </span>\n <span class='path'>\n <a href='#!/";if(i=q.parentId){i=i.call(s,{hash:{},data:y})}else{i=s.parentId;i=typeof i===e?i.apply(s):i}r+=d(i)+"/";if(i=q.nickname){i=i.call(s,{hash:{},data:y})}else{i=s.nickname;i=typeof i===e?i.apply(s):i}r+=d(i)+'\' class="toggleOperation">';if(i=q.path){i=i.call(s,{hash:{},data:y})}else{i=s.path;i=typeof i===e?i.apply(s):i}r+=d(i)+"</a>\n </span>\n </h3>\n <ul class='options'>\n <li>\n <a href='#!/";if(i=q.parentId){i=i.call(s,{hash:{},data:y})}else{i=s.parentId;i=typeof i===e?i.apply(s):i}r+=d(i)+"/";if(i=q.nickname){i=i.call(s,{hash:{},data:y})}else{i=s.nickname;i=typeof i===e?i.apply(s):i}r+=d(i)+'\' class="toggleOperation">';if(i=q.summary){i=i.call(s,{hash:{},data:y})}else{i=s.summary;i=typeof i===e?i.apply(s):i}if(i||i===0){r+=i}r+="</a>\n </li>\n </ul>\n </div>\n <div class='content' id='";if(i=q.parentId){i=i.call(s,{hash:{},data:y})}else{i=s.parentId;i=typeof i===e?i.apply(s):i}r+=d(i)+"_";if(i=q.nickname){i=i.call(s,{hash:{},data:y})}else{i=s.nickname;i=typeof i===e?i.apply(s):i}r+=d(i)+"_content' style='display:none'>\n ";i=q["if"].call(s,s.notes,{hash:{},inverse:p.noop,fn:p.program(1,o,y),data:y});if(i||i===0){r+=i}r+="\n ";f={hash:{},inverse:p.noop,fn:p.program(3,n,y),data:y};if(i=q.oauth){i=i.call(s,f)}else{i=s.oauth;i=typeof i===e?i.apply(s):i}if(!q.oauth){i=c.call(s,i,f)}if(i||i===0){r+=i}r+="\n ";i=q.each.call(s,s.oauth,{hash:{},inverse:p.noop,fn:p.program(5,l,y),data:y});if(i||i===0){r+=i}r+="\n ";f={hash:{},inverse:p.noop,fn:p.program(8,h,y),data:y};if(i=q.oauth){i=i.call(s,f)}else{i=s.oauth;i=typeof i===e?i.apply(s):i}if(!q.oauth){i=c.call(s,i,f)}if(i||i===0){r+=i}r+="\n ";f={hash:{},inverse:p.noop,fn:p.program(10,x,y),data:y};if(i=q.oauth){i=i.call(s,f)}else{i=s.oauth;i=typeof i===e?i.apply(s):i}if(!q.oauth){i=c.call(s,i,f)}if(i||i===0){r+=i}r+="\n ";i=q["if"].call(s,s.type,{hash:{},inverse:p.noop,fn:p.program(12,w,y),data:y});if(i||i===0){r+=i}r+="\n <form accept-charset='UTF-8' class='sandbox'>\n <div style='margin:0;padding:0;display:inline'></div>\n ";i=q["if"].call(s,s.parameters,{hash:{},inverse:p.noop,fn:p.program(14,v,y),data:y});if(i||i===0){r+=i}r+="\n ";i=q["if"].call(s,s.responseMessages,{hash:{},inverse:p.noop,fn:p.program(16,u,y),data:y});if(i||i===0){r+=i}r+="\n ";i=q["if"].call(s,s.isReadOnly,{hash:{},inverse:p.program(20,j,y),fn:p.program(18,t,y),data:y});if(i||i===0){r+=i}r+="\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";return r})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(f,q,o,j,t){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);t=t||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.isFile,{hash:{},inverse:n.program(4,k,x),fn:n.program(2,l,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function l(y,x){var v="",w;v+='\n <input type="file" name=\'';if(w=o.name){w=w.call(y,{hash:{},data:x})}else{w=y.name;w=typeof w===d?w.apply(y):w}v+=c(w)+'\'/>\n <div class="parameter-content-type" />\n ';return v}function k(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.defaultValue,{hash:{},inverse:n.program(7,h,x),fn:n.program(5,i,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function i(y,x){var v="",w;v+="\n <textarea class='body-textarea' name='";if(w=o.name){w=w.call(y,{hash:{},data:x})}else{w=y.name;w=typeof w===d?w.apply(y):w}v+=c(w)+"'>";if(w=o.defaultValue){w=w.call(y,{hash:{},data:x})}else{w=y.defaultValue;w=typeof w===d?w.apply(y):w}v+=c(w)+"</textarea>\n ";return v}function h(y,x){var v="",w;v+="\n <textarea class='body-textarea' name='";if(w=o.name){w=w.call(y,{hash:{},data:x})}else{w=y.name;w=typeof w===d?w.apply(y):w}v+=c(w)+'\'></textarea>\n <br />\n <div class="parameter-content-type" />\n ';return v}function e(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.isFile,{hash:{},inverse:n.program(10,u,x),fn:n.program(2,l,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function u(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.defaultValue,{hash:{},inverse:n.program(13,r,x),fn:n.program(11,s,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function s(y,x){var v="",w;v+="\n <input class='parameter' minlength='0' name='";if(w=o.name){w=w.call(y,{hash:{},data:x})}else{w=y.name;w=typeof w===d?w.apply(y):w}v+=c(w)+"' placeholder='' type='text' value='";if(w=o.defaultValue){w=w.call(y,{hash:{},data:x})}else{w=y.defaultValue;w=typeof w===d?w.apply(y):w}v+=c(w)+"'/>\n ";return v}function r(y,x){var v="",w;v+="\n <input class='parameter' minlength='0' name='";if(w=o.name){w=w.call(y,{hash:{},data:x})}else{w=y.name;w=typeof w===d?w.apply(y):w}v+=c(w)+"' placeholder='' type='text' value=''/>\n ";return v}p+="<td class='code'>";if(g=o.name){g=g.call(q,{hash:{},data:t})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"</td>\n<td>\n\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,t),fn:n.program(1,m,t),data:t});if(g||g===0){p+=g}p+="\n\n</td>\n<td>";if(g=o.description){g=g.call(q,{hash:{},data:t})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="</td>\n<td>";if(g=o.paramType){g=g.call(q,{hash:{},data:t})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='</td>\n<td>\n <span class="model-signature"></span>\n</td>\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(h,t,r,m,y){this.compilerInfo=[4,">= 1.0.0"];r=this.merge(r,h.helpers);y=y||{};var s="",j,g,e,p=this,q=r.helperMissing,d="function",c=this.escapeExpression;function o(A,z){return" multiple='multiple'"}function n(A,z){return"\n "}function l(C,B){var z="",A;z+="\n ";A=r["if"].call(C,C.defaultValue,{hash:{},inverse:p.program(8,i,B),fn:p.program(6,k,B),data:B});if(A||A===0){z+=A}z+="\n ";return z}function k(A,z){return"\n "}function i(E,D){var z="",C,B,A;z+="\n ";A={hash:{},inverse:p.program(11,x,D),fn:p.program(9,f,D),data:D};B=((C=r.isArray||E.isArray),C?C.call(E,E,A):q.call(E,"isArray",E,A));if(B||B===0){z+=B}z+="\n ";return z}function f(A,z){return"\n "}function x(A,z){return"\n <option selected=\"\" value=''></option>\n "}function w(C,B){var z="",A;z+="\n ";A=r["if"].call(C,C.isDefault,{hash:{},inverse:p.program(16,u,B),fn:p.program(14,v,B),data:B});if(A||A===0){z+=A}z+="\n ";return z}function v(C,B){var z="",A;z+='\n <option selected="" value=\'';if(A=r.value){A=A.call(C,{hash:{},data:B})}else{A=C.value;A=typeof A===d?A.apply(C):A}z+=c(A)+"'>";if(A=r.value){A=A.call(C,{hash:{},data:B})}else{A=C.value;A=typeof A===d?A.apply(C):A}z+=c(A)+" (default)</option>\n ";return z}function u(C,B){var z="",A;z+="\n <option value='";if(A=r.value){A=A.call(C,{hash:{},data:B})}else{A=C.value;A=typeof A===d?A.apply(C):A}z+=c(A)+"'>";if(A=r.value){A=A.call(C,{hash:{},data:B})}else{A=C.value;A=typeof A===d?A.apply(C):A}z+=c(A)+"</option>\n ";return z}s+="<td class='code'>";if(j=r.name){j=j.call(t,{hash:{},data:y})}else{j=t.name;j=typeof j===d?j.apply(t):j}s+=c(j)+"</td>\n<td>\n <select ";e={hash:{},inverse:p.noop,fn:p.program(1,o,y),data:y};g=((j=r.isArray||t.isArray),j?j.call(t,t,e):q.call(t,"isArray",t,e));if(g||g===0){s+=g}s+=" class='parameter' name='";if(g=r.name){g=g.call(t,{hash:{},data:y})}else{g=t.name;g=typeof g===d?g.apply(t):g}s+=c(g)+"'>\n ";g=r["if"].call(t,t.required,{hash:{},inverse:p.program(5,l,y),fn:p.program(3,n,y),data:y});if(g||g===0){s+=g}s+="\n ";g=r.each.call(t,((j=t.allowableValues),j==null||j===false?j:j.descriptiveValues),{hash:{},inverse:p.noop,fn:p.program(13,w,y),data:y});if(g||g===0){s+=g}s+="\n </select>\n</td>\n<td>";if(g=r.description){g=g.call(t,{hash:{},data:y})}else{g=t.description;g=typeof g===d?g.apply(t):g}if(g||g===0){s+=g}s+="</td>\n<td>";if(g=r.paramType){g=g.call(t,{hash:{},data:y})}else{g=t.paramType;g=typeof g===d?g.apply(t):g}if(g||g===0){s+=g}s+='</td>\n<td><span class="model-signature"></span></td>';return s})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n <textarea class='body-textarea' readonly='readonly' name='";if(r=f.name){r=r.call(t,{hash:{},data:s})}else{r=t.name;r=typeof r===h?r.apply(t):r}q+=j(r)+"'>";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"</textarea>\n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t.defaultValue,{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="<td class='code'>";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"</td>\n<td>\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n</td>\n<td>";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="</td>\n<td>";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='</td>\n<td><span class="model-signature"></span></td>\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n <textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='";if(r=f.name){r=r.call(t,{hash:{},data:s})}else{r=t.name;r=typeof r===h?r.apply(t):r}q+=j(r)+"'>";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"</textarea>\n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t.defaultValue,{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="<td class='code required'>";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"</td>\n<td>\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n</td>\n<td>";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="</td>\n<td>";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='</td>\n<td><span class="model-signature"></span></td>\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(f,q,o,j,u){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);u=u||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(4,k,y),fn:n.program(2,l,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function l(z,y){var w="",x;w+='\n <input type="file" name=\'';if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"'/>\n ";return w}function k(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.defaultValue,{hash:{},inverse:n.program(7,h,y),fn:n.program(5,i,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function i(z,y){var w="",x;w+="\n <textarea class='body-textarea' placeholder='(required)' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"'>";if(x=o.defaultValue){x=x.call(z,{hash:{},data:y})}else{x=z.defaultValue;x=typeof x===d?x.apply(z):x}w+=c(x)+"</textarea>\n ";return w}function h(z,y){var w="",x;w+="\n <textarea class='body-textarea' placeholder='(required)' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+'\'></textarea>\n <br />\n <div class="parameter-content-type" />\n ';return w}function e(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(12,t,y),fn:n.program(10,v,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function v(z,y){var w="",x;w+="\n <input class='parameter' class='required' type='file' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"'/>\n ";return w}function t(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.defaultValue,{hash:{},inverse:n.program(15,r,y),fn:n.program(13,s,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function s(z,y){var w="",x;w+="\n <input class='parameter required' minlength='1' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"' placeholder='(required)' type='text' value='";if(x=o.defaultValue){x=x.call(z,{hash:{},data:y})}else{x=z.defaultValue;x=typeof x===d?x.apply(z):x}w+=c(x)+"'/>\n ";return w}function r(z,y){var w="",x;w+="\n <input class='parameter required' minlength='1' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"' placeholder='(required)' type='text' value=''/>\n ";return w}p+="<td class='code required'>";if(g=o.name){g=g.call(q,{hash:{},data:u})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"</td>\n<td>\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,u),fn:n.program(1,m,u),data:u});if(g||g===0){p+=g}p+="\n</td>\n<td>\n <strong>";if(g=o.description){g=g.call(q,{hash:{},data:u})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="</strong>\n</td>\n<td>";if(g=o.paramType){g=g.call(q,{hash:{},data:u})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='</td>\n<td><span class="model-signature"></span></td>\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.parameter_content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.consumes,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n <option value="';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+='">';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+="</option>\n ";return o}function n(p,o){return'\n <option value="application/json">application/json</option>\n'}i+='<label for="parameterContentType"></label>\n<select name="parameterContentType">\n';c=f["if"].call(l,l.consumes,{hash:{},inverse:m.program(4,n,j),fn:m.program(1,e,j),data:j});if(c||c===0){i+=c}i+="\n</select>\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.resource=b(function(f,l,e,k,j){this.compilerInfo=[4,">= 1.0.0"];e=this.merge(e,f.helpers);j=j||{};var h="",c,o,g="function",i=this.escapeExpression,n=this,m=e.blockHelperMissing;function d(q,p){return" : "}h+="<div class='heading'>\n <h2>\n <a href='#!/";if(c=e.id){c=c.call(l,{hash:{},data:j})}else{c=l.id;c=typeof c===g?c.apply(l):c}h+=i(c)+"' onclick=\"Docs.toggleEndpointListForResource('";if(c=e.id){c=c.call(l,{hash:{},data:j})}else{c=l.id;c=typeof c===g?c.apply(l):c}h+=i(c)+"');\">";if(c=e.name){c=c.call(l,{hash:{},data:j})}else{c=l.name;c=typeof c===g?c.apply(l):c}h+=i(c)+"</a> ";o={hash:{},inverse:n.noop,fn:n.program(1,d,j),data:j};if(c=e.description){c=c.call(l,o)}else{c=l.description;c=typeof c===g?c.apply(l):c}if(!e.description){c=m.call(l,c,o)}if(c||c===0){h+=c}if(c=e.description){c=c.call(l,{hash:{},data:j})}else{c=l.description;c=typeof c===g?c.apply(l):c}if(c||c===0){h+=c}h+="\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/";if(c=e.id){c=c.call(l,{hash:{},data:j})}else{c=l.id;c=typeof c===g?c.apply(l):c}h+=i(c)+"' id='endpointListTogger_";if(c=e.id){c=c.call(l,{hash:{},data:j})}else{c=l.id;c=typeof c===g?c.apply(l):c}h+=i(c)+"'\n onclick=\"Docs.toggleEndpointListForResource('";if(c=e.id){c=c.call(l,{hash:{},data:j})}else{c=l.id;c=typeof c===g?c.apply(l):c}h+=i(c)+"');\">Show/Hide</a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.collapseOperationsForResource('";if(c=e.id){c=c.call(l,{hash:{},data:j})}else{c=l.id;c=typeof c===g?c.apply(l):c}h+=i(c)+"'); return false;\">\n List Operations\n </a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.expandOperationsForResource('";if(c=e.id){c=c.call(l,{hash:{},data:j})}else{c=l.id;c=typeof c===g?c.apply(l):c}h+=i(c)+"'); return false;\">\n Expand Operations\n </a>\n </li>\n <li>\n <a href='";if(c=e.url){c=c.call(l,{hash:{},data:j})}else{c=l.url;c=typeof c===g?c.apply(l):c}h+=i(c)+"'>Raw</a>\n </li>\n </ul>\n</div>\n<ul class='endpoints' id='";if(c=e.id){c=c.call(l,{hash:{},data:j})}else{c=l.id;c=typeof c===g?c.apply(l):c}h+=i(c)+"_endpoint_list' style='display:none'>\n\n</ul>\n";return h})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.response_content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.produces,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n <option value="';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+='">';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+="</option>\n ";return o}function n(p,o){return'\n <option value="application/json">application/json</option>\n'}i+='<label for="responseContentType"></label>\n<select name="responseContentType">\n';c=f["if"].call(l,l.produces,{hash:{},inverse:m.program(4,n,j),fn:m.program(1,e,j),data:j});if(c||c===0){i+=c}i+="\n</select>\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.signature=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+='<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 ';if(c=d.signature){c=c.call(k,{hash:{},data:i})}else{c=k.signature;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+='\n </div>\n\n <div class="snippet">\n <pre><code>';if(c=d.sampleJSON){c=c.call(k,{hash:{},data:i})}else{c=k.sampleJSON;c=typeof c===f?c.apply(k):c}g+=h(c)+'</code></pre>\n <small class="notice"></small>\n </div>\n</div>\n\n';return g})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.status_code=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+="<td width='15%' class='code'>";if(c=d.code){c=c.call(k,{hash:{},data:i})}else{c=k.code;c=typeof c===f?c.apply(k):c}g+=h(c)+"</td>\n<td>";if(c=d.message){c=c.call(k,{hash:{},data:i})}else{c=k.message;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+="</td>\n<td width='50%'><span class=\"model-signature\" /></td>";return g})})();(function(){var j,r,u,o,l,k,n,m,i,p,s,q,h,c,g,f,e,d,b,a,x,w,t={}.hasOwnProperty,v=function(B,z){for(var y in z){if(t.call(z,y)){B[y]=z[y]}}function A(){this.constructor=B}A.prototype=z.prototype;B.prototype=new A();B.__super__=z.prototype;return B};s=(function(z){v(y,z);function y(){q=y.__super__.constructor.apply(this,arguments);return q}y.prototype.dom_id="swagger_ui";y.prototype.options=null;y.prototype.api=null;y.prototype.headerView=null;y.prototype.mainView=null;y.prototype.initialize=function(A){var B=this;if(A==null){A={}}if(A.dom_id!=null){this.dom_id=A.dom_id;delete A.dom_id}if($("#"+this.dom_id)==null){$("body").append('<div id="'+this.dom_id+'"></div>')}this.options=A;this.options.success=function(){return B.render()};this.options.progress=function(C){return B.showMessage(C)};this.options.failure=function(C){return B.onLoadFailure(C)};this.headerView=new r({el:$("#header")});return this.headerView.on("update-swagger-ui",function(C){return B.updateSwaggerUi(C)})};y.prototype.updateSwaggerUi=function(A){this.options.url=A.url;return this.load()};y.prototype.load=function(){var B,A;if((A=this.mainView)!=null){A.clear()}B=this.options.url;if(B.indexOf("http")!==0){B=this.buildUrl(window.location.href.toString(),B)}this.options.url=B;this.headerView.update(B);this.api=new SwaggerApi(this.options);this.api.build();return this.api};y.prototype.render=function(){var A=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new u({model:this.api,el:$("#"+this.dom_id),swaggerOptions:this.options}).render();this.showMessage();switch(this.options.docExpansion){case"full":Docs.expandOperationsForResource("");break;case"list":Docs.collapseOperationsForResource("")}if(this.options.onComplete){this.options.onComplete(this.api,this)}return setTimeout(function(){return Docs.shebang()},400)};y.prototype.buildUrl=function(C,A){var B,D;log("base is "+C);if(A.indexOf("/")===0){D=C.split("/");C=D[0]+"//"+D[2];return C+A}else{B=C.length;if(C.indexOf("?")>-1){B=Math.min(B,C.indexOf("?"))}if(C.indexOf("#")>-1){B=Math.min(B,C.indexOf("#"))}C=C.substring(0,B);if(C.indexOf("/",C.length-1)!==-1){return C+A}return C+"/"+A}};y.prototype.showMessage=function(A){if(A==null){A=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(A)};y.prototype.onLoadFailure=function(A){var B;if(A==null){A=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");B=$("#message-bar").html(A);if(this.options.onFailure!=null){this.options.onFailure(A)}return B};return y})(Backbone.Router);window.SwaggerUi=s;r=(function(z){v(y,z);function y(){h=y.__super__.constructor.apply(this,arguments);return h}y.prototype.events={"click #show-pet-store-icon":"showPetStore","click #show-wordnik-dev-icon":"showWordnikDev","click #explore":"showCustom","keyup #input_baseUrl":"showCustomOnKeyup","keyup #input_apiKey":"showCustomOnKeyup"};y.prototype.initialize=function(){};y.prototype.showPetStore=function(A){return this.trigger("update-swagger-ui",{url:"http://petstore.swagger.wordnik.com/api/api-docs"})};y.prototype.showWordnikDev=function(A){return this.trigger("update-swagger-ui",{url:"http://api.wordnik.com/v4/resources.json"})};y.prototype.showCustomOnKeyup=function(A){if(A.keyCode===13){return this.showCustom()}};y.prototype.showCustom=function(A){if(A!=null){A.preventDefault()}return this.trigger("update-swagger-ui",{url:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};y.prototype.update=function(B,C,A){if(A==null){A=false}$("#input_baseUrl").val(B);if(A){return this.trigger("update-swagger-ui",{url:B})}};return y})(Backbone.View);u=(function(y){var z;v(A,y);function A(){g=A.__super__.constructor.apply(this,arguments);return g}z={alpha:function(C,B){return C.path.localeCompare(B.path)},method:function(C,B){return C.method.localeCompare(B.method)}};A.prototype.initialize=function(D){var C,H,F,E,B,G;if(D==null){D={}}if(D.swaggerOptions.sorter){F=D.swaggerOptions.sorter;H=z[F];G=this.model.apisArray;for(E=0,B=G.length;E<B;E++){C=G[E];C.operationsArray.sort(H)}if(F==="alpha"){return this.model.apisArray.sort(H)}}};A.prototype.render=function(){var C,H,E,F,D,B,G;$(this.el).html(Handlebars.templates.main(this.model));F={};C=0;G=this.model.apisArray;for(D=0,B=G.length;D<B;D++){E=G[D];H=E.name;while(typeof F[H]!=="undefined"){H=H+"_"+C;C+=1}E.id=H;F[H]=E;this.addResource(E)}return this};A.prototype.addResource=function(C){var B;B=new n({model:C,tagName:"li",id:"resource_"+C.id,className:"resource",swaggerOptions:this.options.swaggerOptions});return $("#resources").append(B.render().el)};A.prototype.clear=function(){return $(this.el).html("")};return A})(Backbone.View);n=(function(z){v(y,z);function y(){f=y.__super__.constructor.apply(this,arguments);return f}y.prototype.initialize=function(){};y.prototype.render=function(){var B,G,D,C,E,A,F;$(this.el).html(Handlebars.templates.resource(this.model));D={};F=this.model.operationsArray;for(E=0,A=F.length;E<A;E++){C=F[E];B=0;G=C.nickname;while(typeof D[G]!=="undefined"){G=G+"_"+B;B+=1}D[G]=C;C.nickname=G;C.parentId=this.model.id;this.addOperation(C)}return this};y.prototype.addOperation=function(A){var B;A.number=this.number;B=new o({model:A,tagName:"li",className:"endpoint",swaggerOptions:this.options.swaggerOptions});$(".endpoints",$(this.el)).append(B.render().el);return this.number++};return y})(Backbone.View);o=(function(z){v(y,z);function y(){e=y.__super__.constructor.apply(this,arguments);return e}y.prototype.invocationUrl=null;y.prototype.events={"submit .sandbox":"submitOperation","click .submit":"submitOperation","click .response_hider":"hideResponse","click .toggleOperation":"toggleOperationContent","mouseenter .api-ic":"mouseEnter","mouseout .api-ic":"mouseExit"};y.prototype.initialize=function(){};y.prototype.mouseEnter=function(F){var D,E,I,B,A,J,G,C,K,H;D=$(F.currentTarget.parentNode).find("#api_information_panel");K=F.pageX;H=F.pageY;J=$(window).scrollLeft();G=$(window).scrollTop();B=J+$(window).width();A=G+$(window).height();C=D.width();E=D.height();if(K+C>B){K=B-C}if(K<J){K=J}if(H+E>A){H=A-E}if(H<G){H=G}I={};I.top=H;I.left=K;D.css(I);return $(F.currentTarget.parentNode).find("#api_information_panel").show()};y.prototype.mouseExit=function(A){return $(A.currentTarget.parentNode).find("#api_information_panel").hide()};y.prototype.render=function(){var Q,R,P,O,I,N,J,M,K,H,L,G,F,E,C,T,V,U,S,D,B,A,W;R=true;if(!R){this.model.isReadOnly=true}this.model.oauth=null;if(this.model.authorizations){D=this.model.authorizations;for(P in D){L=D[P];if(P==="oauth2"){if(this.model.oauth===null){this.model.oauth={}}if(this.model.oauth.scopes===void 0){this.model.oauth.scopes=[]}for(G=0,T=L.length;G<T;G++){O=L[G];this.model.oauth.scopes.push(O)}}}}$(this.el).html(Handlebars.templates.operation(this.model));if(this.model.responseClassSignature&&this.model.responseClassSignature!=="string"){M={sampleJSON:this.model.responseSampleJSON,isParam:false,signature:this.model.responseClassSignature};J=new i({model:M,tagName:"div"});$(".model-signature",$(this.el)).append(J.render().el)}else{$(".model-signature",$(this.el)).html(this.model.type)}Q={isParam:false};Q.consumes=this.model.consumes;Q.produces=this.model.produces;B=this.model.parameters;for(F=0,V=B.length;F<V;F++){I=B[F];H=I.type||I.dataType;if(H.toLowerCase()==="file"){if(!Q.consumes){log("set content type ");Q.consumes="multipart/form-data"}}}N=new m({model:Q});$(".response-content-type",$(this.el)).append(N.render().el);A=this.model.parameters;for(E=0,U=A.length;E<U;E++){I=A[E];this.addParameter(I,Q.consumes)}W=this.model.responseMessages;for(C=0,S=W.length;C<S;C++){K=W[C];this.addStatusCode(K)}return this};y.prototype.addParameter=function(C,A){var B;C.consumes=A;B=new k({model:C,tagName:"tr",readOnly:this.model.isReadOnly});return $(".operation-params",$(this.el)).append(B.render().el)};y.prototype.addStatusCode=function(B){var A;A=new p({model:B,tagName:"tr"});return $(".operation-status",$(this.el)).append(A.render().el)};y.prototype.submitOperation=function(O){var Q,G,N,D,I,A,J,M,L,K,P,F,C,H,E,B;if(O!=null){O.preventDefault()}G=$(".sandbox",$(this.el));Q=true;G.find("input.required").each(function(){var R=this;$(this).removeClass("error");if(jQuery.trim($(this).val())===""){$(this).addClass("error");$(this).wiggle({callback:function(){return $(R).focus()}});return Q=false}});if(Q){D={};A={parent:this};N=false;H=G.find("input");for(M=0,P=H.length;M<P;M++){I=H[M];if((I.value!=null)&&jQuery.trim(I.value).length>0){D[I.name]=I.value}if(I.type==="file"){N=true}}E=G.find("textarea");for(L=0,F=E.length;L<F;L++){I=E[L];if((I.value!=null)&&jQuery.trim(I.value).length>0){D.body=I.value}}B=G.find("select");for(K=0,C=B.length;K<C;K++){I=B[K];J=this.getSelectedValue(I);if((J!=null)&&jQuery.trim(J).length>0){D[I.name]=J}}A.responseContentType=$("div select[name=responseContentType]",$(this.el)).val();A.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val();$(".response_throbber",$(this.el)).show();if(N){return this.handleFileUpload(D,G)}else{return this.model["do"](D,A,this.showCompleteStatus,this.showErrorStatus,this)}}};y.prototype.success=function(A,B){return B.showCompleteStatus(A)};y.prototype.handleFileUpload=function(R,I){var M,H,C,N,L,K,P,J,G,F,D,Q,U,T,S,E,B,A,V,O=this;E=I.serializeArray();for(J=0,Q=E.length;J<Q;J++){N=E[J];if((N.value!=null)&&jQuery.trim(N.value).length>0){R[N.name]=N.value}}M=new FormData();P=0;B=this.model.parameters;for(G=0,U=B.length;G<U;G++){K=B[G];if(K.paramType==="form"){if(K.type.toLowerCase()!=="file"&&R[K.name]!==void 0){M.append(K.name,R[K.name])}}}C={};A=this.model.parameters;for(F=0,T=A.length;F<T;F++){K=A[F];if(K.paramType==="header"){C[K.name]=R[K.name]}}log(C);V=I.find('input[type~="file"]');for(D=0,S=V.length;D<S;D++){H=V[D];if(typeof H.files[0]!=="undefined"){M.append($(H).attr("name"),H.files[0]);P+=1}}this.invocationUrl=this.model.supportHeaderParams()?(C=this.model.getHeaderParams(R),this.model.urlify(R,false)):this.model.urlify(R,true);$(".request_url",$(this.el)).html("<pre></pre>");$(".request_url pre",$(this.el)).text(this.invocationUrl);L={type:this.model.method,url:this.invocationUrl,headers:C,data:M,dataType:"json",contentType:false,processData:false,error:function(X,Y,W){return O.showErrorStatus(O.wrap(X),O)},success:function(W){return O.showResponse(W,O)},complete:function(W){return O.showCompleteStatus(O.wrap(W),O)}};if(window.authorizations){window.authorizations.apply(L)}if(P===0){L.data.append("fake","true")}jQuery.ajax(L);return false};y.prototype.wrap=function(E){var C,F,H,B,G,D,A;H={};F=E.getAllResponseHeaders().split("\r");for(D=0,A=F.length;D<A;D++){B=F[D];C=B.split(":");if(C[0]!==void 0&&C[1]!==void 0){H[C[0].trim()]=C[1].trim()}}G={};G.content={};G.content.data=E.responseText;G.headers=H;G.request={};G.request.url=this.invocationUrl;G.status=E.status;return G};y.prototype.getSelectedValue=function(A){var D,C,F,B,E;if(!A.multiple){return A.value}else{C=[];E=A.options;for(F=0,B=E.length;F<B;F++){D=E[F];if(D.selected){C.push(D.value)}}if(C.length>0){return C.join(",")}else{return null}}};y.prototype.hideResponse=function(A){if(A!=null){A.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};y.prototype.showResponse=function(A){var B;B=JSON.stringify(A,null,"\t").replace(/\n/g,"<br>");return $(".response_body",$(this.el)).html(escape(B))};y.prototype.showErrorStatus=function(B,A){return A.showStatus(B)};y.prototype.showCompleteStatus=function(B,A){return A.showStatus(B)};y.prototype.formatXml=function(H){var D,G,B,I,N,J,C,A,L,M,F,E,K;A=/(>)(<)(\/*)/g;M=/[ ]*(.*)[ ]+\n/g;D=/(<.+>)(.+\n)/g;H=H.replace(A,"$1\n$2$3").replace(M,"$1\n").replace(D,"$1\n$2");C=0;G="";N=H.split("\n");B=0;I="other";L={"single->single":0,"single->closing":-1,"single->opening":0,"single->other":0,"closing->single":0,"closing->closing":-1,"closing->opening":0,"closing->other":0,"opening->single":1,"opening->closing":0,"opening->opening":1,"opening->other":1,"other->single":0,"other->closing":-1,"other->opening":0,"other->other":0};F=function(T){var P,O,R,V,S,Q,U;Q={single:Boolean(T.match(/<.+\/>/)),closing:Boolean(T.match(/<\/.+>/)),opening:Boolean(T.match(/<[^!?].*>/))};S=((function(){var W;W=[];for(R in Q){U=Q[R];if(U){W.push(R)}}return W})())[0];S=S===void 0?"other":S;P=I+"->"+S;I=S;V="";B+=L[P];V=((function(){var X,Y,W;W=[];for(O=X=0,Y=B;0<=Y?X<Y:X>Y;O=0<=Y?++X:--X){W.push(" ")}return W})()).join("");if(P==="opening->closing"){return G=G.substr(0,G.length-1)+T+"\n"}else{return G+=V+T+"\n"}};for(E=0,K=N.length;E<K;E++){J=N[E];F(J)}return G};y.prototype.showStatus=function(F){var C,H,J,D,A,E,I,G,B;if(F.content===void 0){H=F.data;B=F.url}else{H=F.content.data;B=F.request.url}D=F.headers;J=D&&D["Content-Type"]?D["Content-Type"].split(";")[0].trim():null;if(!H){C=$("<code />").text("no content");E=$('<pre class="json" />').append(C)}else{if(J==="application/json"||/\+json$/.test(J)){C=$("<code />").text(JSON.stringify(JSON.parse(H),null," "));E=$('<pre class="json" />').append(C)}else{if(J==="application/xml"||/\+xml$/.test(J)){C=$("<code />").text(this.formatXml(H));E=$('<pre class="xml" />').append(C)}else{if(J==="text/html"){C=$("<code />").html(H);E=$('<pre class="xml" />').append(C)}else{if(/^image\//.test(J)){E=$("<img>").attr("src",B)}else{C=$("<code />").text(H);E=$('<pre class="json" />').append(C)}}}}}I=E;$(".request_url",$(this.el)).html("<pre></pre>");$(".request_url pre",$(this.el)).text(B);$(".response_code",$(this.el)).html("<pre>"+F.status+"</pre>");$(".response_body",$(this.el)).html(I);$(".response_headers",$(this.el)).html("<pre>"+_.escape(JSON.stringify(F.headers,null," ")).replace(/\n/g,"<br>")+"</pre>");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();G=$(".response_body",$(this.el))[0];A=this.options.swaggerOptions;if(A.highlightSizeThreshold&&F.data.length>A.highlightSizeThreshold){return G}else{return hljs.highlightBlock(G)}};y.prototype.toggleOperationContent=function(){var A;A=$("#"+Docs.escapeResourceName(this.model.parentId)+"_"+this.model.nickname+"_content");if(A.is(":visible")){return Docs.collapseOperation(A)}else{return Docs.expandOperation(A)}};return y})(Backbone.View);p=(function(z){v(y,z);function y(){d=y.__super__.constructor.apply(this,arguments);return d}y.prototype.initialize=function(){};y.prototype.render=function(){var B,A,C;C=this.template();$(this.el).html(C(this.model));if(swaggerUi.api.models.hasOwnProperty(this.model.responseModel)){B={sampleJSON:JSON.stringify(swaggerUi.api.models[this.model.responseModel].createJSONSample(),null,2),isParam:false,signature:swaggerUi.api.models[this.model.responseModel].getMockSignature()};A=new i({model:B,tagName:"div"});$(".model-signature",this.$el).append(A.render().el)}else{$(".model-signature",this.$el).html("")}return this};y.prototype.template=function(){return Handlebars.templates.status_code};return y})(Backbone.View);k=(function(z){v(y,z);function y(){b=y.__super__.constructor.apply(this,arguments);return b}y.prototype.initialize=function(){return Handlebars.registerHelper("isArray",function(B,A){if(B.type.toLowerCase()==="array"||B.allowMultiple){return A.fn(this)}else{return A.inverse(this)}})};y.prototype.render=function(){var G,A,C,F,B,H,E,D;D=this.model.type||this.model.dataType;if(this.model.paramType==="body"){this.model.isBody=true}if(D.toLowerCase()==="file"){this.model.isFile=true}E=this.template();$(this.el).html(E(this.model));B={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){H=new i({model:B,tagName:"div"});$(".model-signature",$(this.el)).append(H.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}A=false;if(this.model.isBody){A=true}G={isParam:A};G.consumes=this.model.consumes;if(A){C=new l({model:G});$(".parameter-content-type",$(this.el)).append(C.render().el)}else{F=new m({model:G});$(".response-content-type",$(this.el)).append(F.render().el)}return this};y.prototype.template=function(){if(this.model.isList){return Handlebars.templates.param_list}else{if(this.options.readOnly){if(this.model.required){return Handlebars.templates.param_readonly_required}else{return Handlebars.templates.param_readonly}}else{if(this.model.required){return Handlebars.templates.param_required}else{return Handlebars.templates.param}}}};return y})(Backbone.View);i=(function(z){v(y,z);function y(){a=y.__super__.constructor.apply(this,arguments);return a}y.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));this.switchToSnippet();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};y.prototype.template=function(){return Handlebars.templates.signature};y.prototype.switchToDescription=function(A){if(A!=null){A.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};y.prototype.switchToSnippet=function(A){if(A!=null){A.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};y.prototype.snippetToTextArea=function(A){var B;if(this.isParam){if(A!=null){A.preventDefault()}B=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(B.val())===""){return B.val(this.model.sampleJSON)}}};return y})(Backbone.View);j=(function(y){v(z,y);function z(){x=z.__super__.constructor.apply(this,arguments);return x}z.prototype.initialize=function(){};z.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=contentType]",$(this.el)).text("Response Content Type");return this};z.prototype.template=function(){return Handlebars.templates.content_type};return z})(Backbone.View);m=(function(y){v(z,y);function z(){w=z.__super__.constructor.apply(this,arguments);return w}z.prototype.initialize=function(){};z.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=responseContentType]",$(this.el)).text("Response Content Type");return this};z.prototype.template=function(){return Handlebars.templates.response_content_type};return z})(Backbone.View);l=(function(z){v(y,z);function y(){c=y.__super__.constructor.apply(this,arguments);return c}y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:");return this};y.prototype.template=function(){return Handlebars.templates.parameter_content_type};return y})(Backbone.View)}).call(this);
@@ -1,1480 +1,1603 @@
1
- // Generated by CoffeeScript 1.6.3
2
- (function() {
3
- var ApiKeyAuthorization, PasswordAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource, log,
4
- __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
5
- __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
6
-
7
- log = function() {
8
- if (window.console) {
9
- return console.log.apply(console, arguments);
1
+ // swagger.js
2
+ // version 2.0.37
3
+
4
+ var __bind = function(fn, me){
5
+ return function(){
6
+ return fn.apply(me, arguments);
7
+ };
8
+ };
9
+
10
+ log = function(){
11
+ log.history = log.history || [];
12
+ log.history.push(arguments);
13
+ if(this.console){
14
+ console.log( Array.prototype.slice.call(arguments)[0] );
15
+ }
16
+ };
17
+
18
+ if (!Array.prototype.indexOf) {
19
+ Array.prototype.indexOf = function(obj, start) {
20
+ for (var i = (start || 0), j = this.length; i < j; i++) {
21
+ if (this[i] === obj) { return i; }
10
22
  }
23
+ return -1;
24
+ }
25
+ }
26
+
27
+ if (!('filter' in Array.prototype)) {
28
+ Array.prototype.filter= function(filter, that /*opt*/) {
29
+ var other= [], v;
30
+ for (var i=0, n= this.length; i<n; i++)
31
+ if (i in this && filter.call(that, v= this[i], i, this))
32
+ other.push(v);
33
+ return other;
11
34
  };
12
-
13
- SwaggerApi = (function() {
14
- SwaggerApi.prototype.url = "http://api.wordnik.com/v4/resources.json";
15
-
16
- SwaggerApi.prototype.debug = false;
17
-
18
- SwaggerApi.prototype.basePath = null;
19
-
20
- SwaggerApi.prototype.authorizations = null;
21
-
22
- SwaggerApi.prototype.authorizationScheme = null;
23
-
24
- SwaggerApi.prototype.info = null;
25
-
26
- SwaggerApi.prototype.useJQuery = null;
27
-
28
- function SwaggerApi(url, options) {
29
- if (options == null) {
30
- options = {};
31
- }
32
- if (url) {
33
- if (url.url) {
34
- options = url;
35
- } else {
36
- this.url = url;
37
- }
38
- } else {
39
- options = url;
40
- }
41
- if (options.url != null) {
42
- this.url = options.url;
43
- }
44
- if (options.success != null) {
45
- this.success = options.success;
46
- }
47
- this.failure = options.failure != null ? options.failure : function() {};
48
- this.progress = options.progress != null ? options.progress : function() {};
49
- if (options.success != null) {
50
- this.build();
51
- }
35
+ }
36
+
37
+ if (!('map' in Array.prototype)) {
38
+ Array.prototype.map= function(mapper, that /*opt*/) {
39
+ var other= new Array(this.length);
40
+ for (var i= 0, n= this.length; i<n; i++)
41
+ if (i in this)
42
+ other[i]= mapper.call(that, this[i], i, this);
43
+ return other;
44
+ };
45
+ }
46
+
47
+ Object.keys = Object.keys || (function () {
48
+ var hasOwnProperty = Object.prototype.hasOwnProperty,
49
+ hasDontEnumBug = !{toString:null}.propertyIsEnumerable("toString"),
50
+ DontEnums = [
51
+ 'toString',
52
+ 'toLocaleString',
53
+ 'valueOf',
54
+ 'hasOwnProperty',
55
+ 'isPrototypeOf',
56
+ 'propertyIsEnumerable',
57
+ 'constructor'
58
+ ],
59
+ DontEnumsLength = DontEnums.length;
60
+
61
+ return function (o) {
62
+ if (typeof o != "object" && typeof o != "function" || o === null)
63
+ throw new TypeError("Object.keys called on a non-object");
64
+
65
+ var result = [];
66
+ for (var name in o) {
67
+ if (hasOwnProperty.call(o, name))
68
+ result.push(name);
52
69
  }
53
70
 
54
- SwaggerApi.prototype.build = function() {
55
- var e, obj,
56
- _this = this;
57
- this.progress('fetching resource list: ' + this.url);
58
- obj = {
59
- useJQuery: this.useJQuery,
60
- url: this.url,
61
- method: "get",
62
- headers: {
63
- accept: "application/json"
64
- },
65
- on: {
66
- error: function(response) {
67
- if (_this.url.substring(0, 4) !== 'http') {
68
- return _this.fail('Please specify the protocol for ' + _this.url);
69
- } else if (response.status === 0) {
70
- return _this.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.');
71
- } else if (response.status === 404) {
72
- return _this.fail('Can\'t read swagger JSON from ' + _this.url);
73
- } else {
74
- return _this.fail(response.status + ' : ' + response.statusText + ' ' + _this.url);
75
- }
76
- },
77
- response: function(response) {
78
- var responseObj;
79
- responseObj = JSON.parse(response.data);
80
- _this.swaggerVersion = responseObj.swaggerVersion;
81
- if (_this.swaggerVersion === "1.2") {
82
- return _this.buildFromSpec(responseObj);
83
- } else {
84
- return _this.buildFrom1_1Spec(responseObj);
85
- }
86
- }
87
- }
88
- };
89
- e = {};
90
- if (typeof window !== 'undefined') {
91
- e = window;
92
- } else {
93
- e = exports;
94
- }
95
- e.authorizations.apply(obj);
96
- new SwaggerHttp().execute(obj);
97
- return this;
98
- };
99
-
100
- SwaggerApi.prototype.buildFromSpec = function(response) {
101
- var api, isApi, newName, operation, res, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
102
- if (response.apiVersion != null) {
103
- this.apiVersion = response.apiVersion;
104
- }
105
- this.apis = {};
106
- this.apisArray = [];
107
- this.produces = response.produces;
108
- this.authSchemes = response.authorizations;
109
- if (response.info != null) {
110
- this.info = response.info;
111
- }
112
- isApi = false;
113
- _ref = response.apis;
114
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
115
- api = _ref[_i];
116
- if (api.operations) {
117
- _ref1 = api.operations;
118
- for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
119
- operation = _ref1[_j];
120
- isApi = true;
121
- }
122
- }
123
- }
124
- if (response.basePath) {
125
- this.basePath = response.basePath;
126
- } else if (this.url.indexOf('?') > 0) {
127
- this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
128
- } else {
129
- this.basePath = this.url;
130
- }
131
- if (isApi) {
132
- newName = response.resourcePath.replace(/\//g, '');
133
- this.resourcePath = response.resourcePath;
134
- res = new SwaggerResource(response, this);
135
- this.apis[newName] = res;
136
- this.apisArray.push(res);
137
- } else {
138
- _ref2 = response.apis;
139
- for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
140
- resource = _ref2[_k];
141
- res = new SwaggerResource(resource, this);
142
- this.apis[res.name] = res;
143
- this.apisArray.push(res);
144
- }
145
- }
146
- if (this.success) {
147
- this.success();
148
- }
149
- return this;
150
- };
151
-
152
- SwaggerApi.prototype.buildFrom1_1Spec = function(response) {
153
- var api, isApi, newName, operation, res, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
154
- log("This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info");
155
- if (response.apiVersion != null) {
156
- this.apiVersion = response.apiVersion;
157
- }
158
- this.apis = {};
159
- this.apisArray = [];
160
- this.produces = response.produces;
161
- if (response.info != null) {
162
- this.info = response.info;
163
- }
164
- isApi = false;
165
- _ref = response.apis;
166
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
167
- api = _ref[_i];
168
- if (api.operations) {
169
- _ref1 = api.operations;
170
- for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
171
- operation = _ref1[_j];
172
- isApi = true;
173
- }
174
- }
175
- }
176
- if (response.basePath) {
177
- this.basePath = response.basePath;
178
- } else if (this.url.indexOf('?') > 0) {
179
- this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
180
- } else {
181
- this.basePath = this.url;
182
- }
183
- if (isApi) {
184
- newName = response.resourcePath.replace(/\//g, '');
185
- this.resourcePath = response.resourcePath;
186
- res = new SwaggerResource(response, this);
187
- this.apis[newName] = res;
188
- this.apisArray.push(res);
189
- } else {
190
- _ref2 = response.apis;
191
- for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
192
- resource = _ref2[_k];
193
- res = new SwaggerResource(resource, this);
194
- this.apis[res.name] = res;
195
- this.apisArray.push(res);
196
- }
197
- }
198
- if (this.success) {
199
- this.success();
200
- }
201
- return this;
202
- };
203
-
204
- SwaggerApi.prototype.selfReflect = function() {
205
- var resource, resource_name, _ref;
206
- if (this.apis == null) {
207
- return false;
208
- }
209
- _ref = this.apis;
210
- for (resource_name in _ref) {
211
- resource = _ref[resource_name];
212
- if (resource.ready == null) {
213
- return false;
214
- }
215
- }
216
- this.setConsolidatedModels();
217
- this.ready = true;
218
- if (this.success != null) {
219
- return this.success();
71
+ if (hasDontEnumBug) {
72
+ for (var i = 0; i < DontEnumsLength; i++) {
73
+ if (hasOwnProperty.call(o, DontEnums[i]))
74
+ result.push(DontEnums[i]);
220
75
  }
221
- };
222
-
223
- SwaggerApi.prototype.fail = function(message) {
224
- this.failure(message);
225
- throw message;
226
- };
227
-
228
- SwaggerApi.prototype.setConsolidatedModels = function() {
229
- var model, modelName, resource, resource_name, _i, _len, _ref, _ref1, _results;
230
- this.modelsArray = [];
231
- this.models = {};
232
- _ref = this.apis;
233
- for (resource_name in _ref) {
234
- resource = _ref[resource_name];
235
- for (modelName in resource.models) {
236
- if (this.models[modelName] == null) {
237
- this.models[modelName] = resource.models[modelName];
238
- this.modelsArray.push(resource.models[modelName]);
239
- }
240
- }
241
- }
242
- _ref1 = this.modelsArray;
243
- _results = [];
244
- for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
245
- model = _ref1[_i];
246
- _results.push(model.setReferencedModels(this.models));
247
- }
248
- return _results;
249
- };
250
-
251
- SwaggerApi.prototype.help = function() {
252
- var operation, operation_name, parameter, resource, resource_name, _i, _len, _ref, _ref1, _ref2;
253
- _ref = this.apis;
254
- for (resource_name in _ref) {
255
- resource = _ref[resource_name];
256
- log(resource_name);
257
- _ref1 = resource.operations;
258
- for (operation_name in _ref1) {
259
- operation = _ref1[operation_name];
260
- log(" " + operation.nickname);
261
- _ref2 = operation.parameters;
262
- for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
263
- parameter = _ref2[_i];
264
- log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
265
- }
266
- }
267
- }
268
- return this;
269
- };
76
+ }
270
77
 
271
- return SwaggerApi;
272
-
273
- })();
274
-
275
- SwaggerResource = (function() {
276
- SwaggerResource.prototype.api = null;
277
-
278
- SwaggerResource.prototype.produces = null;
279
-
280
- SwaggerResource.prototype.consumes = null;
281
-
282
- function SwaggerResource(resourceObj, api) {
283
- var consumes, e, obj, parts, produces,
284
- _this = this;
285
- this.api = api;
286
- this.api = this.api;
287
- produces = [];
288
- consumes = [];
289
- this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
290
- this.description = resourceObj.description;
291
- parts = this.path.split("/");
292
- this.name = parts[parts.length - 1].replace('.{format}', '');
293
- this.basePath = this.api.basePath;
294
- this.operations = {};
295
- this.operationsArray = [];
296
- this.modelsArray = [];
297
- this.models = {};
298
- this.rawModels = {};
299
- if ((resourceObj.apis != null) && (this.api.resourcePath != null)) {
300
- this.addApiDeclaration(resourceObj);
301
- } else {
302
- if (this.path == null) {
303
- this.api.fail("SwaggerResources must have a path.");
304
- }
305
- if (this.path.substring(0, 4) === 'http') {
306
- this.url = this.path.replace('{format}', 'json');
78
+ return result;
79
+ };
80
+ })();
81
+
82
+ var SwaggerApi = function(url, options) {
83
+ this.url = null;
84
+ this.debug = false;
85
+ this.basePath = null;
86
+ this.authorizations = null;
87
+ this.authorizationScheme = null;
88
+ this.info = null;
89
+ this.useJQuery = false;
90
+
91
+ options = (options||{});
92
+ if (url)
93
+ if (url.url)
94
+ options = url;
95
+ else
96
+ this.url = url;
97
+ else
98
+ options = url;
99
+
100
+ if (options.url != null)
101
+ this.url = options.url;
102
+
103
+ if (options.success != null)
104
+ this.success = options.success;
105
+
106
+ if (typeof options.useJQuery === 'boolean')
107
+ this.useJQuery = options.useJQuery;
108
+
109
+ this.failure = options.failure != null ? options.failure : function() {};
110
+ this.progress = options.progress != null ? options.progress : function() {};
111
+ if (options.success != null)
112
+ this.build();
113
+ }
114
+
115
+ SwaggerApi.prototype.build = function() {
116
+ var _this = this;
117
+ this.progress('fetching resource list: ' + this.url);
118
+ var obj = {
119
+ useJQuery: this.useJQuery,
120
+ url: this.url,
121
+ method: "get",
122
+ headers: {
123
+ accept: "application/json"
124
+ },
125
+ on: {
126
+ error: function(response) {
127
+ if (_this.url.substring(0, 4) !== 'http') {
128
+ return _this.fail('Please specify the protocol for ' + _this.url);
129
+ } else if (response.status === 0) {
130
+ return _this.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.');
131
+ } else if (response.status === 404) {
132
+ return _this.fail('Can\'t read swagger JSON from ' + _this.url);
307
133
  } else {
308
- this.url = this.api.basePath + this.path.replace('{format}', 'json');
134
+ return _this.fail(response.status + ' : ' + response.statusText + ' ' + _this.url);
309
135
  }
310
- this.api.progress('fetching resource ' + this.name + ': ' + this.url);
311
- obj = {
312
- url: this.url,
313
- method: "get",
314
- useJQuery: this.useJQuery,
315
- headers: {
316
- accept: "application/json"
317
- },
318
- on: {
319
- error: function(response) {
320
- return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")");
321
- },
322
- response: function(response) {
323
- var responseObj;
324
- responseObj = JSON.parse(response.data);
325
- return _this.addApiDeclaration(responseObj);
326
- }
327
- }
328
- };
329
- e = {};
330
- if (typeof window !== 'undefined') {
331
- e = window;
136
+ },
137
+ response: function(resp) {
138
+ var responseObj = resp.obj || JSON.parse(resp.data);
139
+ _this.swaggerVersion = responseObj.swaggerVersion;
140
+ if (_this.swaggerVersion === "1.2") {
141
+ return _this.buildFromSpec(responseObj);
332
142
  } else {
333
- e = exports;
143
+ return _this.buildFrom1_1Spec(responseObj);
334
144
  }
335
- e.authorizations.apply(obj);
336
- new SwaggerHttp().execute(obj);
337
145
  }
338
146
  }
339
-
340
- SwaggerResource.prototype.getAbsoluteBasePath = function(relativeBasePath) {
341
- var parts, pos, url;
342
- url = this.api.basePath;
343
- pos = url.lastIndexOf(relativeBasePath);
344
- if (pos === -1) {
345
- parts = url.split("/");
346
- url = parts[0] + "//" + parts[2];
347
- if (relativeBasePath.indexOf("/") === 0) {
348
- return url + relativeBasePath;
349
- } else {
350
- return url + "/" + relativeBasePath;
351
- }
352
- } else if (relativeBasePath === "/") {
353
- return url.substring(0, pos);
354
- } else {
355
- return url.substring(0, pos) + relativeBasePath;
356
- }
357
- };
358
-
359
- SwaggerResource.prototype.addApiDeclaration = function(response) {
360
- var endpoint, _i, _len, _ref;
361
- if (response.produces != null) {
362
- this.produces = response.produces;
363
- }
364
- if (response.consumes != null) {
365
- this.consumes = response.consumes;
366
- }
367
- if ((response.basePath != null) && response.basePath.replace(/\s/g, '').length > 0) {
368
- this.basePath = response.basePath.indexOf("http") === -1 ? this.getAbsoluteBasePath(response.basePath) : response.basePath;
147
+ };
148
+ var e = (typeof window !== 'undefined' ? window : exports);
149
+ e.authorizations.apply(obj);
150
+ new SwaggerHttp().execute(obj);
151
+ return this;
152
+ };
153
+
154
+ SwaggerApi.prototype.buildFromSpec = function(response) {
155
+ if (response.apiVersion != null) {
156
+ this.apiVersion = response.apiVersion;
157
+ }
158
+ this.apis = {};
159
+ this.apisArray = [];
160
+ this.consumes = response.consumes;
161
+ this.produces = response.produces;
162
+ this.authSchemes = response.authorizations;
163
+ if (response.info != null) {
164
+ this.info = response.info;
165
+ }
166
+ var isApi = false;
167
+ var i;
168
+ for (i = 0; i < response.apis.length; i++) {
169
+ var api = response.apis[i];
170
+ if (api.operations) {
171
+ var j;
172
+ for (j = 0; j < api.operations.length; j++) {
173
+ operation = api.operations[j];
174
+ isApi = true;
369
175
  }
370
- this.addModels(response.models);
371
- if (response.apis) {
372
- _ref = response.apis;
373
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
374
- endpoint = _ref[_i];
375
- this.addOperations(endpoint.path, endpoint.operations, response.consumes, response.produces);
376
- }
176
+ }
177
+ }
178
+ if (response.basePath)
179
+ this.basePath = response.basePath;
180
+ else if (this.url.indexOf('?') > 0)
181
+ this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
182
+ else
183
+ this.basePath = this.url;
184
+
185
+ if (isApi) {
186
+ var newName = response.resourcePath.replace(/\//g, '');
187
+ this.resourcePath = response.resourcePath;
188
+ res = new SwaggerResource(response, this);
189
+ this.apis[newName] = res;
190
+ this.apisArray.push(res);
191
+ } else {
192
+ var k;
193
+ for (k = 0; k < response.apis.length; k++) {
194
+ var resource = response.apis[k];
195
+ res = new SwaggerResource(resource, this);
196
+ this.apis[res.name] = res;
197
+ this.apisArray.push(res);
198
+ }
199
+ }
200
+ if (this.success) {
201
+ this.success();
202
+ }
203
+ return this;
204
+ };
205
+
206
+ SwaggerApi.prototype.buildFrom1_1Spec = function(response) {
207
+ log("This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info");
208
+ if (response.apiVersion != null)
209
+ this.apiVersion = response.apiVersion;
210
+ this.apis = {};
211
+ this.apisArray = [];
212
+ this.produces = response.produces;
213
+ if (response.info != null) {
214
+ this.info = response.info;
215
+ }
216
+ var isApi = false;
217
+ for (var i = 0; i < response.apis.length; i++) {
218
+ var api = response.apis[i];
219
+ if (api.operations) {
220
+ for (var j = 0; j < api.operations.length; j++) {
221
+ operation = api.operations[j];
222
+ isApi = true;
377
223
  }
378
- this.api[this.name] = this;
379
- this.ready = true;
380
- return this.api.selfReflect();
381
- };
382
-
383
- SwaggerResource.prototype.addModels = function(models) {
384
- var model, modelName, swaggerModel, _i, _len, _ref, _results;
385
- if (models != null) {
386
- for (modelName in models) {
387
- if (this.models[modelName] == null) {
388
- swaggerModel = new SwaggerModel(modelName, models[modelName]);
389
- this.modelsArray.push(swaggerModel);
390
- this.models[modelName] = swaggerModel;
391
- this.rawModels[modelName] = models[modelName];
392
- }
393
- }
394
- _ref = this.modelsArray;
395
- _results = [];
396
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
397
- model = _ref[_i];
398
- _results.push(model.setReferencedModels(this.models));
399
- }
400
- return _results;
224
+ }
225
+ }
226
+ if (response.basePath) {
227
+ this.basePath = response.basePath;
228
+ } else if (this.url.indexOf('?') > 0) {
229
+ this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
230
+ } else {
231
+ this.basePath = this.url;
232
+ }
233
+ if (isApi) {
234
+ var newName = response.resourcePath.replace(/\//g, '');
235
+ this.resourcePath = response.resourcePath;
236
+ var res = new SwaggerResource(response, this);
237
+ this.apis[newName] = res;
238
+ this.apisArray.push(res);
239
+ } else {
240
+ for (k = 0; k < response.apis.length; k++) {
241
+ resource = response.apis[k];
242
+ res = new SwaggerResource(resource, this);
243
+ this.apis[res.name] = res;
244
+ this.apisArray.push(res);
245
+ }
246
+ }
247
+ if (this.success) {
248
+ this.success();
249
+ }
250
+ return this;
251
+ };
252
+
253
+ SwaggerApi.prototype.selfReflect = function() {
254
+ var resource, resource_name, _ref;
255
+ if (this.apis == null) {
256
+ return false;
257
+ }
258
+ _ref = this.apis;
259
+ for (resource_name in _ref) {
260
+ resource = _ref[resource_name];
261
+ if (resource.ready == null) {
262
+ return false;
263
+ }
264
+ }
265
+ this.setConsolidatedModels();
266
+ this.ready = true;
267
+ if (this.success != null) {
268
+ return this.success();
269
+ }
270
+ };
271
+
272
+ SwaggerApi.prototype.fail = function(message) {
273
+ this.failure(message);
274
+ throw message;
275
+ };
276
+
277
+ SwaggerApi.prototype.setConsolidatedModels = function() {
278
+ var model, modelName, resource, resource_name, _i, _len, _ref, _ref1, _results;
279
+ this.modelsArray = [];
280
+ this.models = {};
281
+ _ref = this.apis;
282
+ for (resource_name in _ref) {
283
+ resource = _ref[resource_name];
284
+ for (modelName in resource.models) {
285
+ if (this.models[modelName] == null) {
286
+ this.models[modelName] = resource.models[modelName];
287
+ this.modelsArray.push(resource.models[modelName]);
401
288
  }
402
- };
403
-
404
- SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes, produces) {
405
- var method, o, op, r, ref, responseMessages, type, _i, _j, _len, _len1, _results;
406
- if (ops) {
407
- _results = [];
408
- for (_i = 0, _len = ops.length; _i < _len; _i++) {
409
- o = ops[_i];
410
- consumes = this.consumes;
411
- produces = this.produces;
412
- if (o.consumes != null) {
413
- consumes = o.consumes;
414
- } else {
415
- consumes = this.consumes;
416
- }
417
- if (o.produces != null) {
418
- produces = o.produces;
419
- } else {
420
- produces = this.produces;
421
- }
422
- type = o.type || o.responseClass;
423
- if (type === "array") {
424
- ref = null;
425
- if (o.items) {
426
- ref = o.items["type"] || o.items["$ref"];
427
- }
428
- type = "array[" + ref + "]";
429
- }
430
- responseMessages = o.responseMessages;
431
- method = o.method;
432
- if (o.httpMethod) {
433
- method = o.httpMethod;
434
- }
435
- if (o.supportedContentTypes) {
436
- consumes = o.supportedContentTypes;
437
- }
438
- if (o.errorResponses) {
439
- responseMessages = o.errorResponses;
440
- for (_j = 0, _len1 = responseMessages.length; _j < _len1; _j++) {
441
- r = responseMessages[_j];
442
- r.message = r.reason;
443
- r.reason = null;
444
- }
445
- }
446
- o.nickname = this.sanitize(o.nickname);
447
- op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, type, responseMessages, this, consumes, produces, o.authorizations);
448
- this.operations[op.nickname] = op;
449
- _results.push(this.operationsArray.push(op));
450
- }
451
- return _results;
289
+ }
290
+ }
291
+ _ref1 = this.modelsArray;
292
+ _results = [];
293
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
294
+ model = _ref1[_i];
295
+ _results.push(model.setReferencedModels(this.models));
296
+ }
297
+ return _results;
298
+ };
299
+
300
+ SwaggerApi.prototype.help = function() {
301
+ var operation, operation_name, parameter, resource, resource_name, _i, _len, _ref, _ref1, _ref2;
302
+ _ref = this.apis;
303
+ for (resource_name in _ref) {
304
+ resource = _ref[resource_name];
305
+ log(resource_name);
306
+ _ref1 = resource.operations;
307
+ for (operation_name in _ref1) {
308
+ operation = _ref1[operation_name];
309
+ log(" " + operation.nickname);
310
+ _ref2 = operation.parameters;
311
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
312
+ parameter = _ref2[_i];
313
+ log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
452
314
  }
453
- };
454
-
455
- SwaggerResource.prototype.sanitize = function(nickname) {
456
- var op;
457
- op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|./?,\\'""-]/g, '_');
458
- op = op.replace(/((_){2,})/g, '_');
459
- op = op.replace(/^(_)*/g, '');
460
- op = op.replace(/([_])*$/g, '');
461
- return op;
462
- };
463
-
464
- SwaggerResource.prototype.help = function() {
465
- var msg, operation, operation_name, parameter, _i, _len, _ref, _ref1, _results;
466
- _ref = this.operations;
467
- _results = [];
468
- for (operation_name in _ref) {
469
- operation = _ref[operation_name];
470
- msg = " " + operation.nickname;
471
- _ref1 = operation.parameters;
472
- for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
473
- parameter = _ref1[_i];
474
- msg.concat(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
315
+ }
316
+ }
317
+ return this;
318
+ };
319
+
320
+ var SwaggerResource = function(resourceObj, api) {
321
+ var _this = this;
322
+ this.api = api;
323
+ this.api = this.api;
324
+ consumes = (this.consumes | []);
325
+ produces = (this.produces | []);
326
+ this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
327
+ this.description = resourceObj.description;
328
+
329
+ var parts = this.path.split("/");
330
+ this.name = parts[parts.length - 1].replace('.{format}', '');
331
+ this.basePath = this.api.basePath;
332
+ this.operations = {};
333
+ this.operationsArray = [];
334
+ this.modelsArray = [];
335
+ this.models = {};
336
+ this.rawModels = {};
337
+ this.useJQuery = (typeof api.useJQuery !== 'undefined' ? api.useJQuery : null);
338
+
339
+ if ((resourceObj.apis != null) && (this.api.resourcePath != null)) {
340
+ this.addApiDeclaration(resourceObj);
341
+ } else {
342
+ if (this.path == null) {
343
+ this.api.fail("SwaggerResources must have a path.");
344
+ }
345
+ if (this.path.substring(0, 4) === 'http') {
346
+ this.url = this.path.replace('{format}', 'json');
347
+ } else {
348
+ this.url = this.api.basePath + this.path.replace('{format}', 'json');
349
+ }
350
+ this.api.progress('fetching resource ' + this.name + ': ' + this.url);
351
+ obj = {
352
+ url: this.url,
353
+ method: "get",
354
+ useJQuery: this.useJQuery,
355
+ headers: {
356
+ accept: "application/json"
357
+ },
358
+ on: {
359
+ response: function(resp) {
360
+ var responseObj = resp.obj || JSON.parse(resp.data);
361
+ return _this.addApiDeclaration(responseObj);
362
+ },
363
+ error: function(response) {
364
+ return _this.api.fail("Unable to read api '" +
365
+ _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")");
475
366
  }
476
- _results.push(msg);
477
367
  }
478
- return _results;
479
368
  };
480
-
481
- return SwaggerResource;
482
-
483
- })();
484
-
485
- SwaggerModel = (function() {
486
- function SwaggerModel(modelName, obj) {
487
- var prop, propertyName, value;
488
- this.name = obj.id != null ? obj.id : modelName;
489
- this.properties = [];
490
- for (propertyName in obj.properties) {
491
- if (obj.required != null) {
492
- for (value in obj.required) {
493
- if (propertyName === obj.required[value]) {
494
- obj.properties[propertyName].required = true;
495
- }
496
- }
497
- }
498
- prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]);
499
- this.properties.push(prop);
369
+ var e = typeof window !== 'undefined' ? window : exports;
370
+ e.authorizations.apply(obj);
371
+ new SwaggerHttp().execute(obj);
372
+ }
373
+ }
374
+
375
+ SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) {
376
+ var pos, url;
377
+ url = this.api.basePath;
378
+ pos = url.lastIndexOf(relativeBasePath);
379
+ var parts = url.split("/");
380
+ var rootUrl = parts[0] + "//" + parts[2];
381
+
382
+ if(relativeBasePath.indexOf("http") === 0)
383
+ return relativeBasePath;
384
+ if(relativeBasePath === "/")
385
+ return rootUrl;
386
+ if(relativeBasePath.substring(0, 1) == "/") {
387
+ // use root + relative
388
+ return rootUrl + relativeBasePath;
389
+ }
390
+ else {
391
+ var pos = this.basePath.lastIndexOf("/");
392
+ var base = this.basePath.substring(0, pos);
393
+ if(base.substring(base.length - 1) == "/")
394
+ return base + relativeBasePath;
395
+ else
396
+ return base + "/" + relativeBasePath;
397
+ }
398
+ };
399
+
400
+ SwaggerResource.prototype.addApiDeclaration = function(response) {
401
+ if (response.produces != null)
402
+ this.produces = response.produces;
403
+ if (response.consumes != null)
404
+ this.consumes = response.consumes;
405
+ if ((response.basePath != null) && response.basePath.replace(/\s/g, '').length > 0)
406
+ this.basePath = response.basePath.indexOf("http") === -1 ? this.getAbsoluteBasePath(response.basePath) : response.basePath;
407
+
408
+ this.addModels(response.models);
409
+ if (response.apis) {
410
+ for (var i = 0 ; i < response.apis.length; i++) {
411
+ var endpoint = response.apis[i];
412
+ this.addOperations(endpoint.path, endpoint.operations, response.consumes, response.produces);
413
+ }
414
+ }
415
+ this.api[this.name] = this;
416
+ this.ready = true;
417
+ return this.api.selfReflect();
418
+ };
419
+
420
+ SwaggerResource.prototype.addModels = function(models) {
421
+ if (models != null) {
422
+ var modelName;
423
+ for (modelName in models) {
424
+ if (this.models[modelName] == null) {
425
+ var swaggerModel = new SwaggerModel(modelName, models[modelName]);
426
+ this.modelsArray.push(swaggerModel);
427
+ this.models[modelName] = swaggerModel;
428
+ this.rawModels[modelName] = models[modelName];
500
429
  }
501
430
  }
502
-
503
- SwaggerModel.prototype.setReferencedModels = function(allModels) {
504
- var prop, type, _i, _len, _ref, _results;
505
- _ref = this.properties;
506
- _results = [];
507
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
508
- prop = _ref[_i];
509
- type = prop.type || prop.dataType;
510
- if (allModels[type] != null) {
511
- _results.push(prop.refModel = allModels[type]);
512
- } else if ((prop.refDataType != null) && (allModels[prop.refDataType] != null)) {
513
- _results.push(prop.refModel = allModels[prop.refDataType]);
514
- } else {
515
- _results.push(void 0);
431
+ var output = [];
432
+ for (var i = 0; i < this.modelsArray.length; i++) {
433
+ model = this.modelsArray[i];
434
+ output.push(model.setReferencedModels(this.models));
435
+ }
436
+ return output;
437
+ }
438
+ };
439
+
440
+ SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes, produces) {
441
+ if (ops) {
442
+ output = [];
443
+ for (var i = 0; i < ops.length; i++) {
444
+ o = ops[i];
445
+ consumes = this.consumes;
446
+ produces = this.produces;
447
+ if (o.consumes != null)
448
+ consumes = o.consumes;
449
+ else
450
+ consumes = this.consumes;
451
+
452
+ if (o.produces != null)
453
+ produces = o.produces;
454
+ else
455
+ produces = this.produces;
456
+ type = (o.type||o.responseClass);
457
+
458
+ if (type === "array") {
459
+ ref = null;
460
+ if (o.items)
461
+ ref = o.items["type"] || o.items["$ref"];
462
+ type = "array[" + ref + "]";
463
+ }
464
+ responseMessages = o.responseMessages;
465
+ method = o.method;
466
+ if (o.httpMethod) {
467
+ method = o.httpMethod;
468
+ }
469
+ if (o.supportedContentTypes) {
470
+ consumes = o.supportedContentTypes;
471
+ }
472
+ if (o.errorResponses) {
473
+ responseMessages = o.errorResponses;
474
+ for (var j = 0; j < responseMessages.length; j++) {
475
+ r = responseMessages[j];
476
+ r.message = r.reason;
477
+ r.reason = null;
516
478
  }
517
479
  }
518
- return _results;
519
- };
520
-
521
- SwaggerModel.prototype.getMockSignature = function(modelsToIgnore) {
522
- var classClose, classOpen, prop, propertiesStr, returnVal, strong, strongClose, stronger, _i, _j, _len, _len1, _ref, _ref1;
523
- propertiesStr = [];
524
- _ref = this.properties;
525
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
526
- prop = _ref[_i];
527
- propertiesStr.push(prop.toString());
528
- }
529
- strong = '<span class="strong">';
530
- stronger = '<span class="stronger">';
531
- strongClose = '</span>';
532
- classOpen = strong + this.name + ' {' + strongClose;
533
- classClose = strong + '}' + strongClose;
534
- returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;
535
- if (!modelsToIgnore) {
536
- modelsToIgnore = [];
537
- }
538
- modelsToIgnore.push(this);
539
- _ref1 = this.properties;
540
- for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
541
- prop = _ref1[_j];
542
- if ((prop.refModel != null) && modelsToIgnore.indexOf(prop.refModel) === -1) {
543
- returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));
480
+ o.nickname = this.sanitize(o.nickname);
481
+ op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, type, responseMessages, this, consumes, produces, o.authorizations);
482
+ this.operations[op.nickname] = op;
483
+ output.push(this.operationsArray.push(op));
484
+ }
485
+ return output;
486
+ }
487
+ };
488
+
489
+ SwaggerResource.prototype.sanitize = function(nickname) {
490
+ var op;
491
+ op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|.\/?,\\'""-]/g, '_');
492
+ op = op.replace(/((_){2,})/g, '_');
493
+ op = op.replace(/^(_)*/g, '');
494
+ op = op.replace(/([_])*$/g, '');
495
+ return op;
496
+ };
497
+
498
+ SwaggerResource.prototype.help = function() {
499
+ var op = this.operations;
500
+ var output = [];
501
+ var operation_name;
502
+ for (operation_name in op) {
503
+ operation = op[operation_name];
504
+ var msg = " " + operation.nickname;
505
+ for (var i = 0; i < operation.parameters; i++) {
506
+ parameter = operation.parameters[i];
507
+ msg.concat(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
508
+ }
509
+ output.push(msg);
510
+ }
511
+ return output;
512
+ };
513
+
514
+ var SwaggerModel = function(modelName, obj) {
515
+ this.name = obj.id != null ? obj.id : modelName;
516
+ this.properties = [];
517
+ var propertyName;
518
+ for (propertyName in obj.properties) {
519
+ if (obj.required != null) {
520
+ var value;
521
+ for (value in obj.required) {
522
+ if (propertyName === obj.required[value]) {
523
+ obj.properties[propertyName].required = true;
544
524
  }
545
525
  }
546
- return returnVal;
547
- };
548
-
549
- SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) {
550
- var prop, result, _i, _len, _ref;
551
- result = {};
552
- modelsToIgnore = modelsToIgnore || [];
553
- modelsToIgnore.push(this.name);
554
- _ref = this.properties;
555
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
556
- prop = _ref[_i];
557
- result[prop.name] = prop.getSampleValue(modelsToIgnore);
558
- }
559
- modelsToIgnore.pop(this.name);
560
- return result;
561
- };
562
-
563
- return SwaggerModel;
564
-
565
- })();
526
+ }
527
+ prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]);
528
+ this.properties.push(prop);
529
+ }
530
+ }
531
+
532
+ SwaggerModel.prototype.setReferencedModels = function(allModels) {
533
+ var results = [];
534
+ for (var i = 0; i < this.properties.length; i++) {
535
+ var property = this.properties[i];
536
+ var type = property.type || property.dataType;
537
+ if (allModels[type] != null)
538
+ results.push(property.refModel = allModels[type]);
539
+ else if ((property.refDataType != null) && (allModels[property.refDataType] != null))
540
+ results.push(property.refModel = allModels[property.refDataType]);
541
+ else
542
+ results.push(void 0);
543
+ }
544
+ return results;
545
+ };
546
+
547
+ SwaggerModel.prototype.getMockSignature = function(modelsToIgnore) {
548
+ var propertiesStr = [];
549
+ for (var i = 0; i < this.properties.length; i++) {
550
+ prop = this.properties[i];
551
+ propertiesStr.push(prop.toString());
552
+ }
553
+
554
+ var strong = '<span class="strong">';
555
+ var stronger = '<span class="stronger">';
556
+ var strongClose = '</span>';
557
+ var classOpen = strong + this.name + ' {' + strongClose;
558
+ var classClose = strong + '}' + strongClose;
559
+ var returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;
560
+ if (!modelsToIgnore)
561
+ modelsToIgnore = [];
562
+ modelsToIgnore.push(this.name);
563
+
564
+ for (var i = 0; i < this.properties.length; i++) {
565
+ prop = this.properties[i];
566
+ if ((prop.refModel != null) && modelsToIgnore.indexOf(prop.refModel.name) === -1) {
567
+ returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));
568
+ }
569
+ }
570
+ return returnVal;
571
+ };
572
+
573
+ SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) {
574
+ if(sampleModels[this.name]) {
575
+ return sampleModels[this.name];
576
+ }
577
+ else {
578
+ var result = {};
579
+ var modelsToIgnore = (modelsToIgnore||[])
580
+ modelsToIgnore.push(this.name);
581
+ for (var i = 0; i < this.properties.length; i++) {
582
+ prop = this.properties[i];
583
+ result[prop.name] = prop.getSampleValue(modelsToIgnore);
584
+ }
585
+ modelsToIgnore.pop(this.name);
586
+ return result;
587
+ }
588
+ };
589
+
590
+ var SwaggerModelProperty = function(name, obj) {
591
+ this.name = name;
592
+ this.dataType = obj.type || obj.dataType || obj["$ref"];
593
+ this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
594
+ this.descr = obj.description;
595
+ this.required = obj.required;
596
+ if (obj.items != null) {
597
+ if (obj.items.type != null) {
598
+ this.refDataType = obj.items.type;
599
+ }
600
+ if (obj.items.$ref != null) {
601
+ this.refDataType = obj.items.$ref;
602
+ }
603
+ }
604
+ this.dataTypeWithRef = this.refDataType != null ? (this.dataType + '[' + this.refDataType + ']') : this.dataType;
605
+ if (obj.allowableValues != null) {
606
+ this.valueType = obj.allowableValues.valueType;
607
+ this.values = obj.allowableValues.values;
608
+ if (this.values != null) {
609
+ this.valuesString = "'" + this.values.join("' or '") + "'";
610
+ }
611
+ }
612
+ if (obj["enum"] != null) {
613
+ this.valueType = "string";
614
+ this.values = obj["enum"];
615
+ if (this.values != null) {
616
+ this.valueString = "'" + this.values.join("' or '") + "'";
617
+ }
618
+ }
619
+ }
620
+
621
+ SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) {
622
+ var result;
623
+ if ((this.refModel != null) && (modelsToIgnore.indexOf(prop.refModel.name) === -1)) {
624
+ result = this.refModel.createJSONSample(modelsToIgnore);
625
+ } else {
626
+ if (this.isCollection) {
627
+ result = this.toSampleValue(this.refDataType);
628
+ } else {
629
+ result = this.toSampleValue(this.dataType);
630
+ }
631
+ }
632
+ if (this.isCollection) {
633
+ return [result];
634
+ } else {
635
+ return result;
636
+ }
637
+ };
638
+
639
+ SwaggerModelProperty.prototype.toSampleValue = function(value) {
640
+ var result;
641
+ if (value === "integer") {
642
+ result = 0;
643
+ } else if (value === "boolean") {
644
+ result = false;
645
+ } else if (value === "double" || value === "number") {
646
+ result = 0.0;
647
+ } else if (value === "string") {
648
+ result = "";
649
+ } else {
650
+ result = value;
651
+ }
652
+ return result;
653
+ };
654
+
655
+ SwaggerModelProperty.prototype.toString = function() {
656
+ var req = this.required ? 'propReq' : 'propOpt';
657
+ var str = '<span class="propName ' + req + '">' + this.name + '</span> (<span class="propType">' + this.dataTypeWithRef + '</span>';
658
+ if (!this.required) {
659
+ str += ', <span class="propOptKey">optional</span>';
660
+ }
661
+ str += ')';
662
+ if (this.values != null) {
663
+ str += " = <span class='propVals'>['" + this.values.join("' or '") + "']</span>";
664
+ }
665
+ if (this.descr != null) {
666
+ str += ': <span class="propDesc">' + this.descr + '</span>';
667
+ }
668
+ return str;
669
+ };
670
+
671
+ var SwaggerOperation = function(nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces, authorizations) {
672
+ var _this = this;
673
+
674
+ var errors = [];
675
+ this.nickname = (nickname||errors.push("SwaggerOperations must have a nickname."));
676
+ this.path = (path||errors.push("SwaggerOperation " + nickname + " is missing path."));
677
+ this.method = (method||errors.push("SwaggerOperation " + nickname + " is missing method."));
678
+ this.parameters = parameters != null ? parameters : [];
679
+ this.summary = summary;
680
+ this.notes = notes;
681
+ this.type = type;
682
+ this.responseMessages = (responseMessages||[]);
683
+ this.resource = (resource||errors.push("Resource is required"));
684
+ this.consumes = consumes;
685
+ this.produces = produces;
686
+ this.authorizations = authorizations;
687
+ this["do"] = __bind(this["do"], this);
688
+
689
+ if (errors.length > 0)
690
+ this.resource.api.fail(errors);
691
+
692
+ this.path = this.path.replace('{format}', 'json');
693
+ this.method = this.method.toLowerCase();
694
+ this.isGetMethod = this.method === "get";
695
+
696
+ this.resourceName = this.resource.name;
697
+ if(typeof this.type !== 'undefined' && this.type === 'void')
698
+ this.type = null;
699
+ else {
700
+ this.responseClassSignature = this.getSignature(this.type, this.resource.models);
701
+ this.responseSampleJSON = this.getSampleJSON(this.type, this.resource.models);
702
+ }
703
+
704
+ for(var i = 0; i < this.parameters.length; i ++) {
705
+ var param = this.parameters[i];
706
+ // might take this away
707
+ param.name = param.name || param.type || param.dataType;
708
+
709
+ // for 1.1 compatibility
710
+ var type = param.type || param.dataType;
711
+ if(type === 'array') {
712
+ type = 'array[' + (param.items.$ref ? param.items.$ref : param.items.type) + ']';
713
+ }
714
+ param.type = type;
566
715
 
567
- SwaggerModelProperty = (function() {
568
- function SwaggerModelProperty(name, obj) {
569
- this.name = name;
570
- this.dataType = obj.type || obj.dataType || obj["$ref"];
571
- this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
572
- this.descr = obj.description;
573
- this.required = obj.required;
574
- if (obj.items != null) {
575
- if (obj.items.type != null) {
576
- this.refDataType = obj.items.type;
577
- }
578
- if (obj.items.$ref != null) {
579
- this.refDataType = obj.items.$ref;
580
- }
581
- }
582
- this.dataTypeWithRef = this.refDataType != null ? this.dataType + '[' + this.refDataType + ']' : this.dataType;
583
- if (obj.allowableValues != null) {
584
- this.valueType = obj.allowableValues.valueType;
585
- this.values = obj.allowableValues.values;
586
- if (this.values != null) {
587
- this.valuesString = "'" + this.values.join("' or '") + "'";
716
+ if(type.toLowerCase() === 'boolean') {
717
+ param.allowableValues = {};
718
+ param.allowableValues.values = ["true", "false"];
719
+ }
720
+ param.signature = this.getSignature(type, this.resource.models);
721
+ param.sampleJSON = this.getSampleJSON(type, this.resource.models);
722
+
723
+ var enumValue = param["enum"];
724
+ if(enumValue != null) {
725
+ param.isList = true;
726
+ param.allowableValues = {};
727
+ param.allowableValues.descriptiveValues = [];
728
+
729
+ for(var j = 0; j < enumValue.length; j++) {
730
+ var v = enumValue[j];
731
+ if(param.defaultValue != null) {
732
+ param.allowableValues.descriptiveValues.push ({
733
+ value: String(v),
734
+ isDefault: (v === param.defaultValue)
735
+ });
588
736
  }
589
- }
590
- if (obj["enum"] != null) {
591
- this.valueType = "string";
592
- this.values = obj["enum"];
593
- if (this.values != null) {
594
- this.valueString = "'" + this.values.join("' or '") + "'";
737
+ else {
738
+ param.allowableValues.descriptiveValues.push ({
739
+ value: String(v),
740
+ isDefault: false
741
+ });
595
742
  }
596
743
  }
597
744
  }
598
-
599
- SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) {
600
- var result;
601
- if ((this.refModel != null) && (modelsToIgnore[this.refModel.name] === 'undefined')) {
602
- result = this.refModel.createJSONSample(modelsToIgnore);
603
- } else {
604
- if (this.isCollection) {
605
- result = this.toSampleValue(this.refDataType);
606
- } else {
607
- result = this.toSampleValue(this.dataType);
608
- }
609
- }
610
- if (this.isCollection) {
611
- return [result];
612
- } else {
613
- return result;
614
- }
615
- };
616
-
617
- SwaggerModelProperty.prototype.toSampleValue = function(value) {
618
- var result;
619
- if (value === "integer") {
620
- result = 0;
621
- } else if (value === "boolean") {
622
- result = false;
623
- } else if (value === "double") {
624
- result = 0.0;
625
- } else if (value === "string") {
626
- result = "";
627
- } else {
628
- result = value;
629
- }
630
- return result;
631
- };
632
-
633
- SwaggerModelProperty.prototype.toString = function() {
634
- var req, str;
635
- req = this.required ? 'propReq' : 'propOpt';
636
- str = '<span class="propName ' + req + '">' + this.name + '</span> (<span class="propType">' + this.dataTypeWithRef + '</span>';
637
- if (!this.required) {
638
- str += ', <span class="propOptKey">optional</span>';
639
- }
640
- str += ')';
641
- if (this.values != null) {
642
- str += " = <span class='propVals'>['" + this.values.join("' or '") + "']</span>";
643
- }
644
- if (this.descr != null) {
645
- str += ': <span class="propDesc">' + this.descr + '</span>';
646
- }
647
- return str;
648
- };
649
-
650
- return SwaggerModelProperty;
651
-
652
- })();
653
-
654
- SwaggerOperation = (function() {
655
- function SwaggerOperation(nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces, authorizations) {
656
- var parameter, v, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3,
657
- _this = this;
658
- this.nickname = nickname;
659
- this.path = path;
660
- this.method = method;
661
- this.parameters = parameters != null ? parameters : [];
662
- this.summary = summary;
663
- this.notes = notes;
664
- this.type = type;
665
- this.responseMessages = responseMessages;
666
- this.resource = resource;
667
- this.consumes = consumes;
668
- this.produces = produces;
669
- this.authorizations = authorizations;
670
- this["do"] = __bind(this["do"], this);
671
- if (this.nickname == null) {
672
- this.resource.api.fail("SwaggerOperations must have a nickname.");
673
- }
674
- if (this.path == null) {
675
- this.resource.api.fail("SwaggerOperation " + nickname + " is missing path.");
676
- }
677
- if (this.method == null) {
678
- this.resource.api.fail("SwaggerOperation " + nickname + " is missing method.");
679
- }
680
- this.path = this.path.replace('{format}', 'json');
681
- this.method = this.method.toLowerCase();
682
- this.isGetMethod = this.method === "get";
683
- this.resourceName = this.resource.name;
684
- if (((_ref = this.type) != null ? _ref.toLowerCase() : void 0) === 'void') {
685
- this.type = void 0;
686
- }
687
- if (this.type != null) {
688
- this.responseClassSignature = this.getSignature(this.type, this.resource.models);
689
- this.responseSampleJSON = this.getSampleJSON(this.type, this.resource.models);
690
- }
691
- this.responseMessages = this.responseMessages || [];
692
- _ref1 = this.parameters;
693
- for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
694
- parameter = _ref1[_i];
695
- parameter.name = parameter.name || parameter.type || parameter.dataType;
696
- type = parameter.type || parameter.dataType;
697
- if (type.toLowerCase() === 'boolean') {
698
- parameter.allowableValues = {};
699
- parameter.allowableValues.values = ["true", "false"];
700
- }
701
- parameter.signature = this.getSignature(type, this.resource.models);
702
- parameter.sampleJSON = this.getSampleJSON(type, this.resource.models);
703
- if (parameter["enum"] != null) {
704
- parameter.isList = true;
705
- parameter.allowableValues = {};
706
- parameter.allowableValues.descriptiveValues = [];
707
- _ref2 = parameter["enum"];
708
- for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
709
- v = _ref2[_j];
710
- if ((parameter.defaultValue != null) && parameter.defaultValue === v) {
711
- parameter.allowableValues.descriptiveValues.push({
745
+ else if(param.allowableValues != null) {
746
+ if(param.allowableValues.valueType === "RANGE")
747
+ param.isRange = true;
748
+ else
749
+ param.isList = true;
750
+ if(param.allowableValues != null) {
751
+ param.allowableValues.descriptiveValues = [];
752
+ if(param.allowableValues.values) {
753
+ for(var j = 0; j < param.allowableValues.values.length; j++){
754
+ var v = param.allowableValues.values[j];
755
+ if(param.defaultValue != null) {
756
+ param.allowableValues.descriptiveValues.push ({
712
757
  value: String(v),
713
- isDefault: true
758
+ isDefault: (v === param.defaultValue)
714
759
  });
715
- } else {
716
- parameter.allowableValues.descriptiveValues.push({
760
+ }
761
+ else {
762
+ param.allowableValues.descriptiveValues.push ({
717
763
  value: String(v),
718
764
  isDefault: false
719
765
  });
720
766
  }
721
767
  }
722
768
  }
723
- if (parameter.allowableValues != null) {
724
- if (parameter.allowableValues.valueType === "RANGE") {
725
- parameter.isRange = true;
726
- } else {
727
- parameter.isList = true;
728
- }
729
- if (parameter.allowableValues.values != null) {
730
- parameter.allowableValues.descriptiveValues = [];
731
- _ref3 = parameter.allowableValues.values;
732
- for (_k = 0, _len2 = _ref3.length; _k < _len2; _k++) {
733
- v = _ref3[_k];
734
- if ((parameter.defaultValue != null) && parameter.defaultValue === v) {
735
- parameter.allowableValues.descriptiveValues.push({
736
- value: v,
737
- isDefault: true
738
- });
739
- } else {
740
- parameter.allowableValues.descriptiveValues.push({
741
- value: v,
742
- isDefault: false
743
- });
744
- }
745
- }
746
- }
747
- }
748
769
  }
749
- this.resource[this.nickname] = function(args, callback, error) {
750
- return _this["do"](args, callback, error);
751
- };
752
- this.resource[this.nickname].help = function() {
753
- return _this.help();
754
- };
755
770
  }
756
-
757
- SwaggerOperation.prototype.isListType = function(type) {
758
- if (type.indexOf('[') >= 0) {
759
- return type.substring(type.indexOf('[') + 1, type.indexOf(']'));
760
- } else {
761
- return void 0;
762
- }
763
- };
764
-
765
- SwaggerOperation.prototype.getSignature = function(type, models) {
766
- var isPrimitive, listType;
767
- listType = this.isListType(type);
768
- isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
769
- if (isPrimitive) {
770
- return type;
771
- } else {
772
- if (listType != null) {
773
- return models[listType].getMockSignature();
774
- } else {
775
- return models[type].getMockSignature();
776
- }
777
- }
778
- };
779
-
780
- SwaggerOperation.prototype.getSampleJSON = function(type, models) {
781
- var isPrimitive, listType, val;
782
- listType = this.isListType(type);
783
- isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
784
- val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[type].createJSONSample());
785
- if (val) {
786
- val = listType ? [val] : val;
771
+ }
772
+ this.resource[this.nickname] = function(args, callback, error) {
773
+ return _this["do"](args, callback, error);
774
+ };
775
+ this.resource[this.nickname].help = function() {
776
+ return _this.help();
777
+ };
778
+ }
779
+
780
+ SwaggerOperation.prototype.isListType = function(type) {
781
+ if (type && type.indexOf('[') >= 0) {
782
+ return type.substring(type.indexOf('[') + 1, type.indexOf(']'));
783
+ } else {
784
+ return void 0;
785
+ }
786
+ };
787
+
788
+ SwaggerOperation.prototype.getSignature = function(type, models) {
789
+ var isPrimitive, listType;
790
+ listType = this.isListType(type);
791
+ isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
792
+ if (isPrimitive) {
793
+ return type;
794
+ } else {
795
+ if (listType != null) {
796
+ return models[listType].getMockSignature();
797
+ } else {
798
+ return models[type].getMockSignature();
799
+ }
800
+ }
801
+ };
802
+
803
+ SwaggerOperation.prototype.getSampleJSON = function(type, models) {
804
+ var isPrimitive, listType, val;
805
+ listType = this.isListType(type);
806
+ isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
807
+ val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[type].createJSONSample());
808
+ if (val) {
809
+ val = listType ? [val] : val;
810
+ if(typeof val == "string")
811
+ return val;
812
+ else if(typeof val === "object") {
813
+ var t = val;
814
+ if(val instanceof Array && val.length > 0) {
815
+ t = val[0];
816
+ }
817
+ if(t.nodeName) {
818
+ var xmlString = new XMLSerializer().serializeToString(t);
819
+ return this.formatXml(xmlString);
820
+ }
821
+ else
787
822
  return JSON.stringify(val, null, 2);
788
- }
823
+ }
824
+ else
825
+ return val;
826
+ }
827
+ };
828
+
829
+ SwaggerOperation.prototype["do"] = function(args, opts, callback, error) {
830
+ var key, param, params, possibleParams, req, requestContentType, responseContentType, value, _i, _len, _ref;
831
+ if (args == null) {
832
+ args = {};
833
+ }
834
+ if (opts == null) {
835
+ opts = {};
836
+ }
837
+ requestContentType = null;
838
+ responseContentType = null;
839
+ if ((typeof args) === "function") {
840
+ error = opts;
841
+ callback = args;
842
+ args = {};
843
+ }
844
+ if ((typeof opts) === "function") {
845
+ error = callback;
846
+ callback = opts;
847
+ }
848
+ if (error == null) {
849
+ error = function(xhr, textStatus, error) {
850
+ return log(xhr, textStatus, error);
789
851
  };
790
-
791
- SwaggerOperation.prototype["do"] = function(args, opts, callback, error) {
792
- var key, param, params, possibleParams, req, requestContentType, responseContentType, value, _i, _len, _ref;
793
- if (args == null) {
794
- args = {};
795
- }
796
- if (opts == null) {
797
- opts = {};
798
- }
799
- requestContentType = null;
800
- responseContentType = null;
801
- if ((typeof args) === "function") {
802
- error = opts;
803
- callback = args;
804
- args = {};
805
- }
806
- if ((typeof opts) === "function") {
807
- error = callback;
808
- callback = opts;
809
- }
810
- if (error == null) {
811
- error = function(xhr, textStatus, error) {
812
- return log(xhr, textStatus, error);
813
- };
814
- }
815
- if (callback == null) {
816
- callback = function(response) {
817
- var content;
818
- content = null;
819
- if (response != null) {
820
- content = response.data;
821
- } else {
822
- content = "no data";
823
- }
824
- return log("default callback: " + content);
825
- };
826
- }
827
- params = {};
828
- params.headers = [];
829
- if (args.headers != null) {
830
- params.headers = args.headers;
831
- delete args.headers;
832
- }
833
- _ref = this.parameters;
834
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
835
- param = _ref[_i];
836
- if (param.paramType === "header") {
837
- if (args[param.name]) {
838
- params.headers[param.name] = args[param.name];
839
- }
840
- }
841
- }
842
- if (args.body != null) {
843
- params.body = args.body;
844
- delete args.body;
845
- }
846
- possibleParams = (function() {
847
- var _j, _len1, _ref1, _results;
848
- _ref1 = this.parameters;
849
- _results = [];
850
- for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
851
- param = _ref1[_j];
852
- if (param.paramType === "form" || param.paramType.toLowerCase() === "file") {
853
- _results.push(param);
854
- }
855
- }
856
- return _results;
857
- }).call(this);
858
- if (possibleParams) {
859
- for (key in possibleParams) {
860
- value = possibleParams[key];
861
- if (args[value.name]) {
862
- params[value.name] = args[value.name];
863
- }
864
- }
865
- }
866
- req = new SwaggerRequest(this.method, this.urlify(args), params, opts, callback, error, this);
867
- if (opts.mock != null) {
868
- return req;
852
+ }
853
+ if (callback == null) {
854
+ callback = function(response) {
855
+ var content;
856
+ content = null;
857
+ if (response != null) {
858
+ content = response.data;
869
859
  } else {
870
- return true;
860
+ content = "no data";
871
861
  }
862
+ return log("default callback: " + content);
872
863
  };
873
-
874
- SwaggerOperation.prototype.pathJson = function() {
875
- return this.path.replace("{format}", "json");
876
- };
877
-
878
- SwaggerOperation.prototype.pathXml = function() {
879
- return this.path.replace("{format}", "xml");
880
- };
881
-
882
- SwaggerOperation.prototype.urlify = function(args) {
883
- var param, queryParams, reg, url, _i, _j, _len, _len1, _ref, _ref1;
884
- url = this.resource.basePath + this.pathJson();
885
- _ref = this.parameters;
886
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
887
- param = _ref[_i];
888
- if (param.paramType === 'path') {
889
- if (args[param.name]) {
890
- reg = new RegExp('\{' + param.name + '[^\}]*\}', 'gi');
891
- url = url.replace(reg, encodeURIComponent(args[param.name]));
892
- delete args[param.name];
893
- } else {
894
- throw "" + param.name + " is a required path param.";
895
- }
896
- }
897
- }
898
- queryParams = "";
899
- _ref1 = this.parameters;
900
- for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
901
- param = _ref1[_j];
902
- if (param.paramType === 'query') {
903
- if (args[param.name]) {
904
- if (queryParams !== "") {
905
- queryParams += "&";
906
- }
907
- queryParams += encodeURIComponent(param.name) + '=' + encodeURIComponent(args[param.name]);
908
- }
909
- }
910
- }
911
- if ((queryParams != null) && queryParams.length > 0) {
912
- url += "?" + queryParams;
913
- }
914
- return url;
915
- };
916
-
917
- SwaggerOperation.prototype.supportHeaderParams = function() {
918
- return this.resource.api.supportHeaderParams;
919
- };
920
-
921
- SwaggerOperation.prototype.supportedSubmitMethods = function() {
922
- return this.resource.api.supportedSubmitMethods;
923
- };
924
-
925
- SwaggerOperation.prototype.getQueryParams = function(args) {
926
- return this.getMatchingParams(['query'], args);
927
- };
928
-
929
- SwaggerOperation.prototype.getHeaderParams = function(args) {
930
- return this.getMatchingParams(['header'], args);
931
- };
932
-
933
- SwaggerOperation.prototype.getMatchingParams = function(paramTypes, args) {
934
- var matchingParams, name, param, value, _i, _len, _ref, _ref1;
935
- matchingParams = {};
936
- _ref = this.parameters;
937
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
938
- param = _ref[_i];
939
- if (args && args[param.name]) {
940
- matchingParams[param.name] = args[param.name];
941
- }
942
- }
943
- _ref1 = this.resource.api.headers;
944
- for (name in _ref1) {
945
- value = _ref1[name];
946
- matchingParams[name] = value;
864
+ }
865
+ params = {};
866
+ params.headers = [];
867
+ if (args.headers != null) {
868
+ params.headers = args.headers;
869
+ delete args.headers;
870
+ }
871
+
872
+ var possibleParams = [];
873
+ for(var i = 0; i < this.parameters.length; i++) {
874
+ var param = this.parameters[i];
875
+ if(param.paramType === 'header') {
876
+ if(args[param.name])
877
+ params.headers[param.name] = args[param.name];
878
+ }
879
+ else if(param.paramType === 'form' || param.paramType.toLowerCase() === 'file')
880
+ possibleParams.push(param);
881
+ }
882
+
883
+ if (args.body != null) {
884
+ params.body = args.body;
885
+ delete args.body;
886
+ }
887
+
888
+ if (possibleParams) {
889
+ var key;
890
+ for (key in possibleParams) {
891
+ value = possibleParams[key];
892
+ if (args[value.name]) {
893
+ params[value.name] = args[value.name];
947
894
  }
948
- return matchingParams;
949
- };
895
+ }
896
+ }
897
+
898
+ req = new SwaggerRequest(this.method, this.urlify(args), params, opts, callback, error, this);
899
+ if (opts.mock != null) {
900
+ return req;
901
+ } else {
902
+ return true;
903
+ }
904
+ };
905
+
906
+ SwaggerOperation.prototype.pathJson = function() {
907
+ return this.path.replace("{format}", "json");
908
+ };
909
+
910
+ SwaggerOperation.prototype.pathXml = function() {
911
+ return this.path.replace("{format}", "xml");
912
+ };
913
+
914
+ SwaggerOperation.prototype.encodePathParam = function(pathParam) {
915
+ var encParts, part, parts, _i, _len;
916
+ pathParam = pathParam.toString();
917
+ if (pathParam.indexOf("/") === -1) {
918
+ return encodeURIComponent(pathParam);
919
+ } else {
920
+ parts = pathParam.split("/");
921
+ encParts = [];
922
+ for (_i = 0, _len = parts.length; _i < _len; _i++) {
923
+ part = parts[_i];
924
+ encParts.push(encodeURIComponent(part));
925
+ }
926
+ return encParts.join("/");
927
+ }
928
+ };
929
+
930
+ SwaggerOperation.prototype.urlify = function(args) {
931
+ var url = this.resource.basePath + this.pathJson();
932
+ var params = this.parameters;
933
+ for(var i = 0; i < params.length; i ++){
934
+ var param = params[i];
935
+ if (param.paramType === 'path') {
936
+ if(args[param.name]) {
937
+ // apply path params and remove from args
938
+ var reg = new RegExp('\{' + param.name + '[^\}]*\}', 'gi');
939
+ url = url.replace(reg, this.encodePathParam(args[param.name]));
940
+ delete args[param.name];
941
+ }
942
+ else
943
+ throw "" + param.name + " is a required path param.";
944
+ }
945
+ }
950
946
 
951
- SwaggerOperation.prototype.help = function() {
952
- var msg, parameter, _i, _len, _ref;
953
- msg = "";
954
- _ref = this.parameters;
955
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
956
- parameter = _ref[_i];
957
- if (msg !== "") {
958
- msg += "\n";
959
- }
960
- msg += "* " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description;
947
+ var queryParams = "";
948
+ for(var i = 0; i < params.length; i ++){
949
+ var param = params[i];
950
+ if(param.paramType === 'query') {
951
+ if (args[param.name] !== undefined) {
952
+ if (queryParams !== '')
953
+ queryParams += "&";
954
+ queryParams += encodeURIComponent(param.name) + '=' + encodeURIComponent(args[param.name]);
961
955
  }
962
- return msg;
956
+ }
957
+ }
958
+ if ((queryParams != null) && queryParams.length > 0)
959
+ url += '?' + queryParams;
960
+ return url;
961
+ };
962
+
963
+ SwaggerOperation.prototype.supportHeaderParams = function() {
964
+ return this.resource.api.supportHeaderParams;
965
+ };
966
+
967
+ SwaggerOperation.prototype.supportedSubmitMethods = function() {
968
+ return this.resource.api.supportedSubmitMethods;
969
+ };
970
+
971
+ SwaggerOperation.prototype.getQueryParams = function(args) {
972
+ return this.getMatchingParams(['query'], args);
973
+ };
974
+
975
+ SwaggerOperation.prototype.getHeaderParams = function(args) {
976
+ return this.getMatchingParams(['header'], args);
977
+ };
978
+
979
+ SwaggerOperation.prototype.getMatchingParams = function(paramTypes, args) {
980
+ var matchingParams = {};
981
+ var params = this.parameters;
982
+ for (var i = 0; i < params.length; i++) {
983
+ param = params[i];
984
+ if (args && args[param.name])
985
+ matchingParams[param.name] = args[param.name];
986
+ }
987
+ var headers = this.resource.api.headers;
988
+ var name;
989
+ for (name in headers) {
990
+ var value = headers[name];
991
+ matchingParams[name] = value;
992
+ }
993
+ return matchingParams;
994
+ };
995
+
996
+ SwaggerOperation.prototype.help = function() {
997
+ var msg = "";
998
+ var params = this.parameters;
999
+ for (var i = 0; i < params.length; i++) {
1000
+ var param = params[i];
1001
+ if (msg !== "")
1002
+ msg += "\n";
1003
+ msg += "* " + param.name + (param.required ? ' (required)' : '') + " - " + param.description;
1004
+ }
1005
+ return msg;
1006
+ };
1007
+
1008
+
1009
+ SwaggerOperation.prototype.formatXml = function(xml) {
1010
+ var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;
1011
+ reg = /(>)(<)(\/*)/g;
1012
+ wsexp = /[ ]*(.*)[ ]+\n/g;
1013
+ contexp = /(<.+>)(.+\n)/g;
1014
+ xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
1015
+ pad = 0;
1016
+ formatted = '';
1017
+ lines = xml.split('\n');
1018
+ indent = 0;
1019
+ lastType = 'other';
1020
+ transitions = {
1021
+ 'single->single': 0,
1022
+ 'single->closing': -1,
1023
+ 'single->opening': 0,
1024
+ 'single->other': 0,
1025
+ 'closing->single': 0,
1026
+ 'closing->closing': -1,
1027
+ 'closing->opening': 0,
1028
+ 'closing->other': 0,
1029
+ 'opening->single': 1,
1030
+ 'opening->closing': 0,
1031
+ 'opening->opening': 1,
1032
+ 'opening->other': 1,
1033
+ 'other->single': 0,
1034
+ 'other->closing': -1,
1035
+ 'other->opening': 0,
1036
+ 'other->other': 0
1037
+ };
1038
+ _fn = function(ln) {
1039
+ var fromTo, j, key, padding, type, types, value;
1040
+ types = {
1041
+ single: Boolean(ln.match(/<.+\/>/)),
1042
+ closing: Boolean(ln.match(/<\/.+>/)),
1043
+ opening: Boolean(ln.match(/<[^!?].*>/))
963
1044
  };
964
-
965
- return SwaggerOperation;
966
-
967
- })();
968
-
969
- SwaggerRequest = (function() {
970
- function SwaggerRequest(type, url, params, opts, successCallback, errorCallback, operation, execution) {
971
- var body, e, fields, headers, key, myHeaders, name, obj, param, parent, possibleParams, requestContentType, responseContentType, status, urlEncoded, value, values,
972
- _this = this;
973
- this.type = type;
974
- this.url = url;
975
- this.params = params;
976
- this.opts = opts;
977
- this.successCallback = successCallback;
978
- this.errorCallback = errorCallback;
979
- this.operation = operation;
980
- this.execution = execution;
981
- if (this.type == null) {
982
- throw "SwaggerRequest type is required (get/post/put/delete).";
983
- }
984
- if (this.url == null) {
985
- throw "SwaggerRequest url is required.";
986
- }
987
- if (this.successCallback == null) {
988
- throw "SwaggerRequest successCallback is required.";
989
- }
990
- if (this.errorCallback == null) {
991
- throw "SwaggerRequest error callback is required.";
992
- }
993
- if (this.operation == null) {
994
- throw "SwaggerRequest operation is required.";
995
- }
996
- this.type = this.type.toUpperCase();
997
- headers = params.headers;
998
- myHeaders = {};
999
- body = params.body;
1000
- parent = params["parent"];
1001
- requestContentType = "application/json";
1002
- if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH")) {
1003
- if (this.opts.requestContentType) {
1004
- requestContentType = this.opts.requestContentType;
1005
- }
1006
- } else {
1007
- if (((function() {
1008
- var _i, _len, _ref, _results;
1009
- _ref = this.operation.parameters;
1010
- _results = [];
1011
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1012
- param = _ref[_i];
1013
- if (param.paramType === "form") {
1014
- _results.push(param);
1015
- }
1016
- }
1017
- return _results;
1018
- }).call(this)).length > 0) {
1019
- type = param.type || param.dataType;
1020
- if (((function() {
1021
- var _i, _len, _ref, _results;
1022
- _ref = this.operation.parameters;
1023
- _results = [];
1024
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1025
- param = _ref[_i];
1026
- if (typeof type !== 'undefined' && type.toLowerCase() === "file") {
1027
- _results.push(param);
1028
- }
1029
- }
1030
- return _results;
1031
- }).call(this)).length > 0) {
1032
- requestContentType = "multipart/form-data";
1033
- } else {
1034
- requestContentType = "application/x-www-form-urlencoded";
1035
- }
1036
- } else if (this.type !== "DELETE") {
1037
- requestContentType = null;
1038
- }
1039
- }
1040
- if (requestContentType && this.operation.consumes) {
1041
- if (this.operation.consumes[requestContentType] === 'undefined') {
1042
- log("server doesn't consume " + requestContentType + ", try " + JSON.stringify(this.operation.consumes));
1043
- if (this.requestContentType === null) {
1044
- requestContentType = this.operation.consumes[0];
1045
- }
1046
- }
1047
- }
1048
- responseContentType = null;
1049
- if (this.type === "POST" || this.type === "GET" || this.type === "PATCH") {
1050
- if (this.opts.responseContentType) {
1051
- responseContentType = this.opts.responseContentType;
1052
- } else {
1053
- responseContentType = "application/json";
1054
- }
1055
- } else {
1056
- responseContentType = null;
1057
- }
1058
- if (responseContentType && this.operation.produces) {
1059
- if (this.operation.produces[responseContentType] === 'undefined') {
1060
- log("server can't produce " + responseContentType);
1061
- }
1062
- }
1063
- if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) {
1064
- fields = {};
1065
- possibleParams = (function() {
1066
- var _i, _len, _ref, _results;
1067
- _ref = this.operation.parameters;
1068
- _results = [];
1069
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1070
- param = _ref[_i];
1071
- if (param.paramType === "form") {
1072
- _results.push(param);
1073
- }
1074
- }
1075
- return _results;
1076
- }).call(this);
1077
- values = {};
1078
- for (key in possibleParams) {
1079
- value = possibleParams[key];
1080
- if (this.params[value.name]) {
1081
- values[value.name] = this.params[value.name];
1082
- }
1083
- }
1084
- urlEncoded = "";
1085
- for (key in values) {
1086
- value = values[key];
1087
- if (urlEncoded !== "") {
1088
- urlEncoded += "&";
1089
- }
1090
- urlEncoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
1045
+ type = ((function() {
1046
+ var _results;
1047
+ _results = [];
1048
+ for (key in types) {
1049
+ value = types[key];
1050
+ if (value) {
1051
+ _results.push(key);
1091
1052
  }
1092
- body = urlEncoded;
1093
- }
1094
- for (name in headers) {
1095
- myHeaders[name] = headers[name];
1096
1053
  }
1097
- if (requestContentType) {
1098
- myHeaders["Content-Type"] = requestContentType;
1099
- }
1100
- if (responseContentType) {
1101
- myHeaders["Accept"] = responseContentType;
1102
- }
1103
- if (!((headers != null) && (headers.mock != null))) {
1104
- obj = {
1105
- url: this.url,
1106
- method: this.type,
1107
- headers: myHeaders,
1108
- body: body,
1109
- useJQuery: this.useJQuery,
1110
- on: {
1111
- error: function(response) {
1112
- return _this.errorCallback(response, _this.opts.parent);
1113
- },
1114
- redirect: function(response) {
1115
- return _this.successCallback(response, _this.opts.parent);
1116
- },
1117
- 307: function(response) {
1118
- return _this.successCallback(response, _this.opts.parent);
1119
- },
1120
- response: function(response) {
1121
- return _this.successCallback(response, _this.opts.parent);
1122
- }
1123
- }
1124
- };
1125
- e = {};
1126
- if (typeof window !== 'undefined') {
1127
- e = window;
1128
- } else {
1129
- e = exports;
1130
- }
1131
- status = e.authorizations.apply(obj, this.operation.authorizations);
1132
- if (opts.mock == null) {
1133
- if (status !== false) {
1134
- new SwaggerHttp().execute(obj);
1135
- } else {
1136
- obj.canceled = true;
1137
- }
1138
- } else {
1139
- return obj;
1140
- }
1054
+ return _results;
1055
+ })())[0];
1056
+ type = type === void 0 ? 'other' : type;
1057
+ fromTo = lastType + '->' + type;
1058
+ lastType = type;
1059
+ padding = '';
1060
+ indent += transitions[fromTo];
1061
+ padding = ((function() {
1062
+ var _j, _ref5, _results;
1063
+ _results = [];
1064
+ for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) {
1065
+ _results.push(' ');
1141
1066
  }
1067
+ return _results;
1068
+ })()).join('');
1069
+ if (fromTo === 'opening->closing') {
1070
+ return formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
1071
+ } else {
1072
+ return formatted += padding + ln + '\n';
1073
+ }
1074
+ };
1075
+ for (_i = 0, _len = lines.length; _i < _len; _i++) {
1076
+ ln = lines[_i];
1077
+ _fn(ln);
1078
+ }
1079
+ return formatted;
1080
+ };
1081
+
1082
+ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCallback, operation, execution) {
1083
+ var _this = this;
1084
+ var errors = [];
1085
+ this.useJQuery = (typeof operation.resource.useJQuery !== 'undefined' ? operation.resource.useJQuery : null);
1086
+ this.type = (type||errors.push("SwaggerRequest type is required (get/post/put/delete/patch/options)."));
1087
+ this.url = (url||errors.push("SwaggerRequest url is required."));
1088
+ this.params = params;
1089
+ this.opts = opts;
1090
+ this.successCallback = (successCallback||errors.push("SwaggerRequest successCallback is required."));
1091
+ this.errorCallback = (errorCallback||errors.push("SwaggerRequest error callback is required."));
1092
+ this.operation = (operation||errors.push("SwaggerRequest operation is required."));
1093
+ this.execution = execution;
1094
+ this.headers = (params.headers||{});
1095
+
1096
+ if(errors.length > 0) {
1097
+ throw errors;
1098
+ }
1099
+
1100
+ this.type = this.type.toUpperCase();
1101
+
1102
+ // set request, response content type headers
1103
+ var headers = this.setHeaders(params, this.operation);
1104
+ var body = params.body;
1105
+
1106
+ // encode the body for form submits
1107
+ if (headers["Content-Type"]) {
1108
+ var values = {};
1109
+ var i;
1110
+ var operationParams = this.operation.parameters;
1111
+ for(i = 0; i < operationParams.length; i++) {
1112
+ var param = operationParams[i];
1113
+ if(param.paramType === "form")
1114
+ values[param.name] = param;
1142
1115
  }
1143
1116
 
1144
- SwaggerRequest.prototype.asCurl = function() {
1145
- var header_args, k, v;
1146
- header_args = (function() {
1147
- var _ref, _results;
1148
- _ref = this.headers;
1149
- _results = [];
1150
- for (k in _ref) {
1151
- v = _ref[k];
1152
- _results.push("--header \"" + k + ": " + v + "\"");
1117
+ if(headers["Content-Type"].indexOf("application/x-www-form-urlencoded") === 0) {
1118
+ var encoded = "";
1119
+ var key;
1120
+ for(key in values) {
1121
+ value = this.params[key];
1122
+ if(typeof value !== 'undefined'){
1123
+ if(encoded !== "")
1124
+ encoded += "&";
1125
+ encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
1153
1126
  }
1154
- return _results;
1155
- }).call(this);
1156
- return "curl " + (header_args.join(" ")) + " " + this.url;
1157
- };
1158
-
1159
- return SwaggerRequest;
1160
-
1161
- })();
1162
-
1163
- SwaggerHttp = (function() {
1164
- function SwaggerHttp() {}
1165
-
1166
- SwaggerHttp.prototype.Shred = null;
1167
-
1168
- SwaggerHttp.prototype.shred = null;
1169
-
1170
- SwaggerHttp.prototype.content = null;
1171
-
1172
- SwaggerHttp.prototype.initShred = function() {
1173
- var identity, toString,
1174
- _this = this;
1175
- if (typeof window !== 'undefined') {
1176
- this.Shred = require("./shred");
1177
- } else {
1178
- this.Shred = require("shred");
1179
- }
1180
- this.shred = new this.Shred();
1181
- identity = function(x) {
1182
- return x;
1183
- };
1184
- toString = function(x) {
1185
- return x.toString();
1186
- };
1187
- if (typeof window !== 'undefined') {
1188
- this.content = require("./shred/content");
1189
- return this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
1190
- parser: identity,
1191
- stringify: toString
1192
- });
1193
- } else {
1194
- return this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
1195
- parser: identity,
1196
- stringify: toString
1197
- });
1198
- }
1199
- };
1200
-
1201
- SwaggerHttp.prototype.execute = function(obj) {
1202
- if (this.isIE() || obj.useJQuery) {
1203
- return this.executeWithJQuery(obj);
1204
- } else {
1205
- return this.executeWithShred(obj);
1206
1127
  }
1207
- };
1208
-
1209
- SwaggerHttp.prototype.executeWithShred = function(obj) {
1210
- var cb, res,
1211
- _this = this;
1212
- if (!this.Shred) {
1213
- this.initShred();
1128
+ body = encoded;
1129
+ }
1130
+ else if (headers["Content-Type"].indexOf("multipart/form-data") === 0) {
1131
+ // encode the body for form submits
1132
+ var data = "";
1133
+ var boundary = "----SwaggerFormBoundary" + Date.now();
1134
+ var key;
1135
+ for(key in values) {
1136
+ value = this.params[key];
1137
+ if(typeof value !== 'undefined') {
1138
+ data += '--' + boundary + '\n';
1139
+ data += 'Content-Disposition: form-data; name="' + key + '"';
1140
+ data += '\n\n';
1141
+ data += value + "\n";
1142
+ }
1214
1143
  }
1215
- cb = obj.on;
1216
- res = {
1217
- error: function(raw) {
1218
- var headers, out;
1219
- if (obj) {
1220
- headers = raw._headers;
1221
- out = {
1222
- headers: headers,
1223
- url: raw.request.url,
1224
- method: raw.request.method,
1225
- status: raw.status,
1226
- data: raw.content.data
1227
- };
1228
- return cb.error(out);
1229
- }
1144
+ data += "--" + boundary + "--\n";
1145
+ headers["Content-Type"] = "multipart/form-data; boundary=" + boundary;
1146
+ body = data;
1147
+ }
1148
+ }
1149
+
1150
+ if (!((this.headers != null) && (this.headers.mock != null))) {
1151
+ obj = {
1152
+ url: this.url,
1153
+ method: this.type,
1154
+ headers: headers,
1155
+ body: body,
1156
+ useJQuery: this.useJQuery,
1157
+ on: {
1158
+ error: function(response) {
1159
+ return _this.errorCallback(response, _this.opts.parent);
1230
1160
  },
1231
- redirect: function(raw) {
1232
- var headers, out;
1233
- if (obj) {
1234
- headers = raw._headers;
1235
- out = {
1236
- headers: headers,
1237
- url: raw.request.url,
1238
- method: raw.request.method,
1239
- status: raw.status,
1240
- data: raw.content.data
1241
- };
1242
- return cb.redirect(out);
1243
- }
1161
+ redirect: function(response) {
1162
+ return _this.successCallback(response, _this.opts.parent);
1244
1163
  },
1245
- 307: function(raw) {
1246
- var headers, out;
1247
- if (obj) {
1248
- headers = raw._headers;
1249
- out = {
1250
- headers: headers,
1251
- url: raw.request.url,
1252
- method: raw.request.method,
1253
- status: raw.status,
1254
- data: raw.content.data
1255
- };
1256
- return cb.redirect(out);
1257
- }
1164
+ 307: function(response) {
1165
+ return _this.successCallback(response, _this.opts.parent);
1258
1166
  },
1259
- response: function(raw) {
1260
- var headers, out;
1261
- if (obj) {
1262
- headers = raw._headers;
1263
- out = {
1264
- headers: headers,
1265
- url: raw.request.url,
1266
- method: raw.request.method,
1267
- status: raw.status,
1268
- data: raw.content.data
1269
- };
1270
- return cb.response(out);
1271
- }
1167
+ response: function(response) {
1168
+ return _this.successCallback(response, _this.opts.parent);
1272
1169
  }
1273
- };
1274
- if (obj) {
1275
- obj.on = res;
1276
1170
  }
1277
- return this.shred.request(obj);
1278
1171
  };
1279
-
1280
- SwaggerHttp.prototype.executeWithJQuery = function(obj) {
1281
- var beforeSend, cb, request,
1282
- _this = this;
1283
- cb = obj.on;
1284
- request = obj;
1285
- obj.type = obj.method;
1286
- obj.cache = false;
1287
- beforeSend = function(xhr) {
1288
- var key, _results;
1289
- if (obj.headers) {
1290
- _results = [];
1291
- for (key in obj.headers) {
1292
- if (key.toLowerCase() === "content-type") {
1293
- _results.push(obj.contentType = obj.headers[key]);
1294
- } else if (key.toLowerCase() === "accept") {
1295
- _results.push(obj.accepts = obj.headers[key]);
1296
- } else {
1297
- _results.push(xhr.setRequestHeader(key, obj.headers[key]));
1298
- }
1299
- }
1300
- return _results;
1301
- }
1302
- };
1303
- obj.beforeSend = beforeSend;
1304
- obj.data = obj.body;
1305
- obj.complete = function(response, textStatus, opts) {
1306
- var headerArray, headers, i, out, _i, _j, _k, _ref, _ref1, _ref2, _ref3, _results, _results1;
1307
- headers = {};
1308
- headerArray = response.getAllResponseHeaders().split(":");
1309
- for (i = _i = 0, _ref = headerArray.length / 2, _ref1 = 2.; _ref1 > 0 ? _i <= _ref : _i >= _ref; i = _i += _ref1) {
1310
- headers[headerArray[i]] = headerArray[i + 1];
1311
- }
1312
- out = {
1313
- headers: headers,
1314
- url: request.url,
1315
- method: request.method,
1316
- status: response.status,
1317
- data: response.responseText,
1318
- headers: headers
1319
- };
1320
- if (_ref2 = response.status, __indexOf.call((function() {
1321
- _results = [];
1322
- for (_j = 200; _j <= 299; _j++){ _results.push(_j); }
1323
- return _results;
1324
- }).apply(this), _ref2) >= 0) {
1325
- cb.response(out);
1326
- }
1327
- if ((_ref3 = response.status, __indexOf.call((function() {
1328
- _results1 = [];
1329
- for (_k = 400; _k <= 599; _k++){ _results1.push(_k); }
1330
- return _results1;
1331
- }).apply(this), _ref3) >= 0) || response.status === 0) {
1332
- cb.error(out);
1333
- }
1334
- return cb.response(out);
1335
- };
1336
- $.support.cors = true;
1337
- return $.ajax(obj);
1338
- };
1339
-
1340
- SwaggerHttp.prototype.isIE = function() {
1341
- var isIE, nav, version;
1342
- ({
1343
- isIE: false
1344
- });
1345
- if (typeof navigator !== 'undefined' && navigator.userAgent) {
1346
- nav = navigator.userAgent.toLowerCase();
1347
- if (nav.indexOf('msie') !== -1) {
1348
- version = parseInt(nav.split('msie')[1]);
1349
- if (version <= 8) {
1350
- isIE = true;
1351
- }
1352
- }
1172
+ var e;
1173
+ if (typeof window !== 'undefined') {
1174
+ e = window;
1175
+ } else {
1176
+ e = exports;
1177
+ }
1178
+ status = e.authorizations.apply(obj, this.operation.authorizations);
1179
+ if (opts.mock == null) {
1180
+ if (status !== false) {
1181
+ new SwaggerHttp().execute(obj);
1182
+ } else {
1183
+ obj.canceled = true;
1353
1184
  }
1354
- return isIE;
1355
- };
1356
-
1357
- return SwaggerHttp;
1358
-
1359
- })();
1360
-
1361
- SwaggerAuthorizations = (function() {
1362
- SwaggerAuthorizations.prototype.authz = null;
1363
-
1364
- function SwaggerAuthorizations() {
1365
- this.authz = {};
1185
+ } else {
1186
+ return obj;
1366
1187
  }
1367
-
1368
- SwaggerAuthorizations.prototype.add = function(name, auth) {
1369
- this.authz[name] = auth;
1370
- return auth;
1371
- };
1372
-
1373
- SwaggerAuthorizations.prototype.remove = function(name) {
1374
- return delete this.authz[name];
1375
- };
1376
-
1377
- SwaggerAuthorizations.prototype.apply = function(obj, authorizations) {
1378
- var key, result, status, value, _ref;
1379
- status = null;
1380
- _ref = this.authz;
1381
- for (key in _ref) {
1382
- value = _ref[key];
1383
- result = value.apply(obj, authorizations);
1384
- if (result === false) {
1385
- status = false;
1386
- }
1387
- if (result === true) {
1388
- status = true;
1389
- }
1188
+ }
1189
+ };
1190
+
1191
+ SwaggerRequest.prototype.setHeaders = function(params, operation) {
1192
+ // default type
1193
+ var accepts = "application/json";
1194
+ var consumes = "application/json";
1195
+
1196
+ var allDefinedParams = this.operation.parameters;
1197
+ var definedFormParams = [];
1198
+ var definedFileParams = [];
1199
+ var body = params.body;
1200
+ var headers = {};
1201
+
1202
+ // get params from the operation and set them in definedFileParams, definedFormParams, headers
1203
+ var i;
1204
+ for(i = 0; i < allDefinedParams.length; i++) {
1205
+ var param = allDefinedParams[i];
1206
+ if(param.paramType === "form")
1207
+ definedFormParams.push(param);
1208
+ else if(param.paramType === "file")
1209
+ definedFileParams.push(param);
1210
+ else if(param.paramType === "header" && this.params.headers) {
1211
+ var key = param.name;
1212
+ var headerValue = this.params.headers[param.name];
1213
+ if(typeof this.params.headers[param.name] !== 'undefined')
1214
+ headers[key] = headerValue;
1215
+ }
1216
+ }
1217
+
1218
+ // if there's a body, need to set the accepts header via requestContentType
1219
+ if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH" || this.type === "DELETE")) {
1220
+ if (this.opts.requestContentType)
1221
+ accepts = this.opts.requestContentType;
1222
+ } else {
1223
+ // if any form params, content type must be set
1224
+ if(definedFormParams.length > 0) {
1225
+ if(definedFileParams.length > 0)
1226
+ consumes = "multipart/form-data";
1227
+ else
1228
+ consumes = "application/x-www-form-urlencoded";
1229
+ }
1230
+ else if (this.type == "DELETE")
1231
+ body = "{}";
1232
+ else if (this.type != "DELETE")
1233
+ accepts = null;
1234
+ }
1235
+
1236
+ if (consumes && this.operation.consumes) {
1237
+ if (this.operation.consumes.indexOf(consumes) === -1) {
1238
+ log("server doesn't consume " + consumes + ", try " + JSON.stringify(this.operation.consumes));
1239
+ consumes = this.operation.consumes[0];
1240
+ }
1241
+ }
1242
+
1243
+ if (this.opts.responseContentType) {
1244
+ accepts = this.opts.responseContentType;
1245
+ } else {
1246
+ accepts = "application/json";
1247
+ }
1248
+ if (accepts && this.operation.produces) {
1249
+ if (this.operation.produces.indexOf(accepts) === -1) {
1250
+ log("server can't produce " + accepts);
1251
+ accepts = this.operation.produces[0];
1252
+ }
1253
+ }
1254
+
1255
+ if ((consumes && body !== "") || (consumes === "application/x-www-form-urlencoded"))
1256
+ headers["Content-Type"] = consumes;
1257
+ if (accepts)
1258
+ headers["Accept"] = accepts;
1259
+ return headers;
1260
+ }
1261
+
1262
+ SwaggerRequest.prototype.asCurl = function() {
1263
+ var results = [];
1264
+ if(this.headers) {
1265
+ var key;
1266
+ for(key in this.headers) {
1267
+ results.push("--header \"" + key + ": " + this.headers[v] + "\"");
1268
+ }
1269
+ }
1270
+ return "curl " + (results.join(" ")) + " " + this.url;
1271
+ };
1272
+
1273
+ /**
1274
+ * SwaggerHttp is a wrapper for executing requests
1275
+ */
1276
+ var SwaggerHttp = function() {};
1277
+
1278
+ SwaggerHttp.prototype.execute = function(obj) {
1279
+ if(obj && (typeof obj.useJQuery === 'boolean'))
1280
+ this.useJQuery = obj.useJQuery;
1281
+ else
1282
+ this.useJQuery = this.isIE8();
1283
+
1284
+ if(this.useJQuery)
1285
+ return new JQueryHttpClient().execute(obj);
1286
+ else
1287
+ return new ShredHttpClient().execute(obj);
1288
+ }
1289
+
1290
+ SwaggerHttp.prototype.isIE8 = function() {
1291
+ var detectedIE = false;
1292
+ if (typeof navigator !== 'undefined' && navigator.userAgent) {
1293
+ nav = navigator.userAgent.toLowerCase();
1294
+ if (nav.indexOf('msie') !== -1) {
1295
+ var version = parseInt(nav.split('msie')[1]);
1296
+ if (version <= 8) {
1297
+ detectedIE = true;
1390
1298
  }
1391
- return status;
1392
- };
1393
-
1394
- return SwaggerAuthorizations;
1395
-
1396
- })();
1397
-
1398
- ApiKeyAuthorization = (function() {
1399
- ApiKeyAuthorization.prototype.type = null;
1400
-
1401
- ApiKeyAuthorization.prototype.name = null;
1402
-
1403
- ApiKeyAuthorization.prototype.value = null;
1404
-
1405
- function ApiKeyAuthorization(name, value, type) {
1406
- this.name = name;
1407
- this.value = value;
1408
- this.type = type;
1409
1299
  }
1410
-
1411
- ApiKeyAuthorization.prototype.apply = function(obj, authorizations) {
1412
- if (this.type === "query") {
1413
- if (obj.url.indexOf('?') > 0) {
1414
- obj.url = obj.url + "&" + this.name + "=" + this.value;
1300
+ }
1301
+ return detectedIE;
1302
+ };
1303
+
1304
+ /*
1305
+ * JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic.
1306
+ * NOTE: when jQuery is available it will export both '$' and 'jQuery' to the global space.
1307
+ * Since we are using closures here we need to alias it for internal use.
1308
+ */
1309
+ var JQueryHttpClient = function(options) {
1310
+ "use strict";
1311
+ if(!jQuery){
1312
+ var jQuery = window.jQuery;
1313
+ }
1314
+ }
1315
+
1316
+ JQueryHttpClient.prototype.execute = function(obj) {
1317
+ var cb = obj.on;
1318
+ var request = obj;
1319
+
1320
+ obj.type = obj.method;
1321
+ obj.cache = false;
1322
+
1323
+ obj.beforeSend = function(xhr) {
1324
+ var key, results;
1325
+ if (obj.headers) {
1326
+ results = [];
1327
+ var key;
1328
+ for (key in obj.headers) {
1329
+ if (key.toLowerCase() === "content-type") {
1330
+ results.push(obj.contentType = obj.headers[key]);
1331
+ } else if (key.toLowerCase() === "accept") {
1332
+ results.push(obj.accepts = obj.headers[key]);
1415
1333
  } else {
1416
- obj.url = obj.url + "?" + this.name + "=" + this.value;
1334
+ results.push(xhr.setRequestHeader(key, obj.headers[key]));
1417
1335
  }
1418
- return true;
1419
- } else if (this.type === "header") {
1420
- obj.headers[this.name] = this.value;
1421
- return true;
1422
1336
  }
1423
- };
1424
-
1425
- return ApiKeyAuthorization;
1426
-
1427
- })();
1428
-
1429
- PasswordAuthorization = (function() {
1430
- PasswordAuthorization._btoa = null;
1431
-
1432
- PasswordAuthorization.prototype.name = null;
1433
-
1434
- PasswordAuthorization.prototype.username = null;
1435
-
1436
- PasswordAuthorization.prototype.password = null;
1437
-
1438
- function PasswordAuthorization(name, username, password) {
1439
- this.name = name;
1440
- this.username = username;
1441
- this.password = password;
1442
- PasswordAuthorization._ensureBtoa();
1337
+ return results;
1443
1338
  }
1339
+ };
1444
1340
 
1445
- PasswordAuthorization.prototype.apply = function(obj, authorizations) {
1446
- obj.headers["Authorization"] = "Basic " + PasswordAuthorization._btoa(this.username + ":" + this.password);
1447
- return true;
1448
- };
1341
+ obj.data = obj.body;
1342
+ obj.complete = function(response, textStatus, opts) {
1343
+ var headers = {},
1344
+ headerArray = response.getAllResponseHeaders().split("\n");
1345
+
1346
+ for(var i = 0; i < headerArray.length; i++) {
1347
+ var toSplit = headerArray[i].trim();
1348
+ if(toSplit.length === 0)
1349
+ continue;
1350
+ var separator = toSplit.indexOf(":");
1351
+ if(separator === -1) {
1352
+ // Name but no value in the header
1353
+ headers[toSplit] = null;
1354
+ continue;
1355
+ }
1356
+ var name = toSplit.substring(0, separator).trim(),
1357
+ value = toSplit.substring(separator + 1).trim();
1358
+ headers[name] = value;
1359
+ }
1449
1360
 
1450
- PasswordAuthorization._ensureBtoa = function() {
1451
- if (typeof window !== 'undefined') {
1452
- return this._btoa = btoa;
1453
- } else {
1454
- return this._btoa = require("btoa");
1455
- }
1361
+ var out = {
1362
+ url: request.url,
1363
+ method: request.method,
1364
+ status: response.status,
1365
+ data: response.responseText,
1366
+ headers: headers
1456
1367
  };
1457
1368
 
1458
- return PasswordAuthorization;
1369
+ var contentType = (headers["content-type"]||headers["Content-Type"]||null)
1459
1370
 
1460
- })();
1461
-
1462
- this.SwaggerApi = SwaggerApi;
1463
-
1464
- this.SwaggerResource = SwaggerResource;
1465
-
1466
- this.SwaggerOperation = SwaggerOperation;
1467
-
1468
- this.SwaggerRequest = SwaggerRequest;
1371
+ if(contentType != null) {
1372
+ if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
1373
+ if(response.responseText && response.responseText !== "")
1374
+ out.obj = JSON.parse(response.responseText);
1375
+ else
1376
+ out.obj = {}
1377
+ }
1378
+ }
1469
1379
 
1470
- this.SwaggerModelProperty = SwaggerModelProperty;
1380
+ if(response.status >= 200 && response.status < 300)
1381
+ cb.response(out);
1382
+ else if(response.status === 0 || (response.status >= 400 && response.status < 599))
1383
+ cb.error(out);
1384
+ else
1385
+ return cb.response(out);
1386
+ };
1471
1387
 
1472
- this.ApiKeyAuthorization = ApiKeyAuthorization;
1388
+ jQuery.support.cors = true;
1389
+ return jQuery.ajax(obj);
1390
+ }
1391
+
1392
+ /*
1393
+ * ShredHttpClient is a light-weight, node or browser HTTP client
1394
+ */
1395
+ var ShredHttpClient = function(options) {
1396
+ this.options = (options||{});
1397
+ this.isInitialized = false;
1398
+
1399
+ var identity, toString;
1400
+
1401
+ if (typeof window !== 'undefined') {
1402
+ this.Shred = require("./shred");
1403
+ this.content = require("./shred/content");
1404
+ }
1405
+ else
1406
+ this.Shred = require("shred");
1407
+ this.shred = new this.Shred();
1408
+ }
1409
+
1410
+ ShredHttpClient.prototype.initShred = function () {
1411
+ this.isInitialized = true;
1412
+ this.registerProcessors(this.shred);
1413
+ }
1414
+
1415
+ ShredHttpClient.prototype.registerProcessors = function(shred) {
1416
+ var identity = function(x) {
1417
+ return x;
1418
+ };
1419
+ var toString = function(x) {
1420
+ return x.toString();
1421
+ };
1473
1422
 
1474
- this.PasswordAuthorization = PasswordAuthorization;
1423
+ if (typeof window !== 'undefined') {
1424
+ this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
1425
+ parser: identity,
1426
+ stringify: toString
1427
+ });
1428
+ } else {
1429
+ this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
1430
+ parser: identity,
1431
+ stringify: toString
1432
+ });
1433
+ }
1434
+ }
1435
+
1436
+ ShredHttpClient.prototype.execute = function(obj) {
1437
+ if(!this.isInitialized)
1438
+ this.initShred();
1439
+
1440
+ var cb = obj.on, res;
1441
+
1442
+ var transform = function(response) {
1443
+ var out = {
1444
+ headers: response._headers,
1445
+ url: response.request.url,
1446
+ method: response.request.method,
1447
+ status: response.status,
1448
+ data: response.content.data
1449
+ };
1475
1450
 
1476
- this.SwaggerHttp = SwaggerHttp;
1451
+ var contentType = (response._headers["content-type"]||response._headers["Content-Type"]||null)
1477
1452
 
1478
- this.authorizations = new SwaggerAuthorizations();
1453
+ if(contentType != null) {
1454
+ if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
1455
+ if(response.content.data && response.content.data !== "")
1456
+ out.obj = JSON.parse(response.content.data);
1457
+ else
1458
+ out.obj = {}
1459
+ }
1460
+ }
1461
+ return out;
1462
+ };
1479
1463
 
1480
- }).call(this);
1464
+ res = {
1465
+ error: function(response) {
1466
+ if (obj)
1467
+ return cb.error(transform(response));
1468
+ },
1469
+ redirect: function(response) {
1470
+ if (obj)
1471
+ return cb.redirect(transform(response));
1472
+ },
1473
+ 307: function(response) {
1474
+ if (obj)
1475
+ return cb.redirect(transform(response));
1476
+ },
1477
+ response: function(response) {
1478
+ if (obj)
1479
+ return cb.response(transform(response));
1480
+ }
1481
+ };
1482
+ if (obj) {
1483
+ obj.on = res;
1484
+ }
1485
+ return this.shred.request(obj);
1486
+ };
1487
+
1488
+ /**
1489
+ * SwaggerAuthorizations applys the correct authorization to an operation being executed
1490
+ */
1491
+ var SwaggerAuthorizations = function() {
1492
+ this.authz = {};
1493
+ };
1494
+
1495
+ SwaggerAuthorizations.prototype.add = function(name, auth) {
1496
+ this.authz[name] = auth;
1497
+ return auth;
1498
+ };
1499
+
1500
+ SwaggerAuthorizations.prototype.remove = function(name) {
1501
+ return delete this.authz[name];
1502
+ };
1503
+
1504
+ SwaggerAuthorizations.prototype.apply = function(obj, authorizations) {
1505
+ var status = null;
1506
+ var key;
1507
+
1508
+ // if the "authorizations" key is undefined, or has an empty array, add all keys
1509
+ if(typeof authorizations === 'undefined' || Object.keys(authorizations).length == 0) {
1510
+ for (key in this.authz) {
1511
+ value = this.authz[key];
1512
+ result = value.apply(obj, authorizations);
1513
+ if (result === true)
1514
+ status = true;
1515
+ }
1516
+ }
1517
+ else {
1518
+ for(name in authorizations) {
1519
+ for (key in this.authz) {
1520
+ if(key == name) {
1521
+ value = this.authz[key];
1522
+ result = value.apply(obj, authorizations);
1523
+ if (result === true)
1524
+ status = true;
1525
+ }
1526
+ }
1527
+ }
1528
+ }
1529
+
1530
+ return status;
1531
+ };
1532
+
1533
+ /**
1534
+ * ApiKeyAuthorization allows a query param or header to be injected
1535
+ */
1536
+ var ApiKeyAuthorization = function(name, value, type) {
1537
+ this.name = name;
1538
+ this.value = value;
1539
+ this.type = type;
1540
+ };
1541
+
1542
+ ApiKeyAuthorization.prototype.apply = function(obj, authorizations) {
1543
+ if (this.type === "query") {
1544
+ if (obj.url.indexOf('?') > 0)
1545
+ obj.url = obj.url + "&" + this.name + "=" + this.value;
1546
+ else
1547
+ obj.url = obj.url + "?" + this.name + "=" + this.value;
1548
+ return true;
1549
+ } else if (this.type === "header") {
1550
+ obj.headers[this.name] = this.value;
1551
+ return true;
1552
+ }
1553
+ };
1554
+
1555
+ var CookieAuthorization = function(cookie) {
1556
+ this.cookie = cookie;
1557
+ }
1558
+
1559
+ CookieAuthorization.prototype.apply = function(obj, authorizations) {
1560
+ obj.cookieJar = obj.cookieJar || CookieJar();
1561
+ obj.cookieJar.setCookie(this.cookie);
1562
+ return true;
1563
+ }
1564
+
1565
+ /**
1566
+ * Password Authorization is a basic auth implementation
1567
+ */
1568
+ var PasswordAuthorization = function(name, username, password) {
1569
+ this.name = name;
1570
+ this.username = username;
1571
+ this.password = password;
1572
+ this._btoa = null;
1573
+ if (typeof window !== 'undefined')
1574
+ this._btoa = btoa;
1575
+ else
1576
+ this._btoa = require("btoa");
1577
+ };
1578
+
1579
+ PasswordAuthorization.prototype.apply = function(obj, authorizations) {
1580
+ var base64encoder = this._btoa;
1581
+ obj.headers["Authorization"] = "Basic " + base64encoder(this.username + ":" + this.password);
1582
+ return true;
1583
+ };
1584
+
1585
+ var e = (typeof window !== 'undefined' ? window : exports);
1586
+
1587
+ var sampleModels = {};
1588
+ var cookies = {};
1589
+
1590
+ e.SampleModels = sampleModels;
1591
+ e.SwaggerHttp = SwaggerHttp;
1592
+ e.SwaggerRequest = SwaggerRequest;
1593
+ e.authorizations = new SwaggerAuthorizations();
1594
+ e.ApiKeyAuthorization = ApiKeyAuthorization;
1595
+ e.PasswordAuthorization = PasswordAuthorization;
1596
+ e.CookieAuthorization = CookieAuthorization;
1597
+ e.JQueryHttpClient = JQueryHttpClient;
1598
+ e.ShredHttpClient = ShredHttpClient;
1599
+ e.SwaggerOperation = SwaggerOperation;
1600
+ e.SwaggerModel = SwaggerModel;
1601
+ e.SwaggerModelProperty = SwaggerModelProperty;
1602
+ e.SwaggerResource = SwaggerResource;
1603
+ e.SwaggerApi = SwaggerApi;