import React, { Component, } from "react" import PropTypes from "prop-types" import { List } from "immutable" import ImPropTypes from "react-immutable-proptypes" import { sanitizeUrl } from "core/utils" const braceOpen = "{" const braceClose = "}" const propClass = "property" export default class ObjectModel extends Component { static propTypes = { schema: PropTypes.object.isRequired, getComponent: PropTypes.func.isRequired, getConfigs: PropTypes.func.isRequired, expanded: PropTypes.bool, onToggle: PropTypes.func, specSelectors: PropTypes.object.isRequired, name: PropTypes.string, displayName: PropTypes.string, isRef: PropTypes.bool, expandDepth: PropTypes.number, depth: PropTypes.number, specPath: ImPropTypes.list.isRequired, includeReadOnly: PropTypes.bool, includeWriteOnly: PropTypes.bool, } render(){ let { schema, name, displayName, isRef, getComponent, getConfigs, depth, onToggle, expanded, specPath, ...otherProps } = this.props let { specSelectors,expandDepth, includeReadOnly, includeWriteOnly} = otherProps const { isOAS3 } = specSelectors if(!schema) { return null } const { showExtensions } = getConfigs() let description = schema.get("description") let properties = schema.get("properties") let additionalProperties = schema.get("additionalProperties") let title = schema.get("title") || displayName || name let requiredProperties = schema.get("required") let infoProperties = schema .filter( ( v, key) => ["maxProperties", "minProperties", "nullable", "example"].indexOf(key) !== -1 ) let deprecated = schema.get("deprecated") let externalDocsUrl = schema.getIn(["externalDocs", "url"]) let externalDocsDescription = schema.getIn(["externalDocs", "description"]) const JumpToPath = getComponent("JumpToPath", true) const Markdown = getComponent("Markdown", true) const Model = getComponent("Model") const ModelCollapse = getComponent("ModelCollapse") const Property = getComponent("Property") const Link = getComponent("Link") const JumpToPathSection = () => { return } const collapsedContent = ( { braceOpen }...{ braceClose } { isRef ? : "" } ) const allOf = specSelectors.isOAS3() ? schema.get("allOf") : null const anyOf = specSelectors.isOAS3() ? schema.get("anyOf") : null const oneOf = specSelectors.isOAS3() ? schema.get("oneOf") : null const not = specSelectors.isOAS3() ? schema.get("not") : null const titleEl = title && { isRef && schema.get("$$ref") && { schema.get("$$ref") } } { title } return { braceOpen } { !isRef ? null : } { { !description ? null : } { externalDocsUrl && } { !deprecated ? null : } { !(properties && properties.size) ? null : properties.entrySeq().filter( ([, value]) => { return (!value.get("readOnly") || includeReadOnly) && (!value.get("writeOnly") || includeWriteOnly) } ).map( ([key, value]) => { let isDeprecated = isOAS3() && value.get("deprecated") let isRequired = List.isList(requiredProperties) && requiredProperties.contains(key) let classNames = ["property-row"] if (isDeprecated) { classNames.push("deprecated") } if (isRequired) { classNames.push("required") } return () }).toArray() } { // empty row before extensions... !showExtensions ? null : } { !showExtensions ? null : schema.entrySeq().map( ([key, value]) => { if(key.slice(0,2) !== "x-") { return } const normalizedValue = !value ? null : value.toJS ? value.toJS() : value return () }).toArray() } { !additionalProperties || !additionalProperties.size ? null : } { !allOf ? null : } { !anyOf ? null : } { !oneOf ? null : } { !not ? null : }
description:
externalDocs: {externalDocsDescription || externalDocsUrl}
deprecated: true
{ key }{ isRequired && * }
 
{ key } { JSON.stringify(normalizedValue) }
{ "< * >:" }
{ "allOf ->" } {allOf.map((schema, k) => { return
})}
{ "anyOf ->" } {anyOf.map((schema, k) => { return
})}
{ "oneOf ->" } {oneOf.map((schema, k) => { return
})}
{ "not ->" }
}
{ braceClose }
{ infoProperties.size ? infoProperties.entrySeq().map( ( [ key, v ] ) => ) : null }
} }