Skip to content

Commit

Permalink
fixes rapi-doc#606 - handle nulls
Browse files Browse the repository at this point in the history
  • Loading branch information
mrin9 committed Nov 17, 2021
1 parent 1cc8699 commit 3e2a11d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/utils/schema-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,12 @@ export function schemaToSampleObj(schema, config = { }) {
const oneOfSamples = schemaToSampleObj(schema.oneOf[key], config);
for (const sampleKey in oneOfSamples) {
// 2. In the final example include a one-of item along with properties
const finalExample = Object.assign(oneOfSamples[sampleKey], objWithSchemaProps);
obj[`example-${i}`] = finalExample;
addSchemaInfoToExample(schema.oneOf[key], obj[`example-${i}`]);
i++;
if (oneOfSamples[sampleKey] === null) {
const finalExample = Object.assign(oneOfSamples[sampleKey], objWithSchemaProps);
obj[`example-${i}`] = finalExample;
addSchemaInfoToExample(schema.oneOf[key], obj[`example-${i}`]);
i++;
}
}
}
}
Expand Down

0 comments on commit 3e2a11d

Please sign in to comment.