Compare commits

...
32 Commits
Author SHA1 Message Date
shockey ebe9f9b7f4 Merge pull request #3252 from shockey/v/3.0.15
v/3.0.15
2017-06-16 19:26:29 -07:00
shockey 344f28bf22 Fix README typo
nano is questionable.
2017-06-16 19:23:44 -07:00
Kyle Shockey 556ff037dc Rebuild dist 2017-06-16 19:20:08 -07:00
Kyle Shockey 754a93c14e Version bump 2017-06-16 19:10:15 -07:00
shockey eccc26da1b Merge pull request #3236 from mhw/fix-model-markdown
Render Markdown for object and property descriptions
2017-06-16 17:09:31 -07:00
shockey 99600df0f1 Merge branch 'master' into fix-model-markdown 2017-06-16 13:52:32 -07:00
shockey 1cab4984e0 Merge pull request #3250 from GSokol/#2946_FIX
#2946 Fix
2017-06-16 13:02:05 -07:00
sokol acff34e1d4 #2946 Fix CR fix 2017-06-16 21:14:00 +03:00
sokol 129129be97 #2946 Fix 2017-06-16 18:16:46 +03:00
shockey 00745bca38 Merge pull request #3211 from dwickern/multipart-file-upload
Fix #2922: file uploads fail to render curl command
2017-06-13 16:15:45 -07:00
shockey 1bd1190749 Merge branch 'master' into multipart-file-upload 2017-06-13 16:08:19 -07:00
shockey 667976ca67 Merge pull request #3238 from mhw/fix-response-json-indentation
Indent JSON examples.
2017-06-13 15:57:47 -07:00
Ron 0345f66ee2 Merge branch 'master' into fix-response-json-indentation 2017-06-13 15:45:16 -07:00
Mark H. Wilkinson 7d24a95d78 Indent JSON examples. 2017-06-13 23:07:44 +01:00
shockey ce16666b57 Merge branch 'master' into fix-model-markdown 2017-06-13 12:09:58 -07:00
shockey 3cfda13cfe Merge pull request #3076 from furkanayhan/show_actual_error_response
Show actual error response when trying
2017-06-13 11:34:02 -07:00
shockey a54d6fa2bc Merge branch 'master' into show_actual_error_response 2017-06-13 10:36:41 -07:00
Mark H. Wilkinson c24a07c523 Render primitive property descriptions as Markdown. 2017-06-13 17:15:59 +01:00
Mark H. Wilkinson db57ee0dfe Render object descriptions as Markdown. 2017-06-13 17:13:33 +01:00
shockey 99a525eac2 Merge pull request #3218 from dylancwood/chore-dist-dir
Add absolutePath to swagger-ui-dist exports
2017-06-12 23:18:37 -07:00
shockey 3e71861712 Merge branch 'master' into chore-dist-dir 2017-06-12 23:15:21 -07:00
shockey 5f8ffb870c Add function invocation to method example 2017-06-12 23:14:00 -07:00
Dylan 3311f3e95f export getAbsoluteFSPath method instead of property 2017-06-12 22:21:47 -07:00
shockey b5b00953e9 Merge pull request #3230 from shockey/rebuild
Rebuild dist
2017-06-12 15:25:42 -07:00
Kyle Shockey 873cb2892f Rebuild dist 2017-06-12 15:21:17 -07:00
Dylan df149c543b make dist absolutePath browser-safe, add test 2017-06-10 15:59:21 -07:00
Dylan d6d5b1d06e add documentation of absolutePath as well as npm version badge 2017-06-10 15:59:21 -07:00
Dylan 234e6d5d57 add absolutePath to swagger-ui-dist 2017-06-10 15:59:21 -07:00
shockey 212396f24d Merge pull request #3223 from swagger-api/readme-patch
Fix README.md
2017-06-09 22:14:17 -07:00
shockey f4a253461e Create README.md 2017-06-09 21:49:45 -07:00
Furkan Ayhan b3e476f476 Show actual error response when trying 2017-06-09 10:25:28 +03:00
Derek Wickern c5a23e584c Fix #2922: file uploads fail to render curl command
The request body is an immutable.js OrderedMap rather than a string,
so this fixes the type error:

  TypeError: request.get(...).split is not a function

Adds a special curl command argument for files, e.g.

  curl -F "param=value" -F "file=@filename.txt;type=text/plain"
