Merge branch 'master' into master
This commit is contained in:
33
README.md
33
README.md
@@ -15,7 +15,7 @@ The OpenAPI Specification has undergone 4 revisions since initial creation in 20
|
|||||||
|
|
||||||
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes | Status
|
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes | Status
|
||||||
------------------ | ------------ | -------------------------- | ----- | ------
|
------------------ | ------------ | -------------------------- | ----- | ------
|
||||||
3.0.3 | 2017-03-19 | 2.0 | [tag v3.0.3](https://github.com/swagger-api/swagger-ui/tree/v3.0.3) |
|
3.0.4 | 2017-03-19 | 2.0 | [tag v3.0.4](https://github.com/swagger-api/swagger-ui/tree/v3.0.4) |
|
||||||
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) |
|
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) |
|
||||||
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) |
|
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) |
|
||||||
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) |
|
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) |
|
||||||
@@ -50,13 +50,42 @@ Swagger UI works in the latest versions of Chrome, Safari, Firefox, Edge and IE1
|
|||||||
|
|
||||||
To help with the migration, here are the currently known issues with 3.X. This list will update regularly, and will not include features that were not implemented in previous versions.
|
To help with the migration, here are the currently known issues with 3.X. This list will update regularly, and will not include features that were not implemented in previous versions.
|
||||||
|
|
||||||
- Currently, the only configuration options available are the `url` and `spec`.
|
- Only part of the [parameters](#parameters) previously supported are available.
|
||||||
- The JSON Form Editor is not implemented.
|
- The JSON Form Editor is not implemented.
|
||||||
- Shebang URL support for operations is missing.
|
- Shebang URL support for operations is missing.
|
||||||
- Support for `collectionFormat` is partial.
|
- Support for `collectionFormat` is partial.
|
||||||
- l10n (translations) is not implemented.
|
- l10n (translations) is not implemented.
|
||||||
- Relative path support for external files is not implemented.
|
- Relative path support for external files is not implemented.
|
||||||
|
|
||||||
|
### SwaggerUIBundle
|
||||||
|
To use swagger-ui you should take a look at the [source of swagger-ui html page](https://github.com/swagger-api/swagger-ui/blob/master/dist/index.html) and customize it. This basically requires you to instantiate a SwaggerUi object and call load() on it as below:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const ui = SwaggerUIBundle({
|
||||||
|
url: "http://petstore.swagger.io/v2/swagger.json",
|
||||||
|
dom_id: '#swagger-ui',
|
||||||
|
presets: [
|
||||||
|
SwaggerUIBundle.presets.apis,
|
||||||
|
SwaggerUIStandalonePreset
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
SwaggerUIBundle.plugins.DownloadUrl
|
||||||
|
],
|
||||||
|
layout: "StandaloneLayout"
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
Parameter Name | Description
|
||||||
|
--- | ---
|
||||||
|
url | The url pointing to API definition (normally `swagger.json` or `swagger.yaml`).
|
||||||
|
spec | A JSON object describing the OpenAPI Specification. When used, the `url` parameter will not be parsed. This is useful for testing manually-generated specifications without hosting them.
|
||||||
|
validatorUrl | By default, Swagger-UI attempts to validate specs against swagger.io's online validator. You can use this parameter to set a different validator URL, for example for locally deployed validators ([Validator Badge](https://github.com/swagger-api/validator-badge)). Setting it to `null` will disable validation.
|
||||||
|
dom_id | The id of a dom element inside which SwaggerUi will put the user interface for swagger.
|
||||||
|
oauth2RedirectUrl | OAuth redirect URL
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## CORS Support
|
## CORS Support
|
||||||
|
|
||||||
|
|||||||
95
dev-helpers/index.html
Normal file
95
dev-helpers/index.html
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
<!-- HTML for dev server -->
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Swagger UI</title>
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
|
||||||
|
<link rel="icon" type="image/png" href="../public/favicon-32x32.png" sizes="32x32" />
|
||||||
|
<link rel="icon" type="image/png" href="../public/favicon-16x16.png" sizes="16x16" />
|
||||||
|
<style>
|
||||||
|
html
|
||||||
|
{
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow: -moz-scrollbars-vertical;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
*,
|
||||||
|
*:before,
|
||||||
|
*:after
|
||||||
|
{
|
||||||
|
box-sizing: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin:0;
|
||||||
|
background: #fafafa;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
|
||||||
|
<defs>
|
||||||
|
<symbol viewBox="0 0 20 20" id="unlocked">
|
||||||
|
<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>
|
||||||
|
</symbol>
|
||||||
|
|
||||||
|
<symbol viewBox="0 0 20 20" id="locked">
|
||||||
|
<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"/>
|
||||||
|
</symbol>
|
||||||
|
|
||||||
|
<symbol viewBox="0 0 20 20" id="close">
|
||||||
|
<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"/>
|
||||||
|
</symbol>
|
||||||
|
|
||||||
|
<symbol viewBox="0 0 20 20" id="large-arrow">
|
||||||
|
<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"/>
|
||||||
|
</symbol>
|
||||||
|
|
||||||
|
<symbol viewBox="0 0 20 20" id="large-arrow-down">
|
||||||
|
<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"/>
|
||||||
|
</symbol>
|
||||||
|
|
||||||
|
|
||||||
|
<symbol viewBox="0 0 24 24" id="jump-to">
|
||||||
|
<path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z"/>
|
||||||
|
</symbol>
|
||||||
|
|
||||||
|
<symbol viewBox="0 0 24 24" id="expand">
|
||||||
|
<path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"/>
|
||||||
|
</symbol>
|
||||||
|
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<div id="swagger-ui"></div>
|
||||||
|
|
||||||
|
<script src="./swagger-ui-bundle.js"> </script>
|
||||||
|
<script src="./swagger-ui-standalone-preset.js"> </script>
|
||||||
|
<script>
|
||||||
|
window.onload = function() {
|
||||||
|
window["SwaggerUIBundle"] = window["swagger-ui-bundle"]
|
||||||
|
window["SwaggerUIStandalonePreset"] = window["swagger-ui-standalone-preset"]
|
||||||
|
// Build a system
|
||||||
|
const ui = SwaggerUIBundle({
|
||||||
|
url: "http://petstore.swagger.io/v2/swagger.json",
|
||||||
|
dom_id: '#swagger-ui',
|
||||||
|
presets: [
|
||||||
|
SwaggerUIBundle.presets.apis,
|
||||||
|
SwaggerUIStandalonePreset
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
SwaggerUIBundle.plugins.DownloadUrl
|
||||||
|
],
|
||||||
|
layout: "StandaloneLayout"
|
||||||
|
})
|
||||||
|
|
||||||
|
window.ui = ui
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
91
dist/swagger-ui-bundle.js
vendored
91
dist/swagger-ui-bundle.js
vendored
File diff suppressed because one or more lines are too long
2
dist/swagger-ui-bundle.js.map
vendored
2
dist/swagger-ui-bundle.js.map
vendored
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AAsdA;;;;;;AAoIA;AAk7FA;AAmtCA;;;;;AA0uIA;AAq7IA;AAo7FA;AA0wGA;AAglFA;AA0jFA;AAq9CA;AA6jDA;AAgrCA;AAgtEA;AAgkIA;;;;;;;;;;;;;;AAw4GA;AAyoIA;AAiuJA;AA8kHA;AA8mGA;AAokEA;AAi3DA;AA4xDA;AAy9BA;;;;;;AA6sEA;AAwzFA;;;;;AA+1CA;AA2qFA;AAo2CA;AAmhCA;AA2kDA;AAkvEA;AA8iGA;;;;;;;;;AA6pBA;AA2zIA;AAg4DA;AAywDA","sourceRoot":""}
|
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AAsdA;AAkoJA;AAyiCA;;;;;AAskCA;AA66IA;AA27FA;AAuwGA;AAymEA;AAm+CA;AA+/CA;AA+rCA;AA65DA;AAs0IA;;;;;;;;;;;;;;AAgyFA;AAyoIA;AAiuJA;AA8kHA;AAonGA;AAukEA;AA02DA;AAyxDA;AAi9BA;;;;;;AA6xEA;AAq2FA;;;;;AA23CA;AA2qFA;AAo2CA;AAokCA;AAkhDA;AAwvEA;AAq+FA;;;;;;;;;AAwyBA;AA2zIA;AAi4DA;AA6tDA;;;;;;AAg3BA;AA8iHA;AAipGA","sourceRoot":""}
|
||||||
22
dist/swagger-ui.js
vendored
22
dist/swagger-ui.js
vendored
File diff suppressed because one or more lines are too long
2
dist/swagger-ui.js.map
vendored
2
dist/swagger-ui.js.map
vendored
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;AAsoGA;AAy4HA;AA67FA;AA4mCA;AA+9BA;AAyiCA;AAu5BA","sourceRoot":""}
|
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAmwCA;AAoyHA;AA2wHA;AA07FA;AAmnCA;AAu/BA;AAmiCA;AA44BA","sourceRoot":""}
|
||||||
12
package.json
12
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "swagger-ui",
|
"name": "swagger-ui",
|
||||||
"version": "3.0.3",
|
"version": "3.0.4",
|
||||||
"main": "dist/swagger-ui.js",
|
"main": "dist/swagger-ui.js",
|
||||||
"repository": "git@github.com:swagger-api/swagger-ui.git",
|
"repository": "git@github.com:swagger-api/swagger-ui.git",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
"dev": "npm-run-all --parallel hot-server watch open-localhost",
|
"dev": "npm-run-all --parallel hot-server watch open-localhost",
|
||||||
"watch": "webpack --config webpack-watch.config.js --watch --progress",
|
"watch": "webpack --config webpack-watch.config.js --watch --progress",
|
||||||
"open-localhost": "node -e 'require(\"open\")(\"http://localhost:3200\")'",
|
"open-localhost": "node -e 'require(\"open\")(\"http://localhost:3200\")'",
|
||||||
"hot-server": "webpack-dev-server --host 0.0.0.0 --config webpack-hot-dev-server.config.js --inline --hot --progress --content-base dist/",
|
"hot-server": "webpack-dev-server --host 0.0.0.0 --config webpack-hot-dev-server.config.js --inline --hot --progress --content-base dev-helpers/",
|
||||||
"deps-license": "license-checker --production --csv --out $npm_package_config_deps_check_dir/licenses.csv && license-checker --development --csv --out $npm_package_config_deps_check_dir/licenses-dev.csv",
|
"deps-license": "license-checker --production --csv --out $npm_package_config_deps_check_dir/licenses.csv && license-checker --development --csv --out $npm_package_config_deps_check_dir/licenses-dev.csv",
|
||||||
"deps-size": "webpack -p --config webpack.check.js --json | webpack-bundle-size-analyzer >| $npm_package_config_deps_check_dir/sizes.txt",
|
"deps-size": "webpack -p --config webpack.check.js --json | webpack-bundle-size-analyzer >| $npm_package_config_deps_check_dir/sizes.txt",
|
||||||
"deps-check": "npm run deps-license && npm run deps-size",
|
"deps-check": "npm run deps-license && npm run deps-size",
|
||||||
@@ -37,14 +37,11 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-polyfill": "^6.23.0",
|
"babel-polyfill": "^6.23.0",
|
||||||
"brace": "0.7.0",
|
"brace": "0.7.0",
|
||||||
"btoa": "^1.1.2",
|
|
||||||
"debounce": "1.0.0",
|
|
||||||
"deep-extend": "0.4.1",
|
"deep-extend": "0.4.1",
|
||||||
"expect": "1.20.2",
|
"expect": "1.20.2",
|
||||||
"getbase": "^2.8.2",
|
"getbase": "^2.8.2",
|
||||||
"immutable": "^3.x.x",
|
"immutable": "^3.x.x",
|
||||||
"js-yaml": "^3.5.5",
|
"js-yaml": "^3.5.5",
|
||||||
"jsonschema": "^1.1.0",
|
|
||||||
"less": "2.7.1",
|
"less": "2.7.1",
|
||||||
"lodash": "4.17.2",
|
"lodash": "4.17.2",
|
||||||
"matcher": "^0.1.2",
|
"matcher": "^0.1.2",
|
||||||
@@ -70,12 +67,11 @@
|
|||||||
"reselect": "2.5.3",
|
"reselect": "2.5.3",
|
||||||
"serialize-error": "2.0.0",
|
"serialize-error": "2.0.0",
|
||||||
"shallowequal": "0.2.2",
|
"shallowequal": "0.2.2",
|
||||||
"swagger-client": "^3.0.3",
|
"swagger-client": "^3.0.4",
|
||||||
"whatwg-fetch": "0.11.1",
|
"whatwg-fetch": "0.11.1",
|
||||||
"worker-loader": "^0.7.1",
|
"worker-loader": "^0.7.1",
|
||||||
"xml": "1.0.1",
|
"xml": "1.0.1",
|
||||||
"yaml-js": "^0.1.3",
|
"yaml-js": "^0.1.3"
|
||||||
"yaml-worker": "^2.1.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"autoprefixer": "6.6.1",
|
"autoprefixer": "6.6.1",
|
||||||
|
|||||||
@@ -10,14 +10,13 @@ export default class Oauth2 extends React.Component {
|
|||||||
static propTypes = {
|
static propTypes = {
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
authorized: PropTypes.object,
|
authorized: PropTypes.object,
|
||||||
configs: PropTypes.object,
|
|
||||||
getComponent: PropTypes.func.isRequired,
|
getComponent: PropTypes.func.isRequired,
|
||||||
schema: PropTypes.object.isRequired,
|
schema: PropTypes.object.isRequired,
|
||||||
authSelectors: PropTypes.object.isRequired,
|
authSelectors: PropTypes.object.isRequired,
|
||||||
authActions: PropTypes.object.isRequired,
|
authActions: PropTypes.object.isRequired,
|
||||||
errSelectors: PropTypes.object.isRequired,
|
errSelectors: PropTypes.object.isRequired,
|
||||||
errActions: PropTypes.object.isRequired,
|
errActions: PropTypes.object.isRequired,
|
||||||
getConfigs: PropTypes.function
|
getConfigs: PropTypes.any
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props, context) {
|
constructor(props, context) {
|
||||||
@@ -173,7 +172,7 @@ export default class Oauth2 extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
!isAuthorized && flow !== PASSWORD && scopes && scopes.size ? <div className="scopes">
|
!isAuthorized && scopes && scopes.size ? <div className="scopes">
|
||||||
<h2>Scopes:</h2>
|
<h2>Scopes:</h2>
|
||||||
{ scopes.map((description, name) => {
|
{ scopes.map((description, name) => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import { List } from "immutable"
|
|||||||
const braceOpen = "{"
|
const braceOpen = "{"
|
||||||
const braceClose = "}"
|
const braceClose = "}"
|
||||||
|
|
||||||
|
const propStyle = { color: "#999", fontStyle: "italic" }
|
||||||
|
|
||||||
const EnumModel = ({ value }) => {
|
const EnumModel = ({ value }) => {
|
||||||
let collapsedContent = <span>Array [ { value.count() } ]</span>
|
let collapsedContent = <span>Array [ { value.count() } ]</span>
|
||||||
return <span className="prop-enum">
|
return <span className="prop-enum">
|
||||||
@@ -129,7 +131,6 @@ class Primitive extends Component {
|
|||||||
let enumArray = schema.get("enum")
|
let enumArray = schema.get("enum")
|
||||||
let properties = schema.filter( ( v, key) => ["enum", "type", "format", "$$ref"].indexOf(key) === -1 )
|
let properties = schema.filter( ( v, key) => ["enum", "type", "format", "$$ref"].indexOf(key) === -1 )
|
||||||
let style = required ? { fontWeight: "bold" } : {}
|
let style = required ? { fontWeight: "bold" } : {}
|
||||||
let propStyle = { color: "#999", fontStyle: "italic" }
|
|
||||||
|
|
||||||
return <span className="prop">
|
return <span className="prop">
|
||||||
<span className="prop-type" style={ style }>{ type }</span> { required && <span style={{ color: "red" }}>*</span>}
|
<span className="prop-type" style={ style }>{ type }</span> { required && <span style={{ color: "red" }}>*</span>}
|
||||||
@@ -167,12 +168,23 @@ class ArrayModel extends Component {
|
|||||||
render(){
|
render(){
|
||||||
let { required, schema, depth, expandDepth } = this.props
|
let { required, schema, depth, expandDepth } = this.props
|
||||||
let items = schema.get("items")
|
let items = schema.get("items")
|
||||||
|
let properties = schema.filter( ( v, key) => ["type", "items", "$$ref"].indexOf(key) === -1 )
|
||||||
|
|
||||||
return <span>
|
return <span className="model">
|
||||||
|
<span className="model-title">
|
||||||
|
<span className="model-title__text">{ schema.get("title") }</span>
|
||||||
|
</span>
|
||||||
<Collapse collapsed={ depth > expandDepth } collapsedContent="[...]">
|
<Collapse collapsed={ depth > expandDepth } collapsedContent="[...]">
|
||||||
[
|
[
|
||||||
<span><Model { ...this.props } schema={ items } required={ false }/></span>
|
<span><Model { ...this.props } schema={ items } required={ false }/></span>
|
||||||
]
|
]
|
||||||
|
{
|
||||||
|
properties.size ? <span>
|
||||||
|
{ properties.entrySeq().map( ( [ key, v ] ) => <span key={`${key}-${v}`} style={propStyle}>
|
||||||
|
<br />{ `${key}:`}{ String(v) }</span>)
|
||||||
|
}<br /></span>
|
||||||
|
: null
|
||||||
|
}
|
||||||
</Collapse>
|
</Collapse>
|
||||||
{ required && <span style={{ color: "red" }}>*</span>}
|
{ required && <span style={{ color: "red" }}>*</span>}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -33,14 +33,72 @@ export default class OnlineValidatorBadge extends React.Component {
|
|||||||
|
|
||||||
if ( typeof spec === "object" && Object.keys(spec).length) return null
|
if ( typeof spec === "object" && Object.keys(spec).length) return null
|
||||||
|
|
||||||
if (!this.state.url || !this.state.validatorUrl) {
|
if (!this.state.url || !this.state.validatorUrl || this.state.url.indexOf("localhost") >= 0
|
||||||
|
|| this.state.url.indexOf("127.0.0.1") >= 0) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return (<span style={{ float: "right"}}>
|
return (<span style={{ float: "right"}}>
|
||||||
<a target="_blank" href={`${ this.state.validatorUrl }/debug?url=${ this.state.url }`}>
|
<a target="_blank" href={`${ this.state.validatorUrl }/debug?url=${ this.state.url }`}>
|
||||||
<img alt="Online validator badge" src={`${ this.state.validatorUrl }?url=${ this.state.url }`} />
|
<ValidatorImage src={`${ this.state.validatorUrl }?url=${ this.state.url }`} alt="Online validator badge"/>
|
||||||
</a>
|
</a>
|
||||||
</span>)
|
</span>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ValidatorImage extends React.Component {
|
||||||
|
static propTypes = {
|
||||||
|
src: PropTypes.string,
|
||||||
|
alt: PropTypes.string
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props)
|
||||||
|
this.state = {
|
||||||
|
loaded: false,
|
||||||
|
error: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
const img = new Image()
|
||||||
|
img.onload = () => {
|
||||||
|
this.setState({
|
||||||
|
loaded: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
img.onerror = () => {
|
||||||
|
this.setState({
|
||||||
|
error: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
img.src = this.props.src
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillReceiveProps(nextProps) {
|
||||||
|
if (nextProps.src !== this.props.src) {
|
||||||
|
const img = new Image()
|
||||||
|
img.onload = () => {
|
||||||
|
this.setState({
|
||||||
|
loaded: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
img.onerror = () => {
|
||||||
|
this.setState({
|
||||||
|
error: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
img.src = nextProps.src
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
if (this.state.error) {
|
||||||
|
return <img alt={"Error"} />
|
||||||
|
} else if (!this.state.loaded) {
|
||||||
|
return <img alt= {"Loading..."} />
|
||||||
|
}
|
||||||
|
return <img src={this.props.src} alt={this.props.alt} />
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,9 +5,17 @@ import { getSampleSchema } from "core/utils"
|
|||||||
const getExampleComponent = ( sampleResponse, examples, HighlightCode ) => {
|
const getExampleComponent = ( sampleResponse, examples, HighlightCode ) => {
|
||||||
if ( examples && examples.size ) {
|
if ( examples && examples.size ) {
|
||||||
return examples.entrySeq().map( ([ key, example ]) => {
|
return examples.entrySeq().map( ([ key, example ]) => {
|
||||||
|
let exampleValue
|
||||||
|
try {
|
||||||
|
exampleValue = example && example.toJS ? example.toJS() : example
|
||||||
|
exampleValue = JSON.stringify(exampleValue)
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
exampleValue = String(example)
|
||||||
|
}
|
||||||
return (<div key={ key }>
|
return (<div key={ key }>
|
||||||
<h5>{ key }</h5>
|
<h5>{ key }</h5>
|
||||||
<HighlightCode className="example" value={ example } />
|
<HighlightCode className="example" value={ exampleValue } />
|
||||||
</div>)
|
</div>)
|
||||||
}).toArray()
|
}).toArray()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ export default function curl( request ){
|
|||||||
let headers = request.get("headers")
|
let headers = request.get("headers")
|
||||||
curlified.push( "curl" )
|
curlified.push( "curl" )
|
||||||
curlified.push( "-X", request.get("method") )
|
curlified.push( "-X", request.get("method") )
|
||||||
curlified.push( request.get("url") )
|
curlified.push( `"${request.get("url")}"`)
|
||||||
|
|
||||||
if ( headers && headers.size ) {
|
if ( headers && headers.size ) {
|
||||||
for( let p of request.get("headers").entries() ){
|
for( let p of request.get("headers").entries() ){
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import win from "core/window"
|
import win from "core/window"
|
||||||
import btoa from "btoa"
|
import { btoa } from "core/utils"
|
||||||
|
|
||||||
export const SHOW_AUTH_POPUP = "show_popup"
|
export const SHOW_AUTH_POPUP = "show_popup"
|
||||||
export const AUTHORIZE = "authorize"
|
export const AUTHORIZE = "authorize"
|
||||||
@@ -8,6 +8,8 @@ export const PRE_AUTHORIZE_OAUTH2 = "pre_authorize_oauth2"
|
|||||||
export const AUTHORIZE_OAUTH2 = "authorize_oauth2"
|
export const AUTHORIZE_OAUTH2 = "authorize_oauth2"
|
||||||
export const VALIDATE = "validate"
|
export const VALIDATE = "validate"
|
||||||
|
|
||||||
|
const scopeSeparator = " "
|
||||||
|
|
||||||
export function showDefinitions(payload) {
|
export function showDefinitions(payload) {
|
||||||
return {
|
return {
|
||||||
type: SHOW_AUTH_POPUP,
|
type: SHOW_AUTH_POPUP,
|
||||||
@@ -77,7 +79,8 @@ export const authorizePassword = ( auth ) => ( { fn, authActions, errActions } )
|
|||||||
query: {
|
query: {
|
||||||
grant_type: "password",
|
grant_type: "password",
|
||||||
username,
|
username,
|
||||||
password
|
password,
|
||||||
|
scopes: encodeURIComponent(auth.scopes.join(scopeSeparator))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { fromJS, Map } from "immutable"
|
import { fromJS, Map } from "immutable"
|
||||||
import btoa from "btoa"
|
import { btoa } from "core/utils"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
SHOW_AUTH_POPUP,
|
SHOW_AUTH_POPUP,
|
||||||
|
|||||||
@@ -547,3 +547,15 @@ export const parseSeach = () => {
|
|||||||
|
|
||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const btoa = (str) => {
|
||||||
|
let buffer
|
||||||
|
|
||||||
|
if (str instanceof Buffer) {
|
||||||
|
buffer = str
|
||||||
|
} else {
|
||||||
|
buffer = new Buffer(str.toString(), "utf-8")
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer.toString("base64")
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ describe("curlify", function() {
|
|||||||
|
|
||||||
let curlified = curl(Im.fromJS(req))
|
let curlified = curl(Im.fromJS(req))
|
||||||
|
|
||||||
expect(curlified).toEqual("curl -X POST http://example.com -H \"Accept: application/json\" -H \"content-type: application/json\" -d {\"id\":0,\"name\":\"doggie\",\"status\":\"available\"}")
|
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"Accept: application/json\" -H \"content-type: application/json\" -d {\"id\":0,\"name\":\"doggie\",\"status\":\"available\"}")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("does not change the case of header in curl", function() {
|
it("does not change the case of header in curl", function() {
|
||||||
@@ -35,7 +35,7 @@ describe("curlify", function() {
|
|||||||
|
|
||||||
let curlified = curl(Im.fromJS(req))
|
let curlified = curl(Im.fromJS(req))
|
||||||
|
|
||||||
expect(curlified).toEqual("curl -X POST http://example.com -H \"conTenT Type: application/Moar\"")
|
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"conTenT Type: application/Moar\"")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("prints a curl statement with an array of query params", function() {
|
it("prints a curl statement with an array of query params", function() {
|
||||||
@@ -46,7 +46,7 @@ describe("curlify", function() {
|
|||||||
|
|
||||||
let curlified = curl(Im.fromJS(req))
|
let curlified = curl(Im.fromJS(req))
|
||||||
|
|
||||||
expect(curlified).toEqual("curl -X GET http://swaggerhub.com/v1/one?name=john|smith")
|
expect(curlified).toEqual("curl -X GET \"http://swaggerhub.com/v1/one?name=john|smith\"")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("prints a curl statement with an array of query params and auth", function() {
|
it("prints a curl statement with an array of query params and auth", function() {
|
||||||
@@ -60,7 +60,7 @@ describe("curlify", function() {
|
|||||||
|
|
||||||
let curlified = curl(Im.fromJS(req))
|
let curlified = curl(Im.fromJS(req))
|
||||||
|
|
||||||
expect(curlified).toEqual("curl -X GET http://swaggerhub.com/v1/one?name=john|smith -H \"authorization: Basic Zm9vOmJhcg==\"")
|
expect(curlified).toEqual("curl -X GET \"http://swaggerhub.com/v1/one?name=john|smith\" -H \"authorization: Basic Zm9vOmJhcg==\"")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("prints a curl statement with html", function() {
|
it("prints a curl statement with html", function() {
|
||||||
@@ -77,7 +77,7 @@ describe("curlify", function() {
|
|||||||
|
|
||||||
let curlified = curl(Im.fromJS(req))
|
let curlified = curl(Im.fromJS(req))
|
||||||
|
|
||||||
expect(curlified).toEqual("curl -X GET http://swaggerhub.com/v1/one?name=john|smith -H \"accept: application/json\" -d {\"description\":\"<b>Test</b>\"}")
|
expect(curlified).toEqual("curl -X GET \"http://swaggerhub.com/v1/one?name=john|smith\" -H \"accept: application/json\" -d {\"description\":\"<b>Test</b>\"}")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("handles post body with html", function() {
|
it("handles post body with html", function() {
|
||||||
@@ -94,7 +94,7 @@ describe("curlify", function() {
|
|||||||
|
|
||||||
let curlified = curl(Im.fromJS(req))
|
let curlified = curl(Im.fromJS(req))
|
||||||
|
|
||||||
expect(curlified).toEqual("curl -X POST http://swaggerhub.com/v1/one?name=john|smith -H \"accept: application/json\" -d {\"description\":\"<b>Test</b>\"}")
|
expect(curlified).toEqual("curl -X POST \"http://swaggerhub.com/v1/one?name=john|smith\" -H \"accept: application/json\" -d {\"description\":\"<b>Test</b>\"}")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("handles post body with special chars", function() {
|
it("handles post body with special chars", function() {
|
||||||
@@ -109,7 +109,7 @@ describe("curlify", function() {
|
|||||||
|
|
||||||
let curlified = curl(Im.fromJS(req))
|
let curlified = curl(Im.fromJS(req))
|
||||||
|
|
||||||
expect(curlified).toEqual("curl -X POST http://swaggerhub.com/v1/one?name=john|smith -d {\"description\":\"@prefix nif:<http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#> .\"}")
|
expect(curlified).toEqual("curl -X POST \"http://swaggerhub.com/v1/one?name=john|smith\" -d {\"description\":\"@prefix nif:<http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#> .\"}")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("handles delete form with parameters", function() {
|
it("handles delete form with parameters", function() {
|
||||||
@@ -123,7 +123,7 @@ describe("curlify", function() {
|
|||||||
|
|
||||||
let curlified = curl(Im.fromJS(req))
|
let curlified = curl(Im.fromJS(req))
|
||||||
|
|
||||||
expect(curlified).toEqual("curl -X DELETE http://example.com -H \"accept: application/x-www-form-urlencoded\"")
|
expect(curlified).toEqual("curl -X DELETE \"http://example.com\" -H \"accept: application/x-www-form-urlencoded\"")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should print a curl with formData", function() {
|
it("should print a curl with formData", function() {
|
||||||
@@ -136,7 +136,7 @@ describe("curlify", function() {
|
|||||||
|
|
||||||
let curlified = curl(Im.fromJS(req))
|
let curlified = curl(Im.fromJS(req))
|
||||||
|
|
||||||
expect(curlified).toEqual("curl -X POST http://example.com -H \"content-type: multipart/form-data\" -F id=123 -F name=Sahar")
|
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"content-type: multipart/form-data\" -F id=123 -F name=Sahar")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("prints a curl post statement from an object", function() {
|
it("prints a curl post statement from an object", function() {
|
||||||
@@ -153,7 +153,7 @@ describe("curlify", function() {
|
|||||||
|
|
||||||
let curlified = curl(Im.fromJS(req))
|
let curlified = curl(Im.fromJS(req))
|
||||||
|
|
||||||
expect(curlified).toEqual("curl -X POST http://example.com -H \"accept: application/json\" -d {\"id\":10101}")
|
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"accept: application/json\" -d {\"id\":10101}")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("prints a curl post statement from a string containing a single quote", function() {
|
it("prints a curl post statement from a string containing a single quote", function() {
|
||||||
@@ -168,7 +168,7 @@ describe("curlify", function() {
|
|||||||
|
|
||||||
let curlified = curl(Im.fromJS(req))
|
let curlified = curl(Im.fromJS(req))
|
||||||
|
|
||||||
expect(curlified).toEqual("curl -X POST http://example.com -H \"accept: application/json\" -d \"{\\\"id\\\":\\\"foo'bar\\\"}\"")
|
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"accept: application/json\" -d \"{\\\"id\\\":\\\"foo'bar\\\"}\"")
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ module.exports = require("./make-webpack-config")({
|
|||||||
},
|
},
|
||||||
devtool: "eval",
|
devtool: "eval",
|
||||||
entry: {
|
entry: {
|
||||||
'SwaggerUIBundle': [
|
'swagger-ui-bundle': [
|
||||||
'babel-polyfill',
|
'babel-polyfill',
|
||||||
'./src/core/index.js'
|
'./src/core/index.js'
|
||||||
],
|
],
|
||||||
'SwaggerUIStandalonePreset': [
|
'swagger-ui-standalone-preset': [
|
||||||
'./src/standalone/index.js'
|
'./src/standalone/index.js'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -27,8 +27,8 @@ module.exports = require("./make-webpack-config")({
|
|||||||
},
|
},
|
||||||
devServer: {
|
devServer: {
|
||||||
port: 3200,
|
port: 3200,
|
||||||
path: path.join(__dirname, 'dist'),
|
path: path.join(__dirname, 'dev-helpers'),
|
||||||
publicPath: "/dist",
|
publicPath: "/",
|
||||||
noInfo: true,
|
noInfo: true,
|
||||||
colors: true,
|
colors: true,
|
||||||
hot: true,
|
hot: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user