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:
Mahtis Michel
2021-01-14 19:59:35 +01:00
committed by GitHub
parent 7087210adb
commit a2f7917661
2 changed files with 243 additions and 210 deletions

View File

@@ -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