Merge pull request #3297 from owenconti/bug/3256-example-value-fix

#3256 - Fix custom example values
This commit is contained in:
shockey
2017-06-26 17:27:52 -07:00
committed by GitHub

View File

@@ -5,14 +5,16 @@ import { getSampleSchema } from "core/utils"
const getExampleComponent = ( sampleResponse, examples, HighlightCode ) => {
if ( examples && examples.size ) {
return examples.entrySeq().map( ([ key, example ]) => {
let exampleValue
try {
exampleValue = example && example.toJS ? example.toJS() : example
exampleValue = JSON.stringify(exampleValue, null, 2)
}
catch(e) {
exampleValue = String(example)
let exampleValue = example
if ( example.toJS ) {
try {
exampleValue = JSON.stringify(example.toJS(), null, 2)
}
catch(e) {
exampleValue = String(example)
}
}
return (<div key={ key }>
<h5>{ key }</h5>
<HighlightCode className="example" value={ exampleValue } />