mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-12 05:48:57 +00:00
Handle nested deprecated properties in generateSchemaExample (#3267)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@gitbook/react-openapi': patch
|
||||
---
|
||||
|
||||
Handle nested deprecated properties in generateSchemaExample
|
||||
@@ -1017,4 +1017,24 @@ describe('generateSchemaExample', () => {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('handles deprecated properties', () => {
|
||||
expect(
|
||||
generateSchemaExample({
|
||||
type: 'object',
|
||||
deprecated: true,
|
||||
})
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it('handle nested deprecated properties', () => {
|
||||
expect(
|
||||
generateSchemaExample({
|
||||
type: 'array',
|
||||
items: {
|
||||
deprecated: true,
|
||||
},
|
||||
})
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -167,7 +167,7 @@ const getExampleFromSchema = (
|
||||
const makeUpRandomData = !!options?.emptyString;
|
||||
|
||||
// If the property is deprecated we don't show it in examples.
|
||||
if (schema.deprecated) {
|
||||
if (schema.deprecated || (schema.type === 'array' && schema.items?.deprecated)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user