Skip to content

Commit 7cd4299

Browse files
committed
Merge branch 'master' of github.com:swagger-api/swagger-ui
2 parents 408e038 + 746e247 commit 7cd4299

File tree

4 files changed

+32
-28
lines changed

4 files changed

+32
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Will start nginx with swagger-ui on port 80.
4646
Or you can provide your own swagger.json on your host
4747

4848
```
49-
docker run -p 80:8080 -e "SWAGGER_JSON=/foo/swagger.json" -v /bar:/foo swaggerapi/swagger-ui
49+
docker run -p 80:8080 -e SWAGGER_JSON=/foo/swagger.json -v /bar:/foo swaggerapi/swagger-ui
5050
```
5151

5252
##### Prerequisites

src/core/components/array-model.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,15 @@ export default class ArrayModel extends Component {
2828
<span className="model-title__text">{ title }</span>
2929
</span>
3030

31+
/*
32+
Note: we set `name={null}` in <Model> below because we don't want
33+
the name of the current Model passed (and displayed) as the name of the array element Model
34+
*/
35+
3136
return <span className="model">
3237
<ModelCollapse title={titleEl} collapsed={ depth > expandDepth } collapsedContent="[...]">
3338
[
34-
<span><Model { ...this.props } schema={ items } required={ false } depth={ depth + 1 } /></span>
39+
<span><Model { ...this.props } name={null} schema={ items } required={ false } depth={ depth + 1 } /></span>
3540
]
3641
{
3742
properties.size ? <span>

src/core/components/model.jsx

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,38 @@ export default class Model extends Component {
3030

3131
render () {
3232
let { getComponent, specSelectors, schema, required, name, isRef } = this.props
33-
let ObjectModel = getComponent("ObjectModel")
34-
let ArrayModel = getComponent("ArrayModel")
35-
let PrimitiveModel = getComponent("PrimitiveModel")
33+
const ObjectModel = getComponent("ObjectModel")
34+
const ArrayModel = getComponent("ArrayModel")
35+
const PrimitiveModel = getComponent("PrimitiveModel")
36+
let type = "object"
3637
let $$ref = schema && schema.get("$$ref")
37-
let modelName = $$ref && this.getModelName( $$ref )
38-
let modelSchema, type
39-
40-
const deprecated = specSelectors.isOAS3() && schema.get("deprecated")
41-
42-
if ( schema && (schema.get("type") || schema.get("properties")) ) {
43-
modelSchema = schema
44-
} else if ( $$ref ) {
45-
modelSchema = this.getRefSchema( modelName )
38+
39+
// If we weren't passed a `name` but have a ref, grab the name from the ref
40+
if ( !name && $$ref ) {
41+
name = this.getModelName( $$ref )
4642
}
47-
48-
type = modelSchema && modelSchema.get("type")
49-
if ( !type && modelSchema && modelSchema.get("properties") ) {
50-
type = "object"
43+
// If we weren't passed a `schema` but have a ref, grab the schema from the ref
44+
if ( !schema && $$ref ) {
45+
schema = this.getRefSchema( name )
5146
}
52-
47+
48+
const deprecated = specSelectors.isOAS3() && schema.get("deprecated")
49+
isRef = isRef !== undefined ? isRef : !!$$ref
50+
type = schema && schema.get("type") || type
51+
5352
switch(type) {
5453
case "object":
5554
return <ObjectModel
5655
className="object" { ...this.props }
57-
schema={ modelSchema }
58-
name={ modelName || name }
56+
schema={ schema }
57+
name={ name }
5958
deprecated={deprecated}
60-
isRef={ isRef!== undefined ? isRef : !!$$ref } />
59+
isRef={ isRef } />
6160
case "array":
6261
return <ArrayModel
6362
className="array" { ...this.props }
64-
schema={ modelSchema }
65-
name={ modelName || name }
63+
schema={ schema }
64+
name={ name }
6665
deprecated={deprecated}
6766
required={ required } />
6867
case "string":
@@ -73,9 +72,10 @@ export default class Model extends Component {
7372
return <PrimitiveModel
7473
{ ...this.props }
7574
getComponent={ getComponent }
76-
schema={ modelSchema }
77-
name={ modelName || name }
75+
schema={ schema }
76+
name={ name }
7877
deprecated={deprecated}
79-
required={ required }/> }
78+
required={ required }/>
79+
}
8080
}
8181
}

src/core/components/models.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export default class Models extends Component {
3434
return <div className="model-container" key={ `models-section-${name}` }>
3535
<ModelWrapper name={ name }
3636
schema={ model }
37-
isRef={ true }
3837
getComponent={ getComponent }
3938
specSelectors={ specSelectors }/>
4039
</div>

0 commit comments

Comments
 (0)