2017-06-08 15:59:41 -07:00
20 changed files with 182 additions and 94 deletions
+1 -2
View File
@@ -20,8 +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.14 | 2017-06-09 | 2.0 | [tag
v3.0.14](https://github.com/swagger-api/swagger-ui/tree/v3.0.14) |
3.0.15 | 2017-06-16 | 2.0 | [tag v3.0.15](https://github.com/swagger-api/swagger-ui/tree/v3.0.15) |
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 -40
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"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":""}
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AA2TA;;;;;;AAoIA;AAi7FA;AAmtCA;AAi0IA;AAioJA;AA2iGA;AAs+FA;AA4kFA;AA6jFA;AAm9CA;AA6jDA;AAgrCA;AA+/EA;;;;;AAu3BA;AA0qJA;;;;;;;;;;;;;;AAwoFA;AA+lIA;AA2hJA;AAo2HA;AA8lGA;AAwiEA;AAo4DA;AAk7DA;AAyHA;;;;;;AA6iGA;AA07FA;;;;;AAi8CA;AAgsFA;AAs2CA;AAilCA;AA+7CA;AA85DA;AA4zCA;AAs5FA;;;;;;;;;AAqlCA;AA2zIA;AAu7FA;AAmrFA;AA20EA","sourceRoot":""}
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"swagger-ui-standalone-preset.js","sources":["webpack:///swagger-ui-standalone-preset.js"],"mappings":"AAAA;;;;;AA8QA;AAmvGA;AAuxFA;;;;;;AAocA;AAkvFA;AAu+CA;AAo+CA;AAgrCA;AAuyEA","sourceRoot":""}
{"version":3,"file":"swagger-ui-standalone-preset.js","sources":["webpack:///swagger-ui-standalone-preset.js"],"mappings":"AAAA;;;;;AA0SA;AAgyGA;AAuxFA;;;;;;AAocA;AAkvFA;AAu+CA;AAo+CA;AAgrCA;AAuyEA","sourceRoot":""}
+5 -5
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AA4yCA;AAoyHA;AAmyHA;AAukGA;AA+9BA;AA2jCA;AA0iCA;AAy4BA","sourceRoot":""}
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAizCA;AAoyHA;AAmyHA;AAukGA;AA+9BA;AA8jCA;AAyiCA;AAs5BA","sourceRoot":""}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "swagger-ui",
"version": "3.0.14",
"version": "3.0.15",
"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",
@@ -70,7 +70,7 @@
"sanitize-html": "^1.14.1",
"serialize-error": "2.0.0",
"shallowequal": "0.2.2",
"swagger-client": "~3.0.14",
"swagger-client": "~3.0.15",
"url-parse": "^1.1.8",
"whatwg-fetch": "0.11.1",
"worker-loader": "^0.7.1",
+1 -1
View File
@@ -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>
)
+18 -15
View File
@@ -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>
+17 -7
View File
@@ -40,6 +40,7 @@ class ObjectModel extends Component {
let additionalProperties = schema.get("additionalProperties")
let title = schema.get("title") || name
let required = schema.get("required")
const Markdown = getComponent("Markdown")
const JumpToPathSection = ({ name }) => <span className="model-jump-to-path"><JumpToPath path={`definitions.${name}`} /></span>
let collapsedContent = (<span>
<span>{ braceOpen }</span>...<span>{ braceClose }</span>
@@ -66,7 +67,9 @@ class ObjectModel extends Component {
{
!description ? null : <tr style={{ color: "#999", fontStyle: "italic" }}>
<td>description:</td>
<td>{ description }</td>
<td>
<Markdown source={ description } />
</td>
</tr>
}
{
@@ -114,11 +117,12 @@ class ObjectModel extends Component {
class Primitive extends Component {
static propTypes = {
schema: PropTypes.object.isRequired,
getComponent: PropTypes.func.isRequired,
required: PropTypes.bool
}
render(){
let { schema, required } = this.props
let { schema, getComponent, required } = this.props
if(!schema || !schema.get) {
// don't render if schema isn't correctly formed
@@ -129,17 +133,23 @@ class Primitive extends Component {
let format = schema.get("format")
let xml = schema.get("xml")
let enumArray = schema.get("enum")
let properties = schema.filter( ( v, key) => ["enum", "type", "format", "$$ref"].indexOf(key) === -1 )
let description = schema.get("description")
let properties = schema.filter( ( v, key) => ["enum", "type", "format", "description", "$$ref"].indexOf(key) === -1 )
let style = required ? { fontWeight: "bold" } : {}
const Markdown = getComponent("Markdown")
return <span className="prop">
<span className="prop-type" style={ style }>{ type }</span> { required && <span style={{ color: "red" }}>*</span>}
{ format && <span className="prop-format">(${format})</span>}
{
properties.size ? properties.entrySeq().map( ( [ key, v ] ) => <span key={`${key}-${v}`} style={ propStyle }>
<br />{ key !== "description" && key + ": " }{ String(v) }</span>)
<br />{ key }: { String(v) }</span>)
: null
}
{
!description ? null :
<Markdown source={ description } />
}
{
xml && xml.size ? (<span><br /><span style={ propStyle }>xml:</span>
{
@@ -217,7 +227,7 @@ class Model extends Component {
}
render () {
let { schema, required, name, isRef } = this.props
let { schema, getComponent, required, name, isRef } = this.props
let $$ref = schema && schema.get("$$ref")
let modelName = $$ref && this.getModelName( $$ref )
let modelSchema, type
@@ -236,7 +246,7 @@ class Model extends Component {
switch(type) {
case "object":
return <ObjectModel className="object" { ...this.props } schema={ modelSchema }
name={ modelName || name }
name={ name || modelName }
isRef={ isRef!== undefined ? isRef : !!$$ref }/>
case "array":
return <ArrayModel className="array" { ...this.props } schema={ modelSchema } required={ required } />
@@ -245,7 +255,7 @@ class Model extends Component {
case "integer":
case "boolean":
default:
return <Primitive schema={ modelSchema } required={ required }/>
return <Primitive getComponent={ getComponent } schema={ modelSchema } required={ required }/>
}
}
}
+1 -1
View File
@@ -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)
+8 -4
View File
@@ -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" )
+4
View File
@@ -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() :
+2 -1
View File
@@ -3,7 +3,8 @@ function makeWindow() {
location: {},
history: {},
open: () => {},
close: () => {}
close: () => {},
File: function() {}
}
if(typeof window === "undefined") {
+16 -2
View File
@@ -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
[![NPM version](https://badge.fury.io/js/swagger-ui-dist.svg)](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
View 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
+4 -2
View File
@@ -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")
+26 -2
View File
@@ -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() {
@@ -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)
})
})
})