Merge pull request #3297 from owenconti/bug/3256-example-value-fix
#3256 - Fix custom example values
This commit is contained in:
@@ -5,14 +5,16 @@ import { getSampleSchema } from "core/utils"
|
|||||||
const getExampleComponent = ( sampleResponse, examples, HighlightCode ) => {
|
const getExampleComponent = ( sampleResponse, examples, HighlightCode ) => {
|
||||||
if ( examples && examples.size ) {
|
if ( examples && examples.size ) {
|
||||||
return examples.entrySeq().map( ([ key, example ]) => {
|
return examples.entrySeq().map( ([ key, example ]) => {
|
||||||
let exampleValue
|
let exampleValue = example
|
||||||
|
if ( example.toJS ) {
|
||||||
try {
|
try {
|
||||||
exampleValue = example && example.toJS ? example.toJS() : example
|
exampleValue = JSON.stringify(example.toJS(), null, 2)
|
||||||
exampleValue = JSON.stringify(exampleValue, null, 2)
|
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
exampleValue = String(example)
|
exampleValue = String(example)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (<div key={ key }>
|
return (<div key={ key }>
|
||||||
<h5>{ key }</h5>
|
<h5>{ key }</h5>
|
||||||
<HighlightCode className="example" value={ exampleValue } />
|
<HighlightCode className="example" value={ exampleValue } />
|
||||||
|
|||||||
Reference in New Issue
Block a user