Skip to content

fix: Improve model property visualization. #10370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/core/plugins/json-schema-5/components/array-model.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export default class ArrayModel extends Component {
let description = schema.get("description")
let items = schema.get("items")
let title = schema.get("title") || displayName || name
let xml = items.get("xml")
let singleProperty = xml ? xml.size === 1 : false
let simpleProp = ["object", "array"].indexOf(items.get("type")) === -1
let properties = schema.filter( ( v, key) => ["type", "items", "description", "$$ref", "externalDocs"].indexOf(key) === -1 )
let externalDocsUrl = schema.getIn(["externalDocs", "url"])
let externalDocsDescription = schema.getIn(["externalDocs", "description"])
Expand All @@ -49,9 +52,13 @@ export default class ArrayModel extends Component {

return <span className="model">
<ModelCollapse title={titleEl} expanded={ depth <= expandDepth } collapsedContent="[...]">
{ singleProperty && simpleProp ? <span className="prop-type">{ items.get("type") }</span> : null }
[
{
properties.size ? properties.entrySeq().map( ( [ key, v ] ) => <Property key={`${key}-${v}`} propKey={ key } propVal={ v } propClass={ propClass } />) : null
properties.size && !singleProperty ? properties.entrySeq().map( ( [ key, v ] ) => <Property key={`${key}-${v}`} propKey={ key } propVal={ v } propClass={ propClass } />) : null
}
{
xml && properties.size && singleProperty ? xml.entrySeq().map( ( [ key, v ] ) => <Property key={`${key}-${v}`} propKey={ key } propVal={ v } propClass={ propClass } />) : null
}
{
!description ? (properties.size ? <div className="markdown"></div> : null) :
Expand All @@ -62,7 +69,8 @@ export default class ArrayModel extends Component {
<Link target="_blank" href={sanitizeUrl(externalDocsUrl)}>{externalDocsDescription || externalDocsUrl}</Link>
</div>
}
<span>
{ (!singleProperty || !simpleProp ) ?
(<span>
<Model
{ ...this.props }
getConfigs={ getConfigs }
Expand All @@ -72,7 +80,8 @@ export default class ArrayModel extends Component {
required={ false }
depth={ depth + 1 }
/>
</span>
</span>) : null
}
]
</ModelCollapse>
</span>
Expand Down