Merge branch 'master' of github.com:swagger-api/swagger-ui into ft/oas3
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,3 +4,4 @@ node_modules
|
||||
.DS_Store
|
||||
npm-debug.log*
|
||||
.eslintcache
|
||||
package-lock.json
|
||||
|
||||
@@ -20,7 +20,7 @@ The OpenAPI Specification has undergone 4 revisions since initial creation in 20
|
||||
|
||||
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes | Status
|
||||
------------------ | ------------ | -------------------------- | ----- | ------
|
||||
3.0.13 | 2017-06-02 | 2.0 | [tag v3.0.13](https://github.com/swagger-api/swagger-ui/tree/v3.0.13) |
|
||||
3.0.14 | 2017-06-09 | 2.0 | [tag v3.0.14](https://github.com/swagger-api/swagger-ui/tree/v3.0.14) |
|
||||
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.0.24 | 2014-09-12 | 1.1, 1.2 | [tag v2.0.24](https://github.com/swagger-api/swagger-ui/tree/v2.0.24) |
|
||||
@@ -40,6 +40,12 @@ docker run -p 80:8080 swaggerapi/swagger-ui
|
||||
|
||||
Will start nginx with swagger-ui on port 80.
|
||||
|
||||
Or you can provide your own swagger.json on your host
|
||||
|
||||
```
|
||||
docker run -p 80:8080 -e "SWAGGER_JSON=/foo/swagger.json" -v /bar:/foo swaggerapi/swagger-ui
|
||||
```
|
||||
|
||||
##### Prerequisites
|
||||
- Node 6.x
|
||||
- NPM 3.x
|
||||
|
||||
63
dist/swagger-ui-bundle.js
vendored
63
dist/swagger-ui-bundle.js
vendored
File diff suppressed because one or more lines are too long
6
dist/swagger-ui-bundle.js.map
vendored
6
dist/swagger-ui-bundle.js.map
vendored
@@ -1 +1,5 @@
|
||||
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AA2TA;;;;;;AAoIA;AAizFA;AAqjCA;AA0nJA;AA67IA;AA0zGA;AA2xFA;AA6iFA;AAqtFA;AAu+CA;AAs/CA;AA6rCA;AAu2EA;;;;;AAoqCA;AAsyJA;;;;;;;;;;;;;;AA64EA;AA4mIA;AAquJA;AA2qHA;AA2mGA;AAiiEA;AAq4DA;AAg3DA;AAoPA;;;;;;AAk7FA;AA07FA;;;;;AAi8CA;AAgsFA;AAs2CA;AAglCA;AAg8CA;AAg/EA;AAq8BA;AAq3FA;;;;;;;;;AA6mDA;AA2zIA;AAu7FA;AAmrFA;AA6lEA;AA6kEA;AAqBA;AA8DA;;;;;;AA4xFA;AA4qFA","sourceRoot":""}
|
||||
<<<<<<< HEAD
|
||||
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AA2TA;;;;;;AAoIA;AAizFA;AAqjCA;AA0nJA;AA67IA;AA0zGA;AA2xFA;AA6iFA;AAqtFA;AAu+CA;AAs/CA;AA6rCA;AAu2EA;;;;;AAoqCA;AAsyJA;;;;;;;;;;;;;;AA64EA;AA4mIA;AAquJA;AA2qHA;AA2mGA;AAiiEA;AAq4DA;AAg3DA;AAoPA;;;;;;AAk7FA;AA07FA;;;;;AAi8CA;AAgsFA;AAs2CA;AAglCA;AAg8CA;AAg/EA;AAq8BA;AAq3FA;;;;;;;;;AA6mDA;AA2zIA;AAu7FA;AAmrFA;AA6lEA;AA6kEA;AAqBA;AA8DA;;;;;;AA4xFA;AA4qFA","sourceRoot":""}
|
||||
=======
|
||||
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AA2TA;;;;;;AAoIA;AAi7FA;AAmtCA;AAi0IA;AA0oJA;AAgiGA;AA0/FA;AAqkFA;AAqjFA;AAk9CA;AA+jDA;AAwrCA;AA0gFA;;;;;AA+zBA;AAsyJA;;;;;;;;;;;;;;AA64EA;AA4mIA;AAquJA;AA2qHA;AA2mGA;AAiiEA;AAq4DA;AAg3DA;AA8NA;;;;;;AAw8FA;AA07FA;;;;;AAi8CA;AAgsFA;AAs2CA;AA+kCA;AAg8CA;AAg/EA;AAu/BA;AAk0FA;;;;;;;;;AAomDA;AA2zIA;AAu7FA;AAmrFA;AA20EA","sourceRoot":""}
|
||||
>>>>>>> 00745bca386547039c0ea083fbc101db589752e6
|
||||
|
||||
19
dist/swagger-ui-standalone-preset.js
vendored
19
dist/swagger-ui-standalone-preset.js
vendored
File diff suppressed because one or more lines are too long
4
dist/swagger-ui.css
vendored
4
dist/swagger-ui.css
vendored
File diff suppressed because one or more lines are too long
4
dist/swagger-ui.js
vendored
4
dist/swagger-ui.js
vendored
File diff suppressed because one or more lines are too long
@@ -2,7 +2,8 @@
|
||||
|
||||
set -e
|
||||
|
||||
INDEX_FILE=/usr/share/nginx/html/index.html
|
||||
NGINX_ROOT=/usr/share/nginx/html
|
||||
INDEX_FILE=$NGINX_ROOT/index.html
|
||||
|
||||
replace_in_index () {
|
||||
if [ "$1" != "**None**" ]; then
|
||||
@@ -30,8 +31,10 @@ if [ "$OAUTH_ADDITIONAL_PARAMS" != "**None**" ]; then
|
||||
fi
|
||||
|
||||
if [[ -f $SWAGGER_JSON ]]; then
|
||||
sed -i "s|http://petstore.swagger.io/v2/swagger.json|swagger.json|g" $INDEX_FILE
|
||||
sed -i "s|http://example.com/api|swagger.json|g" $INDEX_FILE
|
||||
cp $SWAGGER_JSON $NGINX_ROOT
|
||||
REL_PATH="/$(basename $SWAGGER_JSON)"
|
||||
sed -i "s|http://petstore.swagger.io/v2/swagger.json|$REL_PATH|g" $INDEX_FILE
|
||||
sed -i "s|http://example.com/api|$REL_PATH|g" $INDEX_FILE
|
||||
else
|
||||
sed -i "s|http://petstore.swagger.io/v2/swagger.json|$API_URL|g" $INDEX_FILE
|
||||
sed -i "s|http://example.com/api|$API_URL|g" $INDEX_FILE
|
||||
|
||||
7071
package-lock.json
generated
7071
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "swagger-ui",
|
||||
"version": "3.0.13",
|
||||
"version": "3.0.14",
|
||||
"main": "dist/swagger-ui.js",
|
||||
"repository": "git@github.com:swagger-api/swagger-ui.git",
|
||||
"contributors": [
|
||||
@@ -32,7 +32,7 @@
|
||||
"test": "npm run lint-errors && npm run just-test-in-node",
|
||||
"test-in-node": "npm run lint-errors && npm run just-test-in-node",
|
||||
"just-test": "karma start --config karma.conf.js",
|
||||
"just-test-in-node": "mocha --recursive --compilers js:babel-core/register test/core test/components test/bugs"
|
||||
"just-test-in-node": "mocha --recursive --compilers js:babel-core/register test/core test/components test/bugs test/swagger-ui-dist-package"
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-polyfill": "^6.23.0",
|
||||
@@ -71,7 +71,7 @@
|
||||
"sanitize-html": "^1.14.1",
|
||||
"serialize-error": "2.0.0",
|
||||
"shallowequal": "0.2.2",
|
||||
"swagger-client": "~3.0.13",
|
||||
"swagger-client": "~3.0.14",
|
||||
"url-parse": "^1.1.8",
|
||||
"whatwg-fetch": "0.11.1",
|
||||
"worker-loader": "^0.7.1",
|
||||
|
||||
@@ -19,7 +19,7 @@ export default class Curl extends React.Component {
|
||||
<div>
|
||||
<h4>Curl</h4>
|
||||
<div className="copy-paste">
|
||||
<textarea onFocus={this.handleFocus} className="curl" style={{ whiteSpace: "normal" }} value={curl}></textarea>
|
||||
<textarea onFocus={this.handleFocus} readOnly="true" className="curl" style={{ whiteSpace: "normal" }} value={curl}></textarea>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -22,13 +22,14 @@ export default class LiveResponse extends React.Component {
|
||||
render() {
|
||||
const { request, response, getComponent } = this.props
|
||||
|
||||
const body = response.get("text")
|
||||
const status = response.get("status")
|
||||
const url = response.get("url")
|
||||
const headers = response.get("headers").toJS()
|
||||
const notDocumented = response.get("notDocumented")
|
||||
const isError = response.get("error")
|
||||
|
||||
const body = isError ? response.get("response").get("text") : response.get("text")
|
||||
|
||||
const headersKeys = Object.keys(headers)
|
||||
const contentType = headers["content-type"]
|
||||
|
||||
@@ -37,6 +38,7 @@ export default class LiveResponse extends React.Component {
|
||||
const returnObject = headersKeys.map(key => {
|
||||
return <span className="headerline" key={key}> {key}: {headers[key]} </span>
|
||||
})
|
||||
const hasHeaders = returnObject.length !== 0
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -54,28 +56,29 @@ export default class LiveResponse extends React.Component {
|
||||
<td className="col response-col_status">
|
||||
{ status }
|
||||
{
|
||||
!notDocumented ? null :
|
||||
<div className="response-undocumented">
|
||||
<i> Undocumented </i>
|
||||
</div>
|
||||
notDocumented ? <div className="response-undocumented">
|
||||
<i> Undocumented </i>
|
||||
</div>
|
||||
: null
|
||||
}
|
||||
</td>
|
||||
<td className="col response-col_description">
|
||||
{
|
||||
!isError ? null : <span>
|
||||
{`${response.get("name")}: ${response.get("message")}`}
|
||||
</span>
|
||||
isError ? <span>
|
||||
{`${response.get("name")}: ${response.get("message")}`}
|
||||
</span>
|
||||
: null
|
||||
}
|
||||
{
|
||||
!body || isError ? null
|
||||
: <ResponseBody content={ body }
|
||||
contentType={ contentType }
|
||||
url={ url }
|
||||
headers={ headers }
|
||||
getComponent={ getComponent }/>
|
||||
body ? <ResponseBody content={ body }
|
||||
contentType={ contentType }
|
||||
url={ url }
|
||||
headers={ headers }
|
||||
getComponent={ getComponent }/>
|
||||
: null
|
||||
}
|
||||
{
|
||||
!headers ? null : <Headers headers={ returnObject }/>
|
||||
hasHeaders ? <Headers headers={ returnObject }/> : null
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -8,7 +8,7 @@ const getExampleComponent = ( sampleResponse, examples, HighlightCode ) => {
|
||||
let exampleValue
|
||||
try {
|
||||
exampleValue = example && example.toJS ? example.toJS() : example
|
||||
exampleValue = JSON.stringify(exampleValue)
|
||||
exampleValue = JSON.stringify(exampleValue, null, 2)
|
||||
}
|
||||
catch(e) {
|
||||
exampleValue = String(example)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import win from "./window"
|
||||
|
||||
export default function curl( request ){
|
||||
let curlified = []
|
||||
let type = ""
|
||||
@@ -18,11 +20,13 @@ export default function curl( request ){
|
||||
if ( request.get("body") ){
|
||||
|
||||
if(type === "multipart/form-data" && request.get("method") === "POST") {
|
||||
let formDataBody = request.get("body").split("&")
|
||||
|
||||
for(var data in formDataBody) {
|
||||
for( let [ k,v ] of request.get("body").values()) {
|
||||
curlified.push( "-F" )
|
||||
curlified.push(formDataBody[data])
|
||||
if (v instanceof win.File) {
|
||||
curlified.push( `"${k}=@${v.name};type=${v.type}"` )
|
||||
} else {
|
||||
curlified.push( `"${k}=${v}"` )
|
||||
}
|
||||
}
|
||||
} else {
|
||||
curlified.push( "-d" )
|
||||
|
||||
@@ -7,6 +7,7 @@ import _memoize from "lodash/memoize"
|
||||
import some from "lodash/some"
|
||||
import eq from "lodash/eq"
|
||||
import { memoizedSampleFromSchema, memoizedCreateXMLExample } from "core/plugins/samples/fn"
|
||||
import win from "./window"
|
||||
|
||||
const DEFAULT_REPONSE_KEY = "default"
|
||||
|
||||
@@ -34,6 +35,9 @@ export function fromJSOrdered (js) {
|
||||
if(isImmutable(js))
|
||||
return js // Can't do much here
|
||||
|
||||
if (js instanceof win.File)
|
||||
return js
|
||||
|
||||
return !isObject(js) ? js :
|
||||
Array.isArray(js) ?
|
||||
Im.Seq(js).map(fromJSOrdered).toList() :
|
||||
|
||||
@@ -3,7 +3,8 @@ function makeWindow() {
|
||||
location: {},
|
||||
history: {},
|
||||
open: () => {},
|
||||
close: () => {}
|
||||
close: () => {},
|
||||
File: function() {}
|
||||
}
|
||||
|
||||
if(typeof window === "undefined") {
|
||||
|
||||
@@ -1,8 +1,22 @@
|
||||
This module, `swagger-ui-dist`, exposes Swagger-UI's entire dist folder as a dependency-free npm module. Use `swagger-ui` instead, if you'd like to have npm install dependencies for you.
|
||||
# Swagger UI Dist
|
||||
[](http://badge.fury.io/js/swagger-ui-dist)
|
||||
|
||||
# API
|
||||
|
||||
This module, `swagger-ui-dist`, exposes Swagger-UI's entire dist folder as a dependency-free npm module.
|
||||
Use `swagger-ui` instead, if you'd like to have npm install dependencies for you.
|
||||
|
||||
`SwaggerUIBundle` and `SwaggerUIStandalonePreset` can be imported:
|
||||
```javascript
|
||||
import { SwaggerUIBundle, SwaggerUIStandalonePreset } from 'swagger-ui-dist'
|
||||
import { SwaggerUIBundle, SwaggerUIStandalonePreset } from "swagger-ui-dist"
|
||||
```
|
||||
|
||||
To get an absolute path to this directory for static file serving, use the exported `getAbsoluteFSPath` method:
|
||||
|
||||
```javascript
|
||||
const swaggerUiAssetPath = require("swagger-ui-dist").getAbsoluteFSPath()
|
||||
|
||||
// then instantiate server that serves files from the swaggerUiAssetPath
|
||||
```
|
||||
|
||||
For anything else, check the [Swagger-UI](https://github.com/swagger-api/swagger-ui) repository.
|
||||
|
||||
14
swagger-ui-dist-package/absolute-path.js
Normal file
14
swagger-ui-dist-package/absolute-path.js
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* getAbsoluteFSPath
|
||||
* @return {string} When run in NodeJS env, returns the absolute path to the current directory
|
||||
* When run outside of NodeJS, will return an error message
|
||||
*/
|
||||
const getAbsoluteFSPath = () => {
|
||||
// detect whether we are running in a browser or nodejs
|
||||
if (typeof module !== "undefined" && module.exports) {
|
||||
return require("path").resolve(__dirname)
|
||||
}
|
||||
throw new Error('getAbsoluteFSPath can only be called within a Nodejs environment');
|
||||
}
|
||||
|
||||
module.exports = getAbsoluteFSPath
|
||||
@@ -1,2 +1,4 @@
|
||||
module.exports.SwaggerUIBundle = require('./swagger-ui-bundle.js')
|
||||
module.exports.SwaggerUIStandalonePreset = require('./swagger-ui-standalone-preset.js')
|
||||
module.exports.SwaggerUIBundle = require("./swagger-ui-bundle.js")
|
||||
module.exports.SwaggerUIStandalonePreset = require("./swagger-ui-standalone-preset.js")
|
||||
module.exports.absolutePath = require("./.absolute-path.js")
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import expect from "expect"
|
||||
import Im from "immutable"
|
||||
import curl from "core/curlify"
|
||||
import win from "core/window"
|
||||
|
||||
describe("curlify", function() {
|
||||
|
||||
@@ -131,12 +132,35 @@ describe("curlify", function() {
|
||||
url: "http://example.com",
|
||||
method: "POST",
|
||||
headers: { "content-type": "multipart/form-data" },
|
||||
body: "id=123&name=Sahar"
|
||||
body: [
|
||||
["id", "123"],
|
||||
["name", "Sahar"]
|
||||
]
|
||||
}
|
||||
|
||||
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("should print a curl with formData and file", function() {
|
||||
var file = new win.File()
|
||||
file.name = "file.txt"
|
||||
file.type = "text/plain"
|
||||
|
||||
var req = {
|
||||
url: "http://example.com",
|
||||
method: "POST",
|
||||
headers: { "content-type": "multipart/form-data" },
|
||||
body: [
|
||||
["id", "123"],
|
||||
["file", file]
|
||||
]
|
||||
}
|
||||
|
||||
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 \"file=@file.txt;type=text/plain\"")
|
||||
})
|
||||
|
||||
it("prints a curl post statement from an object", function() {
|
||||
|
||||
13
test/swagger-ui-dist-package/absolute-path.js
Normal file
13
test/swagger-ui-dist-package/absolute-path.js
Normal file
@@ -0,0 +1,13 @@
|
||||
/* eslint-env mocha */
|
||||
import expect from "expect"
|
||||
import path from "path"
|
||||
import getAbsoluteFSPath from "../../swagger-ui-dist-package/absolute-path"
|
||||
|
||||
describe("swagger-ui-dist", function(){
|
||||
describe("getAbsoluteFSPath", function(){
|
||||
it("returns absolute path", function(){
|
||||
const expectedPath = path.resolve(__dirname, "../../swagger-ui-dist-package")
|
||||
expect(getAbsoluteFSPath()).toEqual(expectedPath)
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user