Create valid paths for model jumping in OAS3

This commit is contained in:
Kyle Shockey
2017-08-03 16:15:47 -07:00
parent ad8bad6ddc
commit b16907ce6d

View File

@@ -18,7 +18,8 @@ export default class ObjectModel extends Component {
render(){ render(){
let { schema, name, isRef, getComponent, depth, ...props } = this.props let { schema, name, isRef, getComponent, depth, ...props } = this.props
let { expandDepth } = this.props let { expandDepth, specSelectors } = this.props
let { isOAS3 } = specSelectors
let description = schema.get("description") let description = schema.get("description")
let properties = schema.get("properties") let properties = schema.get("properties")
let additionalProperties = schema.get("additionalProperties") let additionalProperties = schema.get("additionalProperties")
@@ -30,14 +31,16 @@ export default class ObjectModel extends Component {
const Model = getComponent("Model") const Model = getComponent("Model")
const ModelCollapse = getComponent("ModelCollapse") const ModelCollapse = getComponent("ModelCollapse")
const JumpToPathSection = ({ name }) => <span className="model-jump-to-path"><JumpToPath path={`definitions.${name}`} /></span> const path = isOAS3 && isOAS3() ? `components.schemas.${name}` : `definitions.${name}`
const JumpToPathSection = ({ name }) => <span className="model-jump-to-path"><JumpToPath path={path} /></span>
const collapsedContent = (<span> const collapsedContent = (<span>
<span>{ braceOpen }</span>...<span>{ braceClose }</span> <span>{ braceOpen }</span>...<span>{ braceClose }</span>
{ {
isRef ? <JumpToPathSection name={ name }/> : "" isRef ? <JumpToPathSection name={ name }/> : ""
} }
</span>) </span>)
const titleEl = title && <span className="model-title"> const titleEl = title && <span className="model-title">
{ isRef && schema.get("$$ref") && <span className="model-hint">{ schema.get("$$ref") }</span> } { isRef && schema.get("$$ref") && <span className="model-hint">{ schema.get("$$ref") }</span> }
<span className="model-title__text">{ title }</span> <span className="model-title__text">{ title }</span>
@@ -102,4 +105,4 @@ export default class ObjectModel extends Component {
</ModelCollapse> </ModelCollapse>
</span> </span>
} }
} }