improvement: support Markdown in header descriptions (via #5120)
* Added markdown for header descriptions as per specifications: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#header-object which subclasses: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#parameterObject https://swagger.io/specification/#headerObject which subclasses https://swagger.io/specification/#parameterObject * update headers.jsx * Update headers.jsx Fixing test error due to the `description` variable having been removed * Update headers.jsx
This commit is contained in:
@@ -5,16 +5,16 @@ import Im from "immutable"
|
|||||||
const propStyle = { color: "#999", fontStyle: "italic" }
|
const propStyle = { color: "#999", fontStyle: "italic" }
|
||||||
|
|
||||||
export default class Headers extends React.Component {
|
export default class Headers extends React.Component {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
headers: PropTypes.object.isRequired,
|
headers: PropTypes.object.isRequired,
|
||||||
getComponent: PropTypes.func.isRequired
|
getComponent: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
let { headers, getComponent } = this.props
|
let { headers, getComponent } = this.props
|
||||||
|
|
||||||
const Property = getComponent("Property")
|
const Property = getComponent("Property")
|
||||||
|
const Markdown = getComponent("Markdown")
|
||||||
|
|
||||||
if ( !headers || !headers.size )
|
if ( !headers || !headers.size )
|
||||||
return null
|
return null
|
||||||
@@ -36,12 +36,16 @@ export default class Headers extends React.Component {
|
|||||||
if(!Im.Map.isMap(header)) {
|
if(!Im.Map.isMap(header)) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const description = header.get("description")
|
||||||
const type = header.getIn(["schema"]) ? header.getIn(["schema", "type"]) : header.getIn(["type"])
|
const type = header.getIn(["schema"]) ? header.getIn(["schema", "type"]) : header.getIn(["type"])
|
||||||
const schemaExample = header.getIn(["schema", "example"])
|
const schemaExample = header.getIn(["schema", "example"])
|
||||||
|
|
||||||
return (<tr key={ key }>
|
return (<tr key={ key }>
|
||||||
<td className="header-col">{ key }</td>
|
<td className="header-col">{ key }</td>
|
||||||
<td className="header-col">{ header.get( "description" ) }</td>
|
<td className="header-col">{
|
||||||
|
!description ? null : <Markdown source={ description } />
|
||||||
|
}</td>
|
||||||
<td className="header-col">{ type } { schemaExample ? <Property propKey={ "Example" } propVal={ schemaExample } propStyle={ propStyle } /> : null }</td>
|
<td className="header-col">{ type } { schemaExample ? <Property propKey={ "Example" } propVal={ schemaExample } propStyle={ propStyle } /> : null }</td>
|
||||||
</tr>)
|
</tr>)
|
||||||
}).toArray()
|
}).toArray()
|
||||||
|
|||||||
Reference in New Issue
Block a user