Skip to content

Commit f22a628

Browse files
committed
in with the new
1 parent bd8344c commit f22a628

File tree

157 files changed

+12952
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+12952
-0
lines changed

.babelrc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"presets": [
3+
"es2015",
4+
"react",
5+
"stage-0"
6+
],
7+
"plugins": [
8+
[
9+
"module-alias",
10+
[
11+
{
12+
"expose": "components",
13+
"src": "src/core/components"
14+
},
15+
{
16+
"expose": "core",
17+
"src": "src/core"
18+
},
19+
{
20+
"expose": "img",
21+
"src": "src/img"
22+
},
23+
{
24+
"expose": "corePlugins",
25+
"src": "src/core/plugins"
26+
},
27+
{
28+
"expose": "less",
29+
"src": "src/less"
30+
},
31+
{
32+
"expose": "base",
33+
"src": "npm:getbase/src/less/base"
34+
}
35+
]
36+
]
37+
]
38+
}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.idea
3+
.deps_check
4+
.DS_Store
5+
npm-debug.log

.gitmodules

Whitespace-only changes.

LICENSE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Copyright 2017 SmartBear Software
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
6+
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.

README.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Swagger UI
2+
3+
[![NPM version](https://badge.fury.io/js/swagger-ui.svg)](http://badge.fury.io/js/swagger-ui)
4+
5+
## New!
6+
7+
This is the new version of swagger-ui, 3.x.
8+
9+
For the older version of swagger-ui, refer to the [*2.x branch*](https://github.com/swagger-api/swagger-ui/tree/2.x).
10+
11+
## Compatibility
12+
The OpenAPI Specification has undergone 4 revisions since initial creation in 2010. Compatibility between swagger-ui and the OpenAPI Specification is as follows:
13+
14+
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes | Status
15+
------------------ | ------------ | -------------------------- | ----- | ------
16+
3.0.0 | 2017-03-17 | 2.0 | [tag v3.0.0](https://github.com/swagger-api/swagger-ui/tree/v3.0.0) |
17+
2.2.10 | 2017-01-04 | 1.1, 1.2, 2.0 | [tag v2.2.10](https://github.com/swagger-api/swagger-ui/tree/v2.2.10) |
18+
2.1.5 | 2016-07-20 | 1.1, 1.2, 2.0 | [tag v2.1.5](https://github.com/swagger-api/swagger-ui/tree/v2.1.5) |
19+
2.0.24 | 2014-09-12 | 1.1, 1.2 | [tag v2.0.24](https://github.com/swagger-api/swagger-ui/tree/v2.0.24) |
20+
1.0.13 | 2013-03-08 | 1.1, 1.2 | [tag v1.0.13](https://github.com/swagger-api/swagger-ui/tree/v1.0.13) |
21+
1.0.1 | 2011-10-11 | 1.0, 1.1 | [tag v1.0.1](https://github.com/swagger-api/swagger-ui/tree/v1.0.1) |
22+
23+
24+
### How to run
25+
26+
##### Prerequisites
27+
- Node 6.x
28+
- NPM 3.x
29+
30+
If you just want to see your specs, open `public/index.html` in your browser directly from your filesystem.
31+
32+
If you'd like to make modifications to the codebase, run the dev server with: `npm run dev`.
33+
34+
35+
##### Browser support
36+
Swagger UI works in the latest versions of Chrome, Safari, Firefox, Edge and IE11.
37+
38+
## CORS Support
39+
40+
CORS is a technique to prevent websites from doing bad things with your personal data. Most browsers + JavaScript toolkits not only support CORS but enforce it, which has implications for your API server which supports Swagger.
41+
42+
You can read about CORS here: http://www.w3.org/TR/cors.
43+
44+
There are two cases where no action is needed for CORS support:
45+
46+
1. swagger-ui is hosted on the same server as the application itself (same host *and* port).
47+
2. The application is located behind a proxy that enables the required CORS headers. This may already be covered within your organization.
48+
49+
Otherwise, CORS support needs to be enabled for:
50+
51+
1. Your Swagger docs. For Swagger 2.0 it's the `swagger.json`/`swagger.yaml` and any externally `$ref`ed docs.
52+
2. For the `Try it now` button to work, CORS needs to be enabled on your API endpoints as well.
53+
54+
### Testing CORS Support
55+
56+
You can verify CORS support with one of three techniques:
57+
58+
- Curl your API and inspect the headers. For instance:
59+
60+
```bash
61+
$ curl -I "http://petstore.swagger.io/v2/swagger.json"
62+
HTTP/1.1 200 OK
63+
Date: Sat, 31 Jan 2015 23:05:44 GMT
64+
Access-Control-Allow-Origin: *
65+
Access-Control-Allow-Methods: GET, POST, DELETE, PUT, PATCH, OPTIONS
66+
Access-Control-Allow-Headers: Content-Type, api_key, Authorization
67+
Content-Type: application/json
68+
Content-Length: 0
69+
```
70+
71+
This tells us that the petstore resource listing supports OPTIONS, and the following headers: `Content-Type`, `api_key`, `Authorization`.
72+
73+
- Try swagger-ui from your file system and look at the debug console. If CORS is not enabled, you'll see something like this:
74+
75+
```
76+
XMLHttpRequest cannot load http://sad.server.com/v2/api-docs. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
77+
```
78+
79+
Swagger-UI cannot easily show this error state.
80+
81+
- Using the http://www.test-cors.org website. Keep in mind this will show a successful result even if `Access-Control-Allow-Headers` is not available, which is still required for Swagger-UI to function properly.
82+
83+
### Enabling CORS
84+
85+
The method of enabling CORS depends on the server and/or framework you use to host your application. http://enable-cors.org provides information on how to enable CORS in some common web servers.
86+
87+
Other servers/frameworks may provide you information on how to enable it specifically in their use case.
88+
89+
### CORS and Header Parameters
90+
91+
Swagger lets you easily send headers as parameters to requests. The name of these headers *MUST* be supported in your CORS configuration as well. From our example above:
92+
93+
```
94+
Access-Control-Allow-Headers: Content-Type, api_key, Authorization
95+
```
96+
97+
Only headers with these names will be allowed to be sent by Swagger-UI.
98+
99+
## License
100+
101+
Copyright 2017 SmartBear Software
102+
103+
Licensed under the Apache License, Version 2.0 (the "License");
104+
you may not use this file except in compliance with the License.
105+
You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
106+
107+
Unless required by applicable law or agreed to in writing, software
108+
distributed under the License is distributed on an "AS IS" BASIS,
109+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
110+
See the License for the specific language governing permissions and
111+
limitations under the License.

build-tools/loadersByExtension.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
function extsToRegExp(exts) {
2+
return new RegExp("\\.(" + exts.map(function(ext) {
3+
return ext.replace(/\./g, "\\.");
4+
}).join("|") + ")(\\?.*)?$");
5+
}
6+
7+
module.exports = function loadersByExtension(obj) {
8+
var loaders = [];
9+
Object.keys(obj).forEach(function(key) {
10+
var exts = key.split("|");
11+
var value = obj[key];
12+
var entry = {
13+
extensions: exts,
14+
test: extsToRegExp(exts)
15+
};
16+
if(Array.isArray(value)) {
17+
entry.loaders = value;
18+
} else if(typeof value === "string") {
19+
entry.loader = value;
20+
} else {
21+
Object.keys(value).forEach(function(valueKey) {
22+
entry[valueKey] = value[valueKey];
23+
});
24+
}
25+
loaders.push(entry);
26+
});
27+
return loaders;
28+
};

dist/index.html

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<!DOCTYPE html>
2+
<!-- this is for the dev server -->
3+
<html lang="en">
4+
<head>
5+
<meta charset="UTF-8">
6+
<title>Swagger UI</title>
7+
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
8+
<style>
9+
html
10+
{
11+
box-sizing: border-box;
12+
overflow: -moz-scrollbars-vertical;
13+
overflow-y: scroll;
14+
}
15+
*,
16+
*:before,
17+
*:after
18+
{
19+
box-sizing: inherit;
20+
}
21+
22+
body {
23+
margin:0;
24+
background: #fafafa;
25+
}
26+
</style>
27+
</head>
28+
29+
<body>
30+
31+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
32+
<defs>
33+
<symbol viewBox="0 0 20 20" id="unlocked">
34+
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
35+
</symbol>
36+
37+
<symbol viewBox="0 0 20 20" id="locked">
38+
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z"/>
39+
</symbol>
40+
41+
<symbol viewBox="0 0 20 20" id="close">
42+
<path d="M14.348 14.849c-.469.469-1.229.469-1.697 0L10 11.819l-2.651 3.029c-.469.469-1.229.469-1.697 0-.469-.469-.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-.469-.469-.469-1.228 0-1.697.469-.469 1.228-.469 1.697 0L10 8.183l2.651-3.031c.469-.469 1.228-.469 1.697 0 .469.469.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c.469.469.469 1.229 0 1.698z"/>
43+
</symbol>
44+
45+
<symbol viewBox="0 0 20 20" id="large-arrow">
46+
<path d="M13.25 10L6.109 2.58c-.268-.27-.268-.707 0-.979.268-.27.701-.27.969 0l7.83 7.908c.268.271.268.709 0 .979l-7.83 7.908c-.268.271-.701.27-.969 0-.268-.269-.268-.707 0-.979L13.25 10z"/>
47+
</symbol>
48+
49+
<symbol viewBox="0 0 20 20" id="large-arrow-down">
50+
<path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z"/>
51+
</symbol>
52+
53+
54+
<symbol viewBox="0 0 24 24" id="jump-to">
55+
<path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z"/>
56+
</symbol>
57+
58+
<symbol viewBox="0 0 24 24" id="expand">
59+
<path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"/>
60+
</symbol>
61+
62+
</defs>
63+
</svg>
64+
65+
<div id="swagger-ui"></div>
66+
67+
<!-- don't be alarmed, these don't match what's in dist, because webpack-dev-server serves them in memory. -->
68+
<script src="/dist/SwaggerUIBundle.js"> </script>
69+
<script src="/dist/SwaggerUIStandalonePreset.js"> </script>
70+
<script>
71+
window.onload = function() {
72+
// Build a system
73+
const ui = SwaggerUIBundle({
74+
url: "http://petstore.swagger.io/v2/swagger.json",
75+
dom_id: '#swagger-ui',
76+
presets: [
77+
SwaggerUIBundle.presets.apis,
78+
// yay ES6 modules ↘
79+
Array.isArray(SwaggerUIStandalonePreset) ? SwaggerUIStandalonePreset : SwaggerUIStandalonePreset.default
80+
],
81+
plugins: [
82+
SwaggerUIBundle.plugins.DownloadUrl
83+
],
84+
layout: "StandaloneLayout"
85+
})
86+
87+
window.ui = ui
88+
}
89+
</script>
90+
</body>
91+
92+
</html>

dist/swagger-ui-bundle.js

Lines changed: 105 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/swagger-ui-bundle.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/swagger-ui-standalone-preset.js

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)