(Actually) display callbacks

This commit is contained in:
Kyle Shockey
2017-06-01 09:34:42 -07:00
parent ff39d075ff
commit 7deff73eea
5 changed files with 77 additions and 27 deletions

View File

@@ -0,0 +1,31 @@
import React from "react"
export default ({ callbacks, getComponent }) => {
const Markdown = getComponent("Markdown")
if(!callbacks) {
return <span>No callbacks</span>
}
let callbackElements = callbacks.map((callback, callbackName) => {
return <div>
<h2>{callbackName}</h2>
{ callback.map((pathItem, pathItemName) => {
return <div>
<h4>{pathItemName}</h4>
{ pathItem.map((operation, method) => {
return <pre>{JSON.stringify(operation)}</pre>
}) }
</div>
}) }
</div>
// return <div>
// <h2>{name}</h2>
// {callback.description && <Markdown source={callback.description}/>}
// <pre>{JSON.stringify(callback)}</pre>
// </div>
})
return <div>
{callbackElements}
</div>
}

View File

@@ -0,0 +1,7 @@
import Callbacks from "./callbacks"
import RequestBody from "./request-body"
export default {
Callbacks,
RequestBody
}

View File

@@ -0,0 +1,29 @@
import React from "react"
import { OrderedMap } from "immutable"
export default ({ requestBody, getComponent, specSelectors }) => {
const Markdown = getComponent("Markdown")
const Model = getComponent("model")
const requestBodyDescription = (requestBody && requestBody.get("description")) || null
const requestBodyContent = (requestBody && requestBody.get("content")) || new OrderedMap()
return <div>
{ requestBodyDescription &&
<p>{requestBodyDescription}</p>
}
{ !requestBodyContent.count() ? <p>No content</p> :
requestBodyContent.map((mediaTypeValue, key) => (
<div>
<h4>{key}</h4>
<Model
getComponent={ getComponent }
specSelectors={ specSelectors }
expandDepth={1}
schema={mediaTypeValue.get("schema")} />
</div>
)).toArray()
}
</div>
}