rswag-ui 2.5.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/rswag/ui/install/install_generator.rb +1 -1
  3. data/lib/generators/rswag/ui/install/templates/rswag_ui.rb +16 -0
  4. data/lib/rswag/ui/configuration.rb +1 -1
  5. data/lib/rswag/ui/middleware.rb +1 -1
  6. data/node_modules/swagger-ui-dist/LICENSE +202 -0
  7. data/node_modules/swagger-ui-dist/NOTICE +2 -0
  8. data/node_modules/swagger-ui-dist/README.md +22 -0
  9. data/node_modules/swagger-ui-dist/absolute-path.js +14 -0
  10. data/node_modules/swagger-ui-dist/favicon-16x16.png +0 -0
  11. data/node_modules/swagger-ui-dist/favicon-32x32.png +0 -0
  12. data/node_modules/swagger-ui-dist/index.html +60 -0
  13. data/node_modules/swagger-ui-dist/index.js +17 -0
  14. data/node_modules/swagger-ui-dist/oauth2-redirect.html +75 -0
  15. data/node_modules/swagger-ui-dist/package.json +18 -0
  16. data/node_modules/swagger-ui-dist/swagger-ui-bundle.js +3 -0
  17. data/node_modules/swagger-ui-dist/swagger-ui-bundle.js.map +1 -0
  18. data/node_modules/swagger-ui-dist/swagger-ui-es-bundle-core.js +3 -0
  19. data/node_modules/swagger-ui-dist/swagger-ui-es-bundle-core.js.map +1 -0
  20. data/node_modules/swagger-ui-dist/swagger-ui-es-bundle.js +3 -0
  21. data/node_modules/swagger-ui-dist/swagger-ui-es-bundle.js.map +1 -0
  22. data/node_modules/swagger-ui-dist/swagger-ui-standalone-preset.js +3 -0
  23. data/node_modules/swagger-ui-dist/swagger-ui-standalone-preset.js.map +1 -0
  24. data/node_modules/swagger-ui-dist/swagger-ui.css +4 -0
  25. data/node_modules/swagger-ui-dist/swagger-ui.css.map +1 -0
  26. data/node_modules/swagger-ui-dist/swagger-ui.js +3 -0
  27. data/node_modules/swagger-ui-dist/swagger-ui.js.map +1 -0
  28. metadata +25 -3
  29. data/lib/generators/rswag/ui/install/templates/rswag-ui.rb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cfb8dd44e70e7ed3f665577ecf7b1a224570fc4d23856fda660f5d9840551fb2
4
- data.tar.gz: f0225e14d38fb41d6a3ad57cd7b3dc573b8c601a81ff0b618b91254a8b2c8e6d
3
+ metadata.gz: 051a8bf48850f0118a3b8119efe63ed7c57b68fbe390fa019be6a9599f0dad05
4
+ data.tar.gz: 43babc2b967fdc6371cce1a6689cf834bc8b18432bb81fab0978db81b3e8e8a5
5
5
  SHA512:
6
- metadata.gz: e59d50cde145e38b58fc2a92b35989456a659b1fa9170ce52ea8049aea0005353e73b191800f5078053920f82af2cc0b3f8707b06831ac020f2ff7d897cfd600
7
- data.tar.gz: 45a0d51bf1e8f325c596666673431d0fbd10b08116ea2933913cf06f9aaff120469910e0dcc797e4fd28083dd06c76657d6de891aae9f5dc36451e5011302152
6
+ metadata.gz: e75023ec783aaf08cc6a35a55aa1286571d2a6eb930c3edb1fa7a72f1541b5dbdf92ff901e7528091321fccab6edbc5977a59952e2c35eaf94075f1fdeab4073
7
+ data.tar.gz: fe82e2faee07454d84ac5fe86fd7ce2f533b36963f74ca1df7b2b625d320406c76ced7add70c15a4c107f68b6fd02fff6d4d2f3feb2dd412af4dc22651c7549f
@@ -7,7 +7,7 @@ module Rswag
7
7
  source_root File.expand_path('../templates', __FILE__)
8
8
 
9
9
  def add_initializer
10
- template('rswag-ui.rb', 'config/initializers/rswag-ui.rb')
10
+ template('rswag_ui.rb', 'config/initializers/rswag_ui.rb')
11
11
  end
12
12
 
13
13
  def add_routes
