Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thick-chefs-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@gitbook/react-openapi': patch
---

Handle nested deprecated properties in generateSchemaExample
20 changes: 20 additions & 0 deletions packages/react-openapi/src/generateSchemaExample.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
2 changes: 1 addition & 1 deletion packages/react-openapi/src/generateSchemaExample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down