Handle nested deprecated properties in generateSchemaExample (#3267)

This commit is contained in:
Nolann B.
2025-05-26 20:28:26 +02:00
committed by GitHub
parent 40df91a363
commit 4c9a9d0416
3 changed files with 26 additions and 1 deletions
+5
View File
@@ -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;
}