@@ -0,0 +1,16 @@
1
+ Rswag::Ui.configure do |c|
2
+
3
+ # List the Swagger endpoints that you want to be documented through the
4
+ # swagger-ui. The first parameter is the path (absolute or relative to the UI
5
+ # host) to the corresponding endpoint and the second is a title that will be
6
+ # displayed in the document selector.
7
+ # NOTE: If you're using rspec-api to expose Swagger files
8
+ # (under swagger_root) as JSON or YAML endpoints, then the list below should
9
+ # correspond to the relative paths for those endpoints.
10
+
11
+ c.swagger_endpoint '/api-docs/v1/swagger.yaml', 'API V1 Docs'
12
+
13
+ # Add Basic Auth in case your API is private
14
+ # c.basic_auth_enabled = true
15
+ # c.basic_auth_credentials 'username', 'password'
16
+ end
@@ -12,7 +12,7 @@ module Rswag
12
12
 
13
13
  def initialize
14
14
  @template_locations = [
15
- # preffered override location
15
+ # preferred override location
16
16
  "#{Rack::Directory.new('').root}/swagger/index.erb",
17
17
  # backwards compatible override location
18
18
  "#{Rack::Directory.new('').root}/app/views/rswag/ui/home/index.html.erb",
@@ -37,7 +37,7 @@ module Rswag
37
37
  end
38
38
 
39
39
  def template_filename
40
- @config.template_locations.find { |filename| File.exists?(filename) }
40
+ @config.template_locations.find { |filename| File.exist?(filename) }
41
41
  end
42
42
  end
43
43
  end
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ swagger-ui
2
+ Copyright 2020-2021 SmartBear Software Inc.
@@ -0,0 +1,22 @@
1
+ # Swagger UI Dist
2
+ [![NPM version](https://badge.fury.io/js/swagger-ui-dist.svg)](http://badge.fury.io/js/swagger-ui-dist)
3
+
4
+ # API
5
+
6
+ This module, `swagger-ui-dist`, exposes Swagger-UI's entire dist folder as a dependency-free npm module.
7
+ Use `swagger-ui` instead, if you'd like to have npm install dependencies for you.
8
+
9
+ `SwaggerUIBundle` and `SwaggerUIStandalonePreset` can be imported:
10
+ ```javascript
11
+ import { SwaggerUIBundle, SwaggerUIStandalonePreset } from "swagger-ui-dist"
12
+ ```
13
+
14
+ To get an absolute path to this directory for static file serving, use the exported `getAbsoluteFSPath` method:
15
+
16
+ ```javascript
17
+ const swaggerUiAssetPath = require("swagger-ui-dist").getAbsoluteFSPath()
18
+
19
+ // then instantiate server that serves files from the swaggerUiAssetPath
20
+ ```
21
+
22
+ For anything else, check the [Swagger-UI](https://github.com/swagger-api/swagger-ui) repository.
@@ -0,0 +1,14 @@
1
+ /*
2
+ * getAbsoluteFSPath
3
+ * @return {string} When run in NodeJS env, returns the absolute path to the current directory
4
+ * When run outside of NodeJS, will return an error message
5
+ */
6
+ const getAbsoluteFSPath = function () {
7
+ // detect whether we are running in a browser or nodejs
8
+ if (typeof module !== "undefined" && module.exports) {
9
+ return require("path").resolve(__dirname)
10
+ }
11
+ throw new Error('getAbsoluteFSPath can only be called within a Nodejs environment');
12
+ }
13
+
14
+ module.exports = getAbsoluteFSPath
@@ -0,0 +1,60 @@
1
+ <!-- HTML for static distribution bundle build -->
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <title>Swagger UI</title>
7
+ <link rel="stylesheet" type="text/css" href="./swagger-ui.css" />
8
+ <link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
9
+ <link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
10
+ <style>
11
+ html
12
+ {
13
+ box-sizing: border-box;
14
+ overflow: -moz-scrollbars-vertical;
15
+ overflow-y: scroll;
16
+ }
17
+
18
+ *,
19
+ *:before,
20
+ *:after
21
+ {
22
+ box-sizing: inherit;
23
+ }
24
+
25
+ body
26
+ {
27
+ margin:0;
28
+ background: #fafafa;
29
+ }
30
+ </style>
31
+ </head>
32
+
33
+ <body>
34
+ <div id="swagger-ui"></div>
35
+
36
+ <script src="./swagger-ui-bundle.js" charset="UTF-8"> </script>
37
+ <script src="./swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
38
+ <script>
39
+ window.onload = function() {
40
+ // Begin Swagger UI call region
41
+ const ui = SwaggerUIBundle({
42
+ url: "https://petstore.swagger.io/v2/swagger.json",
43
+ dom_id: '#swagger-ui',
44
+ deepLinking: true,
45
+ presets: [
46
+ SwaggerUIBundle.presets.apis,
47
+ SwaggerUIStandalonePreset
48
+ ],
49
+ plugins: [
50
+ SwaggerUIBundle.plugins.DownloadUrl
51
+ ],
52
+ layout: "StandaloneLayout"
53
+ });
54
+ // End Swagger UI call region
55
+
56
+ window.ui = ui;
57
+ };
58
+ </script>
59
+ </body>
60
+ </html>
@@ -0,0 +1,17 @@
1
+ try {
2
+ module.exports.SwaggerUIBundle = require("./swagger-ui-bundle.js")
3
+ module.exports.SwaggerUIStandalonePreset = require("./swagger-ui-standalone-preset.js")
4
+ } catch(e) {
5
+ // swallow the error if there's a problem loading the assets.
6
+ // allows this module to support providing the assets for browserish contexts,
7
+ // without exploding in a Node context.
8
+ //
9
+ // see https://github.com/swagger-api/swagger-ui/issues/3291#issuecomment-311195388
10
+ // for more information.
11
+ }
12
+
13
+ // `absolutePath` and `getAbsoluteFSPath` are both here because at one point,
14
+ // we documented having one and actually implemented the other.
15
+ // They were both retained so we don't break anyone's code.
16
+ module.exports.absolutePath = require("./absolute-path.js")
17
+ module.exports.getAbsoluteFSPath = require("./absolute-path.js")
@@ -0,0 +1,75 @@
1
+ <!doctype html>
2
+ <html lang="en-US">
3
+ <head>
4
+ <title>Swagger UI: OAuth2 Redirect</title>
5
+ </head>
6
+ <body>
7
+ <script>
8
+ 'use strict';
9
+ function run () {
10
+ var oauth2 = window.opener.swaggerUIRedirectOauth2;
11
+ var sentState = oauth2.state;
12
+ var redirectUrl = oauth2.redirectUrl;
13
+ var isValid, qp, arr;
14
+
15
+ if (/code|token|error/.test(window.location.hash)) {
16
+ qp = window.location.hash.substring(1);
17
+ } else {
18
+ qp = location.search.substring(1);
19
+ }
20
+
21
+ arr = qp.split("&");
22
+ arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';});
23
+ qp = qp ? JSON.parse('{' + arr.join() + '}',
24
+ function (key, value) {
25
+ return key === "" ? value : decodeURIComponent(value);
26
+ }
27
+ ) : {};
28
+
29
+ isValid = qp.state === sentState;
30
+
31
+ if ((
32
+ oauth2.auth.schema.get("flow") === "accessCode" ||
33
+ oauth2.auth.schema.get("flow") === "authorizationCode" ||
34
+ oauth2.auth.schema.get("flow") === "authorization_code"
35
+ ) && !oauth2.auth.code) {
36
+ if (!isValid) {
37
+ oauth2.errCb({
38
+ authId: oauth2.auth.name,
39
+ source: "auth",
40
+ level: "warning",
41
+ message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
42
+ });
43
+ }
44
+
45
+ if (qp.code) {
46
+ delete oauth2.state;
47
+ oauth2.auth.code = qp.code;
48
+ oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
49
+ } else {
50
+ let oauthErrorMsg;
51
+ if (qp.error) {
52
+ oauthErrorMsg = "["+qp.error+"]: " +
53
+ (qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
54
+ (qp.error_uri ? "More info: "+qp.error_uri : "");
55
+ }
56
+
57
+ oauth2.errCb({
58
+ authId: oauth2.auth.name,
59
+ source: "auth",
60
+ level: "error",
61
+ message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
62
+ });
63
+ }
64
+ } else {
65
+ oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
66
+ }
67
+ window.close();
68
+ }
69
+
70
+ window.addEventListener('DOMContentLoaded', function () {
71
+ run();
72
+ });
73
+ </script>
74
+ </body>
75
+ </html>
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "swagger-ui-dist",
3
+ "version": "4.1.3",
4
+ "main": "index.js",
5
+ "repository": "git@github.com:swagger-api/swagger-ui.git",
6
+ "contributors": [
7
+ "(in alphabetical order)",
8
+ "Anna Bodnia <anna.bodnia@gmail.com>",
9
+ "Buu Nguyen <buunguyen@gmail.com>",
10
+ "Josh Ponelat <jponelat@gmail.com>",
11
+ "Kyle Shockey <kyleshockey1@gmail.com>",
12
+ "Robert Barnwell <robert@robertismy.name>",
13
+ "Sahar Jafari <shr.jafari@gmail.com>"
14
+ ],
15
+ "license": "Apache-2.0",
16
+ "dependencies": {},
17
+ "devDependencies": {}
18
+ }