import React, { Component } from "react" import PropTypes from "prop-types" const propStyle = { color: "#999", fontStyle: "italic" } export default class Primitive extends Component { static propTypes = { schema: PropTypes.object.isRequired, getComponent: PropTypes.func.isRequired, name: PropTypes.string, depth: PropTypes.number } render(){ let { schema, getComponent, name, depth } = this.props if(!schema || !schema.get) { // don't render if schema isn't correctly formed return
} let type = schema.get("type") let format = schema.get("format") let xml = schema.get("xml") let enumArray = schema.get("enum") let title = schema.get("title") || name let description = schema.get("description") let properties = schema.filter( ( v, key) => ["enum", "type", "format", "description", "$$ref"].indexOf(key) === -1 ) const Markdown = getComponent("Markdown") const EnumModel = getComponent("EnumModel") return { name && { title } } { type } { format && (${format})} { properties.size ? properties.entrySeq().map( ( [ key, v ] ) =>
{ key }: { String(v) }
) : null } { !description ? null : } { xml && xml.size ? (
xml: { xml.entrySeq().map( ( [ key, v ] ) =>
   {key}: { String(v) }
).toArray() }
): null } { enumArray && }
} }