Skip to content

Commit babcfb6

Browse files
john-hart-vertexinc-comshockey
authored andcommitted
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
1 parent 669ec1c commit babcfb6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/core/components/headers.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ import Im from "immutable"
55
const propStyle = { color: "#999", fontStyle: "italic" }
66

77
export default class Headers extends React.Component {
8-
98
static propTypes = {
109
headers: PropTypes.object.isRequired,
1110
getComponent: PropTypes.func.isRequired
1211
};
1312

1413
render() {
15-
1614
let { headers, getComponent } = this.props
15+
1716
const Property = getComponent("Property")
17+
const Markdown = getComponent("Markdown")
1818

1919
if ( !headers || !headers.size )
2020
return null
@@ -36,12 +36,16 @@ export default class Headers extends React.Component {
3636
if(!Im.Map.isMap(header)) {
3737
return null
3838
}
39+
40+
const description = header.get("description")
3941
const type = header.getIn(["schema"]) ? header.getIn(["schema", "type"]) : header.getIn(["type"])
4042
const schemaExample = header.getIn(["schema", "example"])
4143

4244
return (<tr key={ key }>
4345
<td className="header-col">{ key }</td>
44-
<td className="header-col">{ header.get( "description" ) }</td>
46+
<td className="header-col">{
47+
!description ? null : <Markdown source={ description } />
48+
}</td>
4549
<td className="header-col">{ type } { schemaExample ? <Property propKey={ "Example" } propVal={ schemaExample } propStyle={ propStyle } /> : null }</td>
4650
</tr>)
4751
}).toArray()

0 commit comments

Comments
 (0)