fix(sample-gen): should return json literal example (#6827)
* fix(sample-gen): should return json literal example * test(sample-gen): should return json literal example
This commit is contained in:
@@ -203,7 +203,17 @@ export const sampleFromSchemaGeneric = (schema, config={}, exampleOverride = und
|
||||
|
||||
// if json just return
|
||||
if(!respectXML) {
|
||||
return sample
|
||||
// return if sample does not need any parsing
|
||||
if(typeof sample !== "string") {
|
||||
return sample
|
||||
}
|
||||
// check if sample is parsable or just a plain string
|
||||
try {
|
||||
return JSON.parse(sample)
|
||||
} catch(e) {
|
||||
// sample is just plain string return it
|
||||
return sample
|
||||
}
|
||||
}
|
||||
|
||||
// recover missing type
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user