Skip to content

Commit a62dace

Browse files
committed
feat: also support examples for properties
1 parent 5cf94fd commit a62dace

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
@@ -91,7 +91,11 @@ function sampleFromProp(
9191

9292
// TODO: handle discriminators
9393

94-
if (prop.oneOf) {
94+
if (prop.example !== undefined) {
95+
obj[name] = prop.example;
96+
} else if (prop.examples !== undefined && prop.examples.length > 0) {
97+
obj[name] = prop.examples[0];
98+
} else if (prop.oneOf) {
9599
obj[name] = sampleFromSchema(prop.oneOf[0], context);
96100
} else if (prop.anyOf) {
97101
obj[name] = sampleFromSchema(prop.anyOf[0], context);

0 commit comments

Comments
 (0)