swagger-ui_rails 0.1.7 → 2.1.0.alpha.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/Rakefile +45 -0
- data/app/assets/images/explorer_icons.png +0 -0
- data/app/assets/javascripts/swagger-oauth.js +211 -0
- data/app/assets/javascripts/swagger-ui/index.js +13 -0
- data/app/assets/javascripts/{lib → swagger-ui/lib}/backbone-min.js +0 -0
- data/app/assets/javascripts/{lib → swagger-ui/lib}/handlebars-1.0.0.js +0 -0
- data/app/assets/javascripts/{lib → swagger-ui/lib}/highlight.7.3.pack.js +0 -0
- data/app/assets/javascripts/{lib → swagger-ui/lib}/jquery-1.8.0.min.js +0 -0
- data/app/assets/javascripts/{lib → swagger-ui/lib}/jquery.ba-bbq.min.js +0 -0
- data/app/assets/javascripts/{lib → swagger-ui/lib}/jquery.slideto.min.js +0 -0
- data/app/assets/javascripts/{lib → swagger-ui/lib}/jquery.wiggle.min.js +0 -0
- data/app/assets/javascripts/{lib → swagger-ui/lib}/shred.bundle.js +3 -3
- data/app/assets/javascripts/swagger-ui/lib/swagger-client.js +1606 -0
- data/app/assets/javascripts/swagger-ui/lib/swagger.js +1725 -0
- data/app/assets/javascripts/{lib → swagger-ui/lib}/underscore-min.js +0 -0
- data/app/assets/javascripts/swagger-ui/swagger-oauth.js +237 -0
- data/app/assets/javascripts/{swagger-ui.js.erb → swagger-ui/swagger-ui.js.erb} +1076 -520
- data/app/assets/stylesheets/swagger-ui/index.css +5 -0
- data/app/assets/stylesheets/swagger-ui/reset.css +125 -0
- data/app/assets/stylesheets/swagger-ui/screen.css +1224 -0
- data/app/views/swagger_ui/_swagger_ui.html.erb +1 -1
- data/lib/swagger-ui_rails/engine.rb +12 -2
- data/lib/swagger-ui_rails/version.rb +1 -1
- metadata +29 -28
- data/.gitignore +0 -17
- data/Gemfile +0 -4
- data/app/assets/javascripts/lib/shred/content.js +0 -193
- data/app/assets/javascripts/lib/swagger.js +0 -1480
- data/app/assets/stylesheets/hightlight.default.css +0 -135
- data/app/assets/stylesheets/screen.css +0 -1070
- data/app/assets/stylesheets/swagger-ui.css +0 -4
- data/swagger-ui_rails.gemspec +0 -23
@@ -1,4 +1,14 @@
|
|
1
1
|
module Swagger
|
2
|
-
class Engine < Rails::Engine
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
|
4
|
+
initializer :assets do |config|
|
5
|
+
Rails.application.config.assets.precompile += %w{ swagger-ui.js }
|
6
|
+
Rails.application.config.assets.precompile += %w{ swagger-oauth.js }
|
7
|
+
Rails.application.config.assets.precompile += %w{ swagger-ui.css }
|
8
|
+
Rails.application.config.assets.precompile += %w{ swagger-ui/reset.css }
|
9
|
+
Rails.application.config.assets.precompile += %w{ swagger-ui/screen.css }
|
10
|
+
Rails.application.config.assets.paths << root.join("app", "assets")
|
11
|
+
end
|
12
|
+
|
3
13
|
end
|
4
|
-
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swagger-ui_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.1.0.alpha.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stjepan Hadjic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: A gem to add swagger-ui to rails asset pipeline
|
@@ -45,33 +45,34 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- .gitignore
|
49
|
-
- Gemfile
|
50
48
|
- LICENSE.txt
|
51
49
|
- README.md
|
52
50
|
- Rakefile
|
51
|
+
- app/assets/images/explorer_icons.png
|
53
52
|
- app/assets/images/logo_small.png
|
54
53
|
- app/assets/images/throbber.gif
|
55
|
-
- app/assets/javascripts/
|
56
|
-
- app/assets/javascripts/
|
57
|
-
- app/assets/javascripts/lib/
|
58
|
-
- app/assets/javascripts/lib/
|
59
|
-
- app/assets/javascripts/lib/
|
60
|
-
- app/assets/javascripts/lib/jquery.
|
61
|
-
- app/assets/javascripts/lib/jquery.
|
62
|
-
- app/assets/javascripts/lib/
|
63
|
-
- app/assets/javascripts/lib/
|
64
|
-
- app/assets/javascripts/lib/
|
65
|
-
- app/assets/javascripts/lib/
|
66
|
-
- app/assets/javascripts/swagger-ui.js
|
67
|
-
- app/assets/
|
68
|
-
- app/assets/
|
69
|
-
- app/assets/
|
54
|
+
- app/assets/javascripts/swagger-oauth.js
|
55
|
+
- app/assets/javascripts/swagger-ui/index.js
|
56
|
+
- app/assets/javascripts/swagger-ui/lib/backbone-min.js
|
57
|
+
- app/assets/javascripts/swagger-ui/lib/handlebars-1.0.0.js
|
58
|
+
- app/assets/javascripts/swagger-ui/lib/highlight.7.3.pack.js
|
59
|
+
- app/assets/javascripts/swagger-ui/lib/jquery-1.8.0.min.js
|
60
|
+
- app/assets/javascripts/swagger-ui/lib/jquery.ba-bbq.min.js
|
61
|
+
- app/assets/javascripts/swagger-ui/lib/jquery.slideto.min.js
|
62
|
+
- app/assets/javascripts/swagger-ui/lib/jquery.wiggle.min.js
|
63
|
+
- app/assets/javascripts/swagger-ui/lib/shred.bundle.js
|
64
|
+
- app/assets/javascripts/swagger-ui/lib/swagger-client.js
|
65
|
+
- app/assets/javascripts/swagger-ui/lib/swagger.js
|
66
|
+
- app/assets/javascripts/swagger-ui/lib/underscore-min.js
|
67
|
+
- app/assets/javascripts/swagger-ui/swagger-oauth.js
|
68
|
+
- app/assets/javascripts/swagger-ui/swagger-ui.js.erb
|
69
|
+
- app/assets/stylesheets/swagger-ui/index.css
|
70
|
+
- app/assets/stylesheets/swagger-ui/reset.css
|
71
|
+
- app/assets/stylesheets/swagger-ui/screen.css
|
70
72
|
- app/views/swagger_ui/_swagger_ui.html.erb
|
71
73
|
- lib/swagger-ui_rails.rb
|
72
74
|
- lib/swagger-ui_rails/engine.rb
|
73
75
|
- lib/swagger-ui_rails/version.rb
|
74
|
-
- swagger-ui_rails.gemspec
|
75
76
|
homepage: https://github.com/d4be4st/swagger-ui_rails
|
76
77
|
licenses:
|
77
78
|
- MIT
|
@@ -82,17 +83,17 @@ require_paths:
|
|
82
83
|
- lib
|
83
84
|
required_ruby_version: !ruby/object:Gem::Requirement
|
84
85
|
requirements:
|
85
|
-
- -
|
86
|
+
- - ">="
|
86
87
|
- !ruby/object:Gem::Version
|
87
88
|
version: '0'
|
88
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
90
|
requirements:
|
90
|
-
- -
|
91
|
+
- - ">"
|
91
92
|
- !ruby/object:Gem::Version
|
92
|
-
version:
|
93
|
+
version: 1.3.1
|
93
94
|
requirements: []
|
94
95
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.
|
96
|
+
rubygems_version: 2.2.2
|
96
97
|
signing_key:
|
97
98
|
specification_version: 4
|
98
99
|
summary: Add swagger-ui to your rails app easily
|
data/.gitignore
DELETED
data/Gemfile
DELETED
@@ -1,193 +0,0 @@
|
|
1
|
-
|
2
|
-
// The purpose of the `Content` object is to abstract away the data conversions
|
3
|
-
// to and from raw content entities as strings. For example, you want to be able
|
4
|
-
// to pass in a Javascript object and have it be automatically converted into a
|
5
|
-
// JSON string if the `content-type` is set to a JSON-based media type.
|
6
|
-
// Conversely, you want to be able to transparently get back a Javascript object
|
7
|
-
// in the response if the `content-type` is a JSON-based media-type.
|
8
|
-
|
9
|
-
// One limitation of the current implementation is that it [assumes the `charset` is UTF-8](https://github.com/spire-io/shred/issues/5).
|
10
|
-
|
11
|
-
// The `Content` constructor takes an options object, which *must* have either a
|
12
|
-
// `body` or `data` property and *may* have a `type` property indicating the
|
13
|
-
// media type. If there is no `type` attribute, a default will be inferred.
|
14
|
-
var Content = function(options) {
|
15
|
-
this.body = options.body;
|
16
|
-
this.data = options.data;
|
17
|
-
this.type = options.type;
|
18
|
-
};
|
19
|
-
|
20
|
-
Content.prototype = {
|
21
|
-
// Treat `toString()` as asking for the `content.body`. That is, the raw content entity.
|
22
|
-
//
|
23
|
-
// toString: function() { return this.body; }
|
24
|
-
//
|
25
|
-
// Commented out, but I've forgotten why. :/
|
26
|
-
};
|
27
|
-
|
28
|
-
|
29
|
-
// `Content` objects have the following attributes:
|
30
|
-
Object.defineProperties(Content.prototype,{
|
31
|
-
|
32
|
-
// - **type**. Typically accessed as `content.type`, reflects the `content-type`
|
33
|
-
// header associated with the request or response. If not passed as an options
|
34
|
-
// to the constructor or set explicitly, it will infer the type the `data`
|
35
|
-
// attribute, if possible, and, failing that, will default to `text/plain`.
|
36
|
-
type: {
|
37
|
-
get: function() {
|
38
|
-
if (this._type) {
|
39
|
-
return this._type;
|
40
|
-
} else {
|
41
|
-
if (this._data) {
|
42
|
-
switch(typeof this._data) {
|
43
|
-
case "string": return "text/plain";
|
44
|
-
case "object": return "application/json";
|
45
|
-
}
|
46
|
-
}
|
47
|
-
}
|
48
|
-
return "text/plain";
|
49
|
-
},
|
50
|
-
set: function(value) {
|
51
|
-
this._type = value;
|
52
|
-
return this;
|
53
|
-
},
|
54
|
-
enumerable: true
|
55
|
-
},
|
56
|
-
|
57
|
-
// - **data**. Typically accessed as `content.data`, reflects the content entity
|
58
|
-
// converted into Javascript data. This can be a string, if the `type` is, say,
|
59
|
-
// `text/plain`, but can also be a Javascript object. The conversion applied is
|
60
|
-
// based on the `processor` attribute. The `data` attribute can also be set
|
61
|
-
// directly, in which case the conversion will be done the other way, to infer
|
62
|
-
// the `body` attribute.
|
63
|
-
data: {
|
64
|
-
get: function() {
|
65
|
-
if (this._body) {
|
66
|
-
return this.processor.parser(this._body);
|
67
|
-
} else {
|
68
|
-
return this._data;
|
69
|
-
}
|
70
|
-
},
|
71
|
-
set: function(data) {
|
72
|
-
if (this._body&&data) Errors.setDataWithBody(this);
|
73
|
-
this._data = data;
|
74
|
-
return this;
|
75
|
-
},
|
76
|
-
enumerable: true
|
77
|
-
},
|
78
|
-
|
79
|
-
// - **body**. Typically accessed as `content.body`, reflects the content entity
|
80
|
-
// as a UTF-8 string. It is the mirror of the `data` attribute. If you set the
|
81
|
-
// `data` attribute, the `body` attribute will be inferred and vice-versa. If
|
82
|
-
// you attempt to set both, an exception is raised.
|
83
|
-
body: {
|
84
|
-
get: function() {
|
85
|
-
if (this._data) {
|
86
|
-
return this.processor.stringify(this._data);
|
87
|
-
} else {
|
88
|
-
return this._body.toString();
|
89
|
-
}
|
90
|
-
},
|
91
|
-
set: function(body) {
|
92
|
-
if (this._data&&body) Errors.setBodyWithData(this);
|
93
|
-
this._body = body;
|
94
|
-
return this;
|
95
|
-
},
|
96
|
-
enumerable: true
|
97
|
-
},
|
98
|
-
|
99
|
-
// - **processor**. The functions that will be used to convert to/from `data` and
|
100
|
-
// `body` attributes. You can add processors. The two that are built-in are for
|
101
|
-
// `text/plain`, which is basically an identity transformation and
|
102
|
-
// `application/json` and other JSON-based media types (including custom media
|
103
|
-
// types with `+json`). You can add your own processors. See below.
|
104
|
-
processor: {
|
105
|
-
get: function() {
|
106
|
-
var processor = Content.processors[this.type];
|
107
|
-
if (processor) {
|
108
|
-
return processor;
|
109
|
-
} else {
|
110
|
-
// Return the first processor that matches any part of the
|
111
|
-
// content type. ex: application/vnd.foobar.baz+json will match json.
|
112
|
-
var main = this.type.split(";")[0];
|
113
|
-
var parts = main.split(/\+|\//);
|
114
|
-
for (var i=0, l=parts.length; i < l; i++) {
|
115
|
-
processor = Content.processors[parts[i]]
|
116
|
-
}
|
117
|
-
return processor || {parser:identity,stringify:toString};
|
118
|
-
}
|
119
|
-
},
|
120
|
-
enumerable: true
|
121
|
-
},
|
122
|
-
|
123
|
-
// - **length**. Typically accessed as `content.length`, returns the length in
|
124
|
-
// bytes of the raw content entity.
|
125
|
-
length: {
|
126
|
-
get: function() {
|
127
|
-
if (typeof Buffer !== 'undefined') {
|
128
|
-
return Buffer.byteLength(this.body);
|
129
|
-
}
|
130
|
-
return this.body.length;
|
131
|
-
}
|
132
|
-
}
|
133
|
-
});
|
134
|
-
|
135
|
-
Content.processors = {};
|
136
|
-
|
137
|
-
// The `registerProcessor` function allows you to add your own processors to
|
138
|
-
// convert content entities. Each processor consists of a Javascript object with
|
139
|
-
// two properties:
|
140
|
-
// - **parser**. The function used to parse a raw content entity and convert it
|
141
|
-
// into a Javascript data type.
|
142
|
-
// - **stringify**. The function used to convert a Javascript data type into a
|
143
|
-
// raw content entity.
|
144
|
-
Content.registerProcessor = function(types,processor) {
|
145
|
-
|
146
|
-
// You can pass an array of types that will trigger this processor, or just one.
|
147
|
-
// We determine the array via duck-typing here.
|
148
|
-
if (types.forEach) {
|
149
|
-
types.forEach(function(type) {
|
150
|
-
Content.processors[type] = processor;
|
151
|
-
});
|
152
|
-
} else {
|
153
|
-
// If you didn't pass an array, we just use what you pass in.
|
154
|
-
Content.processors[types] = processor;
|
155
|
-
}
|
156
|
-
};
|
157
|
-
|
158
|
-
// Register the identity processor, which is used for text-based media types.
|
159
|
-
var identity = function(x) { return x; }
|
160
|
-
, toString = function(x) { return x.toString(); }
|
161
|
-
Content.registerProcessor(
|
162
|
-
["text/html","text/plain","text"],
|
163
|
-
{ parser: identity, stringify: toString });
|
164
|
-
|
165
|
-
// Register the JSON processor, which is used for JSON-based media types.
|
166
|
-
Content.registerProcessor(
|
167
|
-
["application/json; charset=utf-8","application/json","json"],
|
168
|
-
{
|
169
|
-
parser: function(string) {
|
170
|
-
return JSON.parse(string);
|
171
|
-
},
|
172
|
-
stringify: function(data) {
|
173
|
-
return JSON.stringify(data); }});
|
174
|
-
|
175
|
-
var qs = require('querystring');
|
176
|
-
// Register the post processor, which is used for JSON-based media types.
|
177
|
-
Content.registerProcessor(
|
178
|
-
["application/x-www-form-urlencoded"],
|
179
|
-
{ parser : qs.parse, stringify : qs.stringify });
|
180
|
-
|
181
|
-
// Error functions are defined separately here in an attempt to make the code
|
182
|
-
// easier to read.
|
183
|
-
var Errors = {
|
184
|
-
setDataWithBody: function(object) {
|
185
|
-
throw new Error("Attempt to set data attribute of a content object " +
|
186
|
-
"when the body attributes was already set.");
|
187
|
-
},
|
188
|
-
setBodyWithData: function(object) {
|
189
|
-
throw new Error("Attempt to set body attribute of a content object " +
|
190
|
-
"when the data attributes was already set.");
|
191
|
-
}
|
192
|
-
}
|
193
|
-
module.exports = Content;
|
@@ -1,1480 +0,0 @@
|
|
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);
|
10
|
-
}
|
11
|
-
};
|
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
|
-
}
|
52
|
-
}
|
53
|
-
|
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();
|
220
|
-
}
|
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
|
-
};
|
270
|
-
|
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');
|
307
|
-
} else {
|
308
|
-
this.url = this.api.basePath + this.path.replace('{format}', 'json');
|
309
|
-
}
|
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;
|
332
|
-
} else {
|
333
|
-
e = exports;
|
334
|
-
}
|
335
|
-
e.authorizations.apply(obj);
|
336
|
-
new SwaggerHttp().execute(obj);
|
337
|
-
}
|
338
|
-
}
|
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;
|
369
|
-
}
|
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
|
-
}
|
377
|
-
}
|
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;
|
401
|
-
}
|
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;
|
452
|
-
}
|
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);
|
475
|
-
}
|
476
|
-
_results.push(msg);
|
477
|
-
}
|
478
|
-
return _results;
|
479
|
-
};
|
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);
|
500
|
-
}
|
501
|
-
}
|
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);
|
516
|
-
}
|
517
|
-
}
|
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));
|
544
|
-
}
|
545
|
-
}
|
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
|
-
})();
|
566
|
-
|
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 '") + "'";
|
588
|
-
}
|
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 '") + "'";
|
595
|
-
}
|
596
|
-
}
|
597
|
-
}
|
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({
|
712
|
-
value: String(v),
|
713
|
-
isDefault: true
|
714
|
-
});
|
715
|
-
} else {
|
716
|
-
parameter.allowableValues.descriptiveValues.push({
|
717
|
-
value: String(v),
|
718
|
-
isDefault: false
|
719
|
-
});
|
720
|
-
}
|
721
|
-
}
|
722
|
-
}
|
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
|
-
}
|
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
|
-
}
|
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;
|
787
|
-
return JSON.stringify(val, null, 2);
|
788
|
-
}
|
789
|
-
};
|
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;
|
869
|
-
} else {
|
870
|
-
return true;
|
871
|
-
}
|
872
|
-
};
|
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;
|
947
|
-
}
|
948
|
-
return matchingParams;
|
949
|
-
};
|
950
|
-
|
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;
|
961
|
-
}
|
962
|
-
return msg;
|
963
|
-
};
|
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);
|
1091
|
-
}
|
1092
|
-
body = urlEncoded;
|
1093
|
-
}
|
1094
|
-
for (name in headers) {
|
1095
|
-
myHeaders[name] = headers[name];
|
1096
|
-
}
|
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
|
-
}
|
1141
|
-
}
|
1142
|
-
}
|
1143
|
-
|
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 + "\"");
|
1153
|
-
}
|
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
|
-
}
|
1207
|
-
};
|
1208
|
-
|
1209
|
-
SwaggerHttp.prototype.executeWithShred = function(obj) {
|
1210
|
-
var cb, res,
|
1211
|
-
_this = this;
|
1212
|
-
if (!this.Shred) {
|
1213
|
-
this.initShred();
|
1214
|
-
}
|
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
|
-
}
|
1230
|
-
},
|
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
|
-
}
|
1244
|
-
},
|
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
|
-
}
|
1258
|
-
},
|
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
|
-
}
|
1272
|
-
}
|
1273
|
-
};
|
1274
|
-
if (obj) {
|
1275
|
-
obj.on = res;
|
1276
|
-
}
|
1277
|
-
return this.shred.request(obj);
|
1278
|
-
};
|
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
|
-
}
|
1353
|
-
}
|
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 = {};
|
1366
|
-
}
|
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
|
-
}
|
1390
|
-
}
|
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
|
-
}
|
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;
|
1415
|
-
} else {
|
1416
|
-
obj.url = obj.url + "?" + this.name + "=" + this.value;
|
1417
|
-
}
|
1418
|
-
return true;
|
1419
|
-
} else if (this.type === "header") {
|
1420
|
-
obj.headers[this.name] = this.value;
|
1421
|
-
return true;
|
1422
|
-
}
|
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();
|
1443
|
-
}
|
1444
|
-
|
1445
|
-
PasswordAuthorization.prototype.apply = function(obj, authorizations) {
|
1446
|
-
obj.headers["Authorization"] = "Basic " + PasswordAuthorization._btoa(this.username + ":" + this.password);
|
1447
|
-
return true;
|
1448
|
-
};
|
1449
|
-
|
1450
|
-
PasswordAuthorization._ensureBtoa = function() {
|
1451
|
-
if (typeof window !== 'undefined') {
|
1452
|
-
return this._btoa = btoa;
|
1453
|
-
} else {
|
1454
|
-
return this._btoa = require("btoa");
|
1455
|
-
}
|
1456
|
-
};
|
1457
|
-
|
1458
|
-
return PasswordAuthorization;
|
1459
|
-
|
1460
|
-
})();
|
1461
|
-
|
1462
|
-
this.SwaggerApi = SwaggerApi;
|
1463
|
-
|
1464
|
-
this.SwaggerResource = SwaggerResource;
|
1465
|
-
|
1466
|
-
this.SwaggerOperation = SwaggerOperation;
|
1467
|
-
|
1468
|
-
this.SwaggerRequest = SwaggerRequest;
|
1469
|
-
|
1470
|
-
this.SwaggerModelProperty = SwaggerModelProperty;
|
1471
|
-
|
1472
|
-
this.ApiKeyAuthorization = ApiKeyAuthorization;
|
1473
|
-
|
1474
|
-
this.PasswordAuthorization = PasswordAuthorization;
|
1475
|
-
|
1476
|
-
this.SwaggerHttp = SwaggerHttp;
|
1477
|
-
|
1478
|
-
this.authorizations = new SwaggerAuthorizations();
|
1479
|
-
|
1480
|
-
}).call(this);
|