docusaurus-plugin-openapi-docs 0.0.0-1079 → 0.0.0-1081

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -58,7 +58,14 @@ function sampleFromProp(name, prop, obj, context) {
58
58
  return obj;
59
59
  }
60
60
  // TODO: handle discriminators
61
- if (prop.oneOf) {
61
+ // Check for explicit example/examples first (OAS 3.1 support)
62
+ if (prop.example !== undefined) {
63
+ obj[name] = prop.example;
64
+ }
65
+ else if (prop.examples !== undefined && prop.examples.length > 0) {
66
+ obj[name] = prop.examples[0];
67
+ }
68
+ else if (prop.oneOf) {
62
69
  obj[name] = (0, exports.sampleFromSchema)(prop.oneOf[0], context);
63
70
  }
64
71
  else if (prop.anyOf) {
@@ -77,10 +84,14 @@ const sampleFromSchema = (schema = {}, context) => {
77
84
  try {
78
85
  // deep copy schema before processing
79
86
  let schemaCopy = JSON.parse(JSON.stringify(schema));
80
- let { type, example, allOf, properties, items, oneOf, anyOf, const: constant, } = schemaCopy;
87
+ let { type, example, examples, allOf, properties, items, oneOf, anyOf, const: constant, } = schemaCopy;
81
88
  if (example !== undefined) {
82
89
  return example;
83
90
  }
91
+ // OAS 3.1 / JSON Schema: examples is an array
92
+ if (examples !== undefined && examples.length > 0) {
93
+ return examples[0];
94
+ }
84
95
  if (oneOf) {
85
96
  if (properties) {
86
97
  const combinedSchemas = (0, merge_1.default)(schemaCopy, oneOf[0]);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "docusaurus-plugin-openapi-docs",
3
3
  "description": "OpenAPI plugin for Docusaurus.",
4
- "version": "0.0.0-1079",
4
+ "version": "0.0.0-1081",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -65,5 +65,5 @@
65
65
  "engines": {
66
66
  "node": ">=14"
67
67
  },
68
- "gitHead": "85d510d246cd12692f7a784f7668332a34bc0233"
68
+ "gitHead": "2b7184703cfbed61bafb8d671bbbb61ac5f187bc"
69
69
  }
@@ -91,7 +91,12 @@ function sampleFromProp(
91
91
 
92
92
  // TODO: handle discriminators
93
93
 
94
- if (prop.oneOf) {
94
+ // Check for explicit example/examples first (OAS 3.1 support)
95
+ if (prop.example !== undefined) {
96
+ obj[name] = prop.example;
97
+ } else if (prop.examples !== undefined && prop.examples.length > 0) {
98
+ obj[name] = prop.examples[0];
99
+ } else if (prop.oneOf) {
95
100
  obj[name] = sampleFromSchema(prop.oneOf[0], context);
96
101
  } else if (prop.anyOf) {
97
102
  obj[name] = sampleFromSchema(prop.anyOf[0], context);
@@ -114,6 +119,7 @@ export const sampleFromSchema = (
114
119
  let {
115
120
  type,
116
121
  example,
122
+ examples,
117
123
  allOf,
118
124
  properties,
119
125
  items,
@@ -126,6 +132,11 @@ export const sampleFromSchema = (
126
132
  return example;
127
133
  }
128
134
 
135
+ // OAS 3.1 / JSON Schema: examples is an array
136
+ if (examples !== undefined && examples.length > 0) {
137
+ return examples[0];
138
+ }
139
+
129
140
  if (oneOf) {
130
141
  if (properties) {
131
142
  const combinedSchemas = merge(schemaCopy, oneOf[0]);