diff --git a/README.md b/README.md index bdcfc28e..af874466 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ 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 +docker run -p 80:8080 -e SWAGGER_JSON=/foo/swagger.json -v /bar:/foo swaggerapi/swagger-ui ``` ##### Prerequisites diff --git a/src/core/components/array-model.jsx b/src/core/components/array-model.jsx index f0046aec..a9c36a2c 100644 --- a/src/core/components/array-model.jsx +++ b/src/core/components/array-model.jsx @@ -28,10 +28,15 @@ export default class ArrayModel extends Component { { title } + /* + Note: we set `name={null}` in below because we don't want + the name of the current Model passed (and displayed) as the name of the array element Model + */ + return expandDepth } collapsedContent="[...]"> [ - + ] { properties.size ? diff --git a/src/core/components/model.jsx b/src/core/components/model.jsx index e00c317e..73163388 100644 --- a/src/core/components/model.jsx +++ b/src/core/components/model.jsx @@ -30,39 +30,38 @@ export default class Model extends Component { render () { let { getComponent, specSelectors, schema, required, name, isRef } = this.props - let ObjectModel = getComponent("ObjectModel") - let ArrayModel = getComponent("ArrayModel") - let PrimitiveModel = getComponent("PrimitiveModel") + const ObjectModel = getComponent("ObjectModel") + const ArrayModel = getComponent("ArrayModel") + const PrimitiveModel = getComponent("PrimitiveModel") + let type = "object" let $$ref = schema && schema.get("$$ref") - let modelName = $$ref && this.getModelName( $$ref ) - let modelSchema, type - + + // If we weren't passed a `name` but have a ref, grab the name from the ref + if ( !name && $$ref ) { + name = this.getModelName( $$ref ) + } + // If we weren't passed a `schema` but have a ref, grab the schema from the ref + if ( !schema && $$ref ) { + schema = this.getRefSchema( name ) + } + const deprecated = specSelectors.isOAS3() && schema.get("deprecated") - - if ( schema && (schema.get("type") || schema.get("properties")) ) { - modelSchema = schema - } else if ( $$ref ) { - modelSchema = this.getRefSchema( modelName ) - } - - type = modelSchema && modelSchema.get("type") - if ( !type && modelSchema && modelSchema.get("properties") ) { - type = "object" - } - + isRef = isRef !== undefined ? isRef : !!$$ref + type = schema && schema.get("type") || type + switch(type) { case "object": return + isRef={ isRef } /> case "array": return case "string": @@ -73,9 +72,10 @@ export default class Model extends Component { return } + required={ required }/> + } } } diff --git a/src/core/components/models.jsx b/src/core/components/models.jsx index 1af412ab..29ac96d0 100644 --- a/src/core/components/models.jsx +++ b/src/core/components/models.jsx @@ -34,7 +34,6 @@ export default class Models extends Component { return