Merge branch 'master' into patch-1
This commit is contained in:
31
README.md
31
README.md
@@ -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
|
||||||
|
|
||||||
|
|||||||
40
composer.json
Normal file
40
composer.json
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"name": "swagger-api/swagger-ui",
|
||||||
|
"description": " Swagger UI is a collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.",
|
||||||
|
"keywords": [
|
||||||
|
"Swagger",
|
||||||
|
"OpenAPI",
|
||||||
|
"specification",
|
||||||
|
"documentation",
|
||||||
|
"API",
|
||||||
|
"UI"
|
||||||
|
],
|
||||||
|
"homepage": "http://swagger.io",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Anna Bodnia",
|
||||||
|
"email": "anna.bodnia@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Buu Nguyen",
|
||||||
|
"email": "buunguyen@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Josh Ponelat",
|
||||||
|
"email": "jponelat@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Kyle Shockey",
|
||||||
|
"email": "kyleshockey1@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Robert Barnwell",
|
||||||
|
"email": "robert@robertismy.name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Sahar Jafari",
|
||||||
|
"email": "shr.jafari@gmail.com"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
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;AAonGA;AAukEA;AA02DA;AAyxDA;AAm+BA;;;;;;AAmsEA;AA2zFA;;;;;AA+1CA;AA2qFA;AAo2CA;AAokCA;AAkhDA;AAwvEA;AAs+FA;;;;;;;;;AA+xBA;AA2zIA;AAg4DA;AA0vDA","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;AA+7FA;AA2mCA;AAw/BA;AA2hCA;AAs5BA","sourceRoot":""}
|
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAmwCA;AAoyHA;AA2wHA;AA07FA;AAmnCA;AAu/BA;AAmiCA;AA44BA","sourceRoot":""}
|
||||||
@@ -37,7 +37,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-polyfill": "^6.23.0",
|
"babel-polyfill": "^6.23.0",
|
||||||
"brace": "0.7.0",
|
"brace": "0.7.0",
|
||||||
"btoa": "^1.1.2",
|
|
||||||
"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",
|
||||||
|
|||||||
@@ -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,6 +168,7 @@ 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 className="model">
|
return <span className="model">
|
||||||
<span className="model-title">
|
<span className="model-title">
|
||||||
@@ -176,6 +178,13 @@ class ArrayModel extends Component {
|
|||||||
[
|
[
|
||||||
<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>
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
@@ -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\\\"}\"")
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user