import React, { Component, } from "react"
import PropTypes from "prop-types"
import { List } from "immutable"
const braceOpen = "{"
const braceClose = "}"
export default class ObjectModel extends Component {
static propTypes = {
schema: PropTypes.object.isRequired,
getComponent: PropTypes.func.isRequired,
specSelectors: PropTypes.object.isRequired,
name: PropTypes.string,
isRef: PropTypes.bool,
expandDepth: PropTypes.number,
depth: PropTypes.number
}
render(){
let { schema, name, isRef, getComponent, depth, ...props } = this.props
let { expandDepth } = this.props
let description = schema.get("description")
let properties = schema.get("properties")
let additionalProperties = schema.get("additionalProperties")
let title = schema.get("title") || name
let required = schema.get("required")
const JumpToPath = getComponent("JumpToPath", true)
const Markdown = getComponent("Markdown")
const Model = getComponent("Model")
const ModelCollapse = getComponent("ModelCollapse")
const JumpToPathSection = ({ name }) =>
const collapsedContent = (
{ braceOpen }...{ braceClose }
{
isRef ? : ""
}
)
const titleEl = title &&
{ isRef && schema.get("$$ref") && { schema.get("$$ref") } }
{ title }
return
expandDepth } collapsedContent={ collapsedContent }>
{ braceOpen }
{
!isRef ? null :
}
{
{
!description ? null :
| description: |
|
}
{
!(properties && properties.size) ? null : properties.entrySeq().map(
([key, value]) => {
let isRequired = List.isList(required) && required.contains(key)
let propertyStyle = { verticalAlign: "top", paddingRight: "0.2em" }
if ( isRequired ) {
propertyStyle.fontWeight = "bold"
}
return (
| { key }: |
|
)
}).toArray()
}
{
!additionalProperties || !additionalProperties.size ? null
:
| { "< * >:" } |
|
}
}
{ braceClose }
}
}