Skip to content

Commit 4315cf6

Browse files
authored
Merge branch 'master' into bug/validation-messages
2 parents 87bbb9e + b3e86b3 commit 4315cf6

29 files changed

+521
-264
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
language: node_js
22
node_js:
33
- '6.9'
4+
cache:
5+
directories:
6+
- node_modules
47
services:
58
- docker
69
branches:
710
only:
811
- master
912
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/
13+
install: "npm i && npm update"
1014
before_deploy:
1115
- npm run build
1216
env:

docs/version-detection.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Some distinct identifiers to Swagger-UI 3.X:
2020

2121
If you've determined this is the version you have, to find the exact version:
2222
- Open your browser's web console (changes between browsers)
23-
- Type `versions` in the console and execute the call.
24-
- You might need to expand the result, until you get a string similar to `swaggerUi : Object { version: "3.1.6", gitRevision: "g786cd47", gitDirty: true, … }`.
23+
- Type `JSON.stringify(versions)` in the console and execute the call.
24+
- The result should look similar to `swaggerUi : Object { version: "3.1.6", gitRevision: "g786cd47", gitDirty: true, … }`.
2525
- The version taken from that example would be `3.1.6`.
2626

2727
Note: This functionality was added in 3.0.8. If you're unable to execute it, you're likely to use an older version, and in that case the first step would be to upgrade.
@@ -51,4 +51,4 @@ If you've determined this is the version you have, to find the exact version:
5151
* @link http://swagger.io
5252
* @license Apache-2.0
5353
*/
54-
```
54+
```

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@
5656
"memoizee": "0.4.1",
5757
"promise-worker": "^1.1.1",
5858
"prop-types": "^15.5.10",
59-
"react": "^15.4.0",
59+
"react": "^15.6.2",
6060
"react-addons-perf": "^15.4.0",
6161
"react-addons-shallow-compare": "0.14.8",
62-
"react-addons-test-utils": "^15.4.0",
62+
"react-addons-test-utils": "^15.6.2",
6363
"react-collapse": "2.3.1",
64-
"react-dom": "^15.4.0",
64+
"react-dom": "^15.6.2",
6565
"react-height": "^2.0.0",
6666
"react-hot-loader": "1.3.1",
6767
"react-immutable-proptypes": "2.1.0",
@@ -84,6 +84,7 @@
8484
"whatwg-fetch": "0.11.1",
8585
"worker-loader": "^0.7.1",
8686
"xml": "1.0.1",
87+
"xml-but-prettier": "^1.0.1",
8788
"yaml-js": "0.2.0"
8889
},
8990
"devDependencies": {

src/core/components/array-model.jsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,23 @@ export default class ArrayModel extends Component {
2424
const Markdown = getComponent("Markdown")
2525
const ModelCollapse = getComponent("ModelCollapse")
2626
const Model = getComponent("Model")
27+
const Property = getComponent("Property")
2728

2829
const titleEl = title &&
2930
<span className="model-title">
3031
<span className="model-title__text">{ title }</span>
3132
</span>
3233

33-
/*
34+
/*
3435
Note: we set `name={null}` in <Model> below because we don't want
3536
the name of the current Model passed (and displayed) as the name of the array element Model
36-
*/
37+
*/
3738

3839
return <span className="model">
3940
<ModelCollapse title={titleEl} collapsed={ depth > expandDepth } collapsedContent="[...]">
4041
[
4142
{
42-
properties.size ? properties.entrySeq().map( ( [ key, v ] ) => <span key={`${key}-${v}`} style={ propStyle }>
43-
<br />{ key }: { String(v) }</span>)
44-
: null
43+
properties.size ? properties.entrySeq().map( ( [ key, v ] ) => <Property key={`${key}-${v}`} propKey={ key } propVal={ v } propStyle={ propStyle } />) : null
4544
}
4645
{
4746
!description ? null :

src/core/components/primitive-model.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,15 @@ export default class Primitive extends Component {
2828
let properties = schema.filter( ( v, key) => ["enum", "type", "format", "description", "$$ref"].indexOf(key) === -1 )
2929
const Markdown = getComponent("Markdown")
3030
const EnumModel = getComponent("EnumModel")
31+
const Property = getComponent("Property")
3132

3233
return <span className="model">
3334
<span className="prop">
3435
{ name && <span className={`${depth === 1 && "model-title"} prop-name`}>{ title }</span> }
3536
<span className="prop-type">{ type }</span>
3637
{ format && <span className="prop-format">(${format})</span>}
3738
{
38-
properties.size ? properties.entrySeq().map( ( [ key, v ] ) => <span key={`${key}-${v}`} style={ propStyle }>
39-
<br />{ key }: { String(v) }</span>)
40-
: null
39+
properties.size ? properties.entrySeq().map( ( [ key, v ] ) => <Property key={`${key}-${v}`} propKey={ key } propVal={ v } propStyle={ propStyle } />) : null
4140
}
4241
{
4342
!description ? null :
@@ -56,4 +55,4 @@ export default class Primitive extends Component {
5655
</span>
5756
</span>
5857
}
59-
}
58+
}

src/core/components/property.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from "react"
2+
import PropTypes from "prop-types"
3+
4+
export const Property = ({ propKey, propVal, propStyle }) => {
5+
return (
6+
<span style={ propStyle }>
7+
<br />{ propKey }: { String(propVal) }</span>
8+
)
9+
}
10+
Property.propTypes = {
11+
propKey: PropTypes.string,
12+
propVal: PropTypes.any,
13+
propStyle: PropTypes.object
14+
}
15+
16+
export default Property

src/core/components/response-body.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react"
22
import PropTypes from "prop-types"
3-
import { formatXml } from "core/utils"
3+
import formatXml from "xml-but-prettier"
44
import lowerCase from "lodash/lowerCase"
55

66
export default class ResponseBody extends React.Component {
@@ -31,7 +31,9 @@ export default class ResponseBody extends React.Component {
3131

3232
// XML
3333
} else if (/xml/i.test(contentType)) {
34-
body = formatXml(content)
34+
body = formatXml(content, {
35+
textNodesOnSameLine: true
36+
})
3537
bodyEl = <HighlightCode value={ body } />
3638

3739
// HTML or Plain Text

src/core/index.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,12 @@ module.exports = function SwaggerUI(opts) {
5858
plugins: [
5959
],
6060

61+
// Initial state
62+
initialState: { },
63+
6164
// Inline Plugin
6265
fn: { },
6366
components: { },
64-
state: { },
65-
66-
// Override some core configs... at your own risk
67-
store: { },
6867
}
6968

7069
let queryConfig = parseSearch()
@@ -74,12 +73,12 @@ module.exports = function SwaggerUI(opts) {
7473

7574
const constructorConfig = deepExtend({}, defaults, opts, queryConfig)
7675

77-
const storeConfigs = deepExtend({}, constructorConfig.store, {
76+
const storeConfigs = {
7877
system: {
7978
configs: constructorConfig.configs
8079
},
8180
plugins: constructorConfig.presets,
82-
state: {
81+
state: deepExtend({
8382
layout: {
8483
layout: constructorConfig.layout,
8584
filter: constructorConfig.filter
@@ -88,8 +87,8 @@ module.exports = function SwaggerUI(opts) {
8887
spec: "",
8988
url: constructorConfig.url
9089
}
91-
}
92-
})
90+
}, constructorConfig.initialState)
91+
}
9392

9493
let inlinePlugin = ()=> {
9594
return {

src/core/plugins/oas3/components/http-auth.jsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ export default class HttpAuth extends React.Component {
108108
<Row>
109109
<Markdown source={ schema.get("description") } />
110110
</Row>
111-
<Row>
112-
<p>In: <code>{ schema.get("in") }</code></p>
113-
</Row>
114111
<Row>
115112
<label>Value:</label>
116113
{

src/core/plugins/oas3/spec-extensions/wrap-selectors.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ export const definitions = onlyOAS3(createSelector(
4848
spec => spec.getIn(["components", "schemas"]) || Map()
4949
))
5050

51+
export const hasHost = onlyOAS3((state) => {
52+
return spec(state).hasIn(["servers", 0])
53+
})
54+
5155
export const securityDefinitions = onlyOAS3(createSelector(
5256
spec,
5357
spec => spec.getIn(["components", "securitySchemes"]) || null

0 commit comments

Comments
 (0)