Skip to content

Commit 02a8102

Browse files
committed
feat: allow following examples array
1 parent b0d2b7d commit 02a8102

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/docusaurus-plugin-openapi-docs/src/openapi/createSchemaExample.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,15 @@ export const sampleFromSchema = (
111111
try {
112112
// deep copy schema before processing
113113
let schemaCopy = JSON.parse(JSON.stringify(schema));
114-
let { type, example, allOf, properties, items, oneOf, anyOf } = schemaCopy;
114+
let { type, example, examples, allOf, properties, items, oneOf, anyOf } =
115+
schemaCopy;
115116

116117
if (example !== undefined) {
117118
return example;
118119
}
120+
if (examples !== undefined && examples.length > 0) {
121+
return examples[0];
122+
}
119123

120124
if (oneOf) {
121125
if (properties) {

0 commit comments

Comments
 (0)