fix(sample-gen): respect null values in examples (via #4679)
* improvement: re-enable and improve Models jump-to-path * fix(sample-gen): respect null values in examples
This commit is contained in:
@@ -29,6 +29,7 @@ export const sampleFromSchema = (schema, config={}) => {
|
||||
let { type, example, properties, additionalProperties, items } = objectify(schema)
|
||||
let { includeReadOnly, includeWriteOnly } = config
|
||||
|
||||
|
||||
if(example !== undefined) {
|
||||
return deeplyStripKey(example, "$$ref", (val) => {
|
||||
// do a couple of quick sanity tests to ensure the value
|
||||
|
||||
@@ -742,7 +742,7 @@ export const getCommonExtensions = (defObj) => defObj.filter((v, k) => /^pattern
|
||||
// `predicate` can be used to discriminate the stripping further,
|
||||
// by preserving the key's place in the object based on its value.
|
||||
export function deeplyStripKey(input, keyToStrip, predicate = () => true) {
|
||||
if(typeof input !== "object" || Array.isArray(input) || !keyToStrip) {
|
||||
if(typeof input !== "object" || Array.isArray(input) || input === null || !keyToStrip) {
|
||||
return input
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user