docusaurus-theme-openapi-docs 4.7.1 → 5.0.0

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.
Files changed (127) hide show
  1. package/lib/index.js +2 -0
  2. package/lib/markdown/schema.js +63 -9
  3. package/lib/theme/ApiExplorer/Accept/index.js +2 -1
  4. package/lib/theme/ApiExplorer/Authorization/index.js +12 -18
  5. package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.js +0 -4
  6. package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +5 -1
  7. package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +190 -37
  8. package/lib/theme/ApiExplorer/Body/index.js +84 -13
  9. package/lib/theme/ApiExplorer/Body/slice.d.ts +136 -544
  10. package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +2 -1
  11. package/lib/theme/ApiExplorer/CodeSnippets/index.js +4 -0
  12. package/lib/theme/ApiExplorer/CodeTabs/index.js +15 -16
  13. package/lib/theme/ApiExplorer/ContentType/index.js +7 -2
  14. package/lib/theme/ApiExplorer/EncodingSelection/slice.d.ts +17 -0
  15. package/lib/theme/ApiExplorer/EncodingSelection/slice.js +29 -0
  16. package/lib/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.d.ts +12 -0
  17. package/lib/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.js +39 -0
  18. package/lib/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
  19. package/lib/theme/ApiExplorer/FormItem/index.d.ts +1 -4
  20. package/lib/theme/ApiExplorer/FormItem/index.js +2 -26
  21. package/lib/theme/ApiExplorer/FormLabel/_FormLabel.scss +4 -0
  22. package/lib/theme/ApiExplorer/FormLabel/index.d.ts +9 -0
  23. package/lib/theme/ApiExplorer/FormLabel/index.js +50 -0
  24. package/lib/theme/ApiExplorer/FormMultiSelect/index.d.ts +4 -1
  25. package/lib/theme/ApiExplorer/FormMultiSelect/index.js +97 -19
  26. package/lib/theme/ApiExplorer/FormSelect/index.d.ts +6 -1
  27. package/lib/theme/ApiExplorer/FormSelect/index.js +96 -15
  28. package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +4 -1
  29. package/lib/theme/ApiExplorer/FormTextInput/index.js +71 -1
  30. package/lib/theme/ApiExplorer/MethodEndpoint/index.js +28 -0
  31. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.d.ts +4 -1
  32. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +11 -3
  33. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.d.ts +4 -1
  34. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +4 -1
  35. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.d.ts +4 -1
  36. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +6 -2
  37. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.d.ts +4 -1
  38. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +6 -2
  39. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.d.ts +4 -1
  40. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +8 -3
  41. package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
  42. package/lib/theme/ApiExplorer/ParamOptions/index.d.ts +10 -0
  43. package/lib/theme/ApiExplorer/ParamOptions/index.js +55 -5
  44. package/lib/theme/ApiExplorer/Request/_Request.scss +11 -0
  45. package/lib/theme/ApiExplorer/Request/index.js +19 -5
  46. package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +3 -1
  47. package/lib/theme/ApiExplorer/Request/makeRequest.js +19 -3
  48. package/lib/theme/ApiExplorer/Response/_Response.scss +11 -0
  49. package/lib/theme/ApiExplorer/Response/index.js +98 -12
  50. package/lib/theme/ApiExplorer/Server/index.d.ts +4 -1
  51. package/lib/theme/ApiExplorer/Server/index.js +6 -3
  52. package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +4 -1
  53. package/lib/theme/ApiExplorer/buildPostmanRequest.js +46 -5
  54. package/lib/theme/ApiExplorer/index.js +1 -0
  55. package/lib/theme/ApiExplorer/persistenceMiddleware.d.ts +2 -0
  56. package/lib/theme/ApiItem/hooks.d.ts +1 -0
  57. package/lib/theme/ApiItem/index.js +2 -1
  58. package/lib/theme/ApiItem/store.d.ts +6 -0
  59. package/lib/theme/ApiItem/store.js +11 -7
  60. package/lib/theme/ApiTabs/index.js +10 -11
  61. package/lib/theme/DiscriminatorTabs/index.js +10 -11
  62. package/lib/theme/MimeTabs/index.js +10 -11
  63. package/lib/theme/OperationTabs/index.js +10 -11
  64. package/lib/theme/ParamsItem/index.js +27 -0
  65. package/lib/theme/RequestSchema/index.js +172 -109
  66. package/lib/theme/ResponseHeaders/index.js +0 -1
  67. package/lib/theme/Schema/index.d.ts +1 -1
  68. package/lib/theme/Schema/index.js +91 -23
  69. package/lib/theme/SchemaItem/index.js +6 -1
  70. package/lib/theme/SchemaTabs/index.d.ts +1 -1
  71. package/lib/theme/SchemaTabs/index.js +31 -12
  72. package/lib/theme/styles.scss +1 -0
  73. package/lib/theme/translationIds.d.ts +3 -0
  74. package/lib/theme/translationIds.js +3 -0
  75. package/package.json +9 -8
  76. package/src/index.ts +2 -0
  77. package/src/markdown/schema.ts +69 -13
  78. package/src/theme/ApiExplorer/Accept/index.tsx +2 -1
  79. package/src/theme/ApiExplorer/Authorization/index.tsx +27 -33
  80. package/src/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.tsx +0 -5
  81. package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +115 -37
  82. package/src/theme/ApiExplorer/Body/index.tsx +85 -17
  83. package/src/theme/ApiExplorer/CodeSnippets/index.tsx +9 -1
  84. package/src/theme/ApiExplorer/CodeTabs/index.tsx +19 -19
  85. package/src/theme/ApiExplorer/ContentType/index.tsx +7 -4
  86. package/src/theme/ApiExplorer/EncodingSelection/slice.ts +31 -0
  87. package/src/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.ts +43 -0
  88. package/src/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
  89. package/src/theme/ApiExplorer/FormItem/index.tsx +2 -16
  90. package/src/theme/ApiExplorer/FormLabel/_FormLabel.scss +4 -0
  91. package/src/theme/ApiExplorer/FormLabel/index.tsx +43 -0
  92. package/src/theme/ApiExplorer/FormMultiSelect/index.tsx +40 -20
  93. package/src/theme/ApiExplorer/FormSelect/index.tsx +41 -15
  94. package/src/theme/ApiExplorer/FormTextInput/index.tsx +15 -1
  95. package/src/theme/ApiExplorer/MethodEndpoint/index.tsx +21 -0
  96. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +13 -2
  97. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +12 -1
  98. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +14 -2
  99. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +14 -2
  100. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +16 -3
  101. package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
  102. package/src/theme/ApiExplorer/ParamOptions/index.tsx +97 -11
  103. package/src/theme/ApiExplorer/Request/_Request.scss +11 -0
  104. package/src/theme/ApiExplorer/Request/index.tsx +20 -8
  105. package/src/theme/ApiExplorer/Request/makeRequest.ts +19 -3
  106. package/src/theme/ApiExplorer/Response/_Response.scss +11 -0
  107. package/src/theme/ApiExplorer/Response/index.tsx +35 -14
  108. package/src/theme/ApiExplorer/Server/index.tsx +10 -3
  109. package/src/theme/ApiExplorer/buildPostmanRequest.ts +52 -5
  110. package/src/theme/ApiExplorer/index.tsx +1 -0
  111. package/src/theme/ApiItem/index.tsx +2 -1
  112. package/src/theme/ApiItem/store.ts +2 -0
  113. package/src/theme/ApiTabs/index.tsx +14 -19
  114. package/src/theme/DiscriminatorTabs/index.tsx +14 -19
  115. package/src/theme/MimeTabs/index.tsx +15 -19
  116. package/src/theme/OperationTabs/index.tsx +14 -19
  117. package/src/theme/ParamsItem/index.tsx +25 -0
  118. package/src/theme/RequestSchema/index.tsx +141 -83
  119. package/src/theme/ResponseHeaders/index.tsx +1 -2
  120. package/src/theme/Schema/index.tsx +112 -27
  121. package/src/theme/SchemaItem/index.tsx +6 -1
  122. package/src/theme/SchemaTabs/index.tsx +42 -21
  123. package/src/theme/styles.scss +1 -0
  124. package/src/theme/translationIds.ts +3 -0
  125. package/src/theme-classic.d.ts +25 -1
  126. package/src/types.d.ts +7 -0
  127. package/tsconfig.tsbuildinfo +1 -1
@@ -88,11 +88,37 @@ function ParamsItem({ param, ...rest }) {
88
88
  })
89
89
  )
90
90
  );
91
+ const constValue = schema?.const;
91
92
  const renderQualifier = (0, utils_1.guard)(
92
93
  (0, schema_1.getQualifierMessage)(schema),
93
94
  (qualifier) =>
94
95
  react_1.default.createElement(Markdown_1.default, null, qualifier)
95
96
  );
97
+ function renderConstValue() {
98
+ if (constValue === undefined) {
99
+ return undefined;
100
+ }
101
+ const label = (0, Translate_1.translate)({
102
+ id: translationIds_1.OPENAPI_SCHEMA_ITEM.CONSTANT_VALUE,
103
+ message: "Constant value:",
104
+ });
105
+ return react_1.default.createElement(
106
+ "div",
107
+ null,
108
+ react_1.default.createElement("strong", null, label, " "),
109
+ react_1.default.createElement(
110
+ "span",
111
+ null,
112
+ react_1.default.createElement(
113
+ "code",
114
+ null,
115
+ typeof constValue === "string"
116
+ ? constValue
117
+ : JSON.stringify(constValue)
118
+ )
119
+ )
120
+ );
121
+ }
96
122
  const renderDescription = (0, utils_1.guard)(description, (description) =>
97
123
  react_1.default.createElement(Markdown_1.default, null, description)
98
124
  );
@@ -177,6 +203,7 @@ function ParamsItem({ param, ...rest }) {
177
203
  renderDeprecated
178
204
  ),
179
205
  renderQualifier,
206
+ renderConstValue(),
180
207
  renderDescription,
181
208
  renderEnumDescriptions,
182
209
  renderDefaultValue(),
@@ -17,7 +17,9 @@ const Translate_1 = require("@docusaurus/Translate");
17
17
  const Details_1 = __importDefault(require("@theme/Details"));
18
18
  const Markdown_1 = __importDefault(require("@theme/Markdown"));
19
19
  const MimeTabs_1 = __importDefault(require("@theme/MimeTabs")); // Assume these components exist
20
+ const ResponseExamples_1 = require("@theme/ResponseExamples");
20
21
  const Schema_1 = __importDefault(require("@theme/Schema"));
22
+ const SchemaTabs_1 = __importDefault(require("@theme/SchemaTabs"));
21
23
  const SkeletonLoader_1 = __importDefault(require("@theme/SkeletonLoader"));
22
24
  const TabItem_1 = __importDefault(require("@theme/TabItem"));
23
25
  const translationIds_1 = require("@theme/translationIds");
@@ -36,7 +38,10 @@ const RequestSchemaComponent = ({ title, body, style }) => {
36
38
  MimeTabs_1.default,
37
39
  { className: "openapi-tabs__mime", schemaType: "request", lazy: true },
38
40
  mimeTypes.map((mimeType) => {
39
- const firstBody = body.content[mimeType].schema;
41
+ const mediaTypeObject = body.content[mimeType];
42
+ const firstBody = mediaTypeObject?.schema;
43
+ const requestExamples = mediaTypeObject?.examples;
44
+ const requestExample = mediaTypeObject?.example;
40
45
  if (
41
46
  firstBody === undefined ||
42
47
  (firstBody.properties &&
@@ -50,68 +55,96 @@ const RequestSchemaComponent = ({ title, body, style }) => {
50
55
  TabItem_1.default,
51
56
  { key: mimeType, label: mimeType, value: mimeType },
52
57
  react_1.default.createElement(
53
- "div",
54
- { style: { marginTop: "1rem" } },
58
+ SchemaTabs_1.default,
59
+ { className: "openapi-tabs__schema" },
55
60
  react_1.default.createElement(
56
- Details_1.default,
57
- {
58
- className: "openapi-markdown__details mime",
59
- "data-collapsed": false,
60
- open: true,
61
- style: style,
62
- summary: react_1.default.createElement(
63
- react_1.default.Fragment,
64
- null,
65
- react_1.default.createElement(
66
- "summary",
67
- null,
68
- react_1.default.createElement(
69
- "h3",
70
- {
71
- className:
72
- "openapi-markdown__details-summary-header-body",
73
- },
74
- (0, Translate_1.translate)({
75
- id: translationIds_1.OPENAPI_REQUEST.BODY_TITLE,
76
- message: title,
77
- }),
78
- body.required === true &&
61
+ TabItem_1.default,
62
+ { key: title, label: title, value: title },
63
+ react_1.default.createElement(
64
+ "div",
65
+ { style: { marginTop: "1rem" } },
66
+ react_1.default.createElement(
67
+ Details_1.default,
68
+ {
69
+ className: "openapi-markdown__details mime",
70
+ "data-collapsed": false,
71
+ open: true,
72
+ style: style,
73
+ summary: react_1.default.createElement(
74
+ react_1.default.Fragment,
75
+ null,
76
+ react_1.default.createElement(
77
+ "summary",
78
+ null,
79
79
  react_1.default.createElement(
80
- "span",
81
- { className: "openapi-schema__required" },
80
+ "h3",
81
+ {
82
+ className:
83
+ "openapi-markdown__details-summary-header-body",
84
+ },
82
85
  (0, Translate_1.translate)({
83
- id: translationIds_1.OPENAPI_SCHEMA_ITEM.REQUIRED,
84
- message: "required",
85
- })
86
+ id: translationIds_1.OPENAPI_REQUEST.BODY_TITLE,
87
+ message: title,
88
+ }),
89
+ body.required === true &&
90
+ react_1.default.createElement(
91
+ "span",
92
+ { className: "openapi-schema__required" },
93
+ (0, Translate_1.translate)({
94
+ id: translationIds_1.OPENAPI_SCHEMA_ITEM
95
+ .REQUIRED,
96
+ message: "required",
97
+ })
98
+ )
86
99
  )
87
- )
88
- )
89
- ),
90
- },
91
- react_1.default.createElement(
92
- "div",
93
- { style: { textAlign: "left", marginLeft: "1rem" } },
94
- body.description &&
100
+ )
101
+ ),
102
+ },
95
103
  react_1.default.createElement(
96
104
  "div",
97
- { style: { marginTop: "1rem", marginBottom: "1rem" } },
98
- react_1.default.createElement(
99
- Markdown_1.default,
100
- null,
101
- body.description
102
- )
105
+ { style: { textAlign: "left", marginLeft: "1rem" } },
106
+ body.description &&
107
+ react_1.default.createElement(
108
+ "div",
109
+ {
110
+ style: { marginTop: "1rem", marginBottom: "1rem" },
111
+ },
112
+ react_1.default.createElement(
113
+ Markdown_1.default,
114
+ null,
115
+ body.description
116
+ )
117
+ )
118
+ ),
119
+ react_1.default.createElement(
120
+ "ul",
121
+ { style: { marginLeft: "1rem" } },
122
+ react_1.default.createElement(Schema_1.default, {
123
+ schema: firstBody,
124
+ schemaType: "request",
125
+ schemaPath: "requestBody",
126
+ })
103
127
  )
104
- ),
105
- react_1.default.createElement(
106
- "ul",
107
- { style: { marginLeft: "1rem" } },
108
- react_1.default.createElement(Schema_1.default, {
109
- schema: firstBody,
110
- schemaType: "request",
111
- schemaPath: "requestBody",
112
- })
128
+ )
113
129
  )
114
- )
130
+ ),
131
+ firstBody &&
132
+ !requestExample &&
133
+ !requestExamples &&
134
+ (0, ResponseExamples_1.ExampleFromSchema)({
135
+ schema: firstBody,
136
+ mimeType: mimeType,
137
+ }),
138
+ requestExamples &&
139
+ (0, ResponseExamples_1.ResponseExamples)({
140
+ responseExamples: requestExamples,
141
+ mimeType,
142
+ }),
143
+ requestExample &&
144
+ (0, ResponseExamples_1.ResponseExample)({
145
+ responseExample: requestExample,
146
+ mimeType,
147
+ })
115
148
  )
116
149
  )
117
150
  );
@@ -119,8 +152,10 @@ const RequestSchemaComponent = ({ title, body, style }) => {
119
152
  );
120
153
  }
121
154
  const randomFirstKey = mimeTypes[0];
122
- const firstBody =
123
- body.content[randomFirstKey].schema ?? body.content[randomFirstKey];
155
+ const mediaTypeObject = body.content[randomFirstKey];
156
+ const firstBody = mediaTypeObject?.schema ?? body.content[randomFirstKey];
157
+ const requestExamples = mediaTypeObject?.examples;
158
+ const requestExample = mediaTypeObject?.example;
124
159
  if (firstBody === undefined) {
125
160
  return null;
126
161
  }
@@ -131,67 +166,95 @@ const RequestSchemaComponent = ({ title, body, style }) => {
131
166
  TabItem_1.default,
132
167
  { label: randomFirstKey, value: `${randomFirstKey}-schema` },
133
168
  react_1.default.createElement(
134
- Details_1.default,
135
- {
136
- className: "openapi-markdown__details mime",
137
- "data-collapsed": false,
138
- open: true,
139
- style: style,
140
- summary: react_1.default.createElement(
141
- react_1.default.Fragment,
142
- null,
143
- react_1.default.createElement(
144
- "summary",
145
- null,
146
- react_1.default.createElement(
147
- "h3",
148
- { className: "openapi-markdown__details-summary-header-body" },
149
- (0, Translate_1.translate)({
150
- id: translationIds_1.OPENAPI_REQUEST.BODY_TITLE,
151
- message: title,
152
- }),
153
- firstBody.type === "array" &&
154
- react_1.default.createElement(
155
- "span",
156
- { style: { opacity: "0.6" } },
157
- " array"
158
- ),
159
- body.required &&
169
+ SchemaTabs_1.default,
170
+ { className: "openapi-tabs__schema" },
171
+ react_1.default.createElement(
172
+ TabItem_1.default,
173
+ { key: title, label: title, value: title },
174
+ react_1.default.createElement(
175
+ Details_1.default,
176
+ {
177
+ className: "openapi-markdown__details mime",
178
+ "data-collapsed": false,
179
+ open: true,
180
+ style: style,
181
+ summary: react_1.default.createElement(
182
+ react_1.default.Fragment,
183
+ null,
184
+ react_1.default.createElement(
185
+ "summary",
186
+ null,
160
187
  react_1.default.createElement(
161
- "strong",
162
- { className: "openapi-schema__required" },
188
+ "h3",
189
+ {
190
+ className:
191
+ "openapi-markdown__details-summary-header-body",
192
+ },
163
193
  (0, Translate_1.translate)({
164
- id: translationIds_1.OPENAPI_SCHEMA_ITEM.REQUIRED,
165
- message: "required",
166
- })
194
+ id: translationIds_1.OPENAPI_REQUEST.BODY_TITLE,
195
+ message: title,
196
+ }),
197
+ firstBody.type === "array" &&
198
+ react_1.default.createElement(
199
+ "span",
200
+ { style: { opacity: "0.6" } },
201
+ " array"
202
+ ),
203
+ body.required &&
204
+ react_1.default.createElement(
205
+ "strong",
206
+ { className: "openapi-schema__required" },
207
+ (0, Translate_1.translate)({
208
+ id: translationIds_1.OPENAPI_SCHEMA_ITEM.REQUIRED,
209
+ message: "required",
210
+ })
211
+ )
167
212
  )
168
- )
169
- )
170
- ),
171
- },
172
- react_1.default.createElement(
173
- "div",
174
- { style: { textAlign: "left", marginLeft: "1rem" } },
175
- body.description &&
213
+ )
214
+ ),
215
+ },
176
216
  react_1.default.createElement(
177
217
  "div",
178
- { style: { marginTop: "1rem", marginBottom: "1rem" } },
179
- react_1.default.createElement(
180
- Markdown_1.default,
181
- null,
182
- body.description
183
- )
218
+ { style: { textAlign: "left", marginLeft: "1rem" } },
219
+ body.description &&
220
+ react_1.default.createElement(
221
+ "div",
222
+ { style: { marginTop: "1rem", marginBottom: "1rem" } },
223
+ react_1.default.createElement(
224
+ Markdown_1.default,
225
+ null,
226
+ body.description
227
+ )
228
+ )
229
+ ),
230
+ react_1.default.createElement(
231
+ "ul",
232
+ { style: { marginLeft: "1rem" } },
233
+ react_1.default.createElement(Schema_1.default, {
234
+ schema: firstBody,
235
+ schemaType: "request",
236
+ schemaPath: "requestBody",
237
+ })
184
238
  )
239
+ )
185
240
  ),
186
- react_1.default.createElement(
187
- "ul",
188
- { style: { marginLeft: "1rem" } },
189
- react_1.default.createElement(Schema_1.default, {
241
+ firstBody &&
242
+ !requestExample &&
243
+ !requestExamples &&
244
+ (0, ResponseExamples_1.ExampleFromSchema)({
190
245
  schema: firstBody,
191
- schemaType: "request",
192
- schemaPath: "requestBody",
246
+ mimeType: randomFirstKey,
247
+ }),
248
+ requestExamples &&
249
+ (0, ResponseExamples_1.ResponseExamples)({
250
+ responseExamples: requestExamples,
251
+ mimeType: randomFirstKey,
252
+ }),
253
+ requestExample &&
254
+ (0, ResponseExamples_1.ResponseExample)({
255
+ responseExample: requestExample,
256
+ mimeType: randomFirstKey,
193
257
  })
194
- )
195
258
  )
196
259
  )
197
260
  );
@@ -27,7 +27,6 @@ const ResponseHeaders = ({ responseHeaders }) => {
27
27
  name: name,
28
28
  collapsible: false,
29
29
  schemaName: (0, schema_1.getSchemaName)(schema),
30
- qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
31
30
  schema: schema,
32
31
  discriminator: false,
33
32
  children: null,
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import type { SchemaObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
2
+ import type { SchemaObject } from "../../types.d";
3
3
  interface SchemaProps {
4
4
  schema: SchemaObject;
5
5
  schemaType: "request" | "response";
@@ -84,8 +84,8 @@ const translationIds_1 = require("@theme/translationIds");
84
84
  // eslint-disable-next-line import/no-extraneous-dependencies
85
85
  const allof_merge_1 = require("allof-merge");
86
86
  const clsx_1 = __importDefault(require("clsx"));
87
- const schema_1 = require("docusaurus-plugin-openapi-docs/lib/markdown/schema");
88
87
  const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
88
+ const schema_1 = require("../../markdown/schema");
89
89
  // eslint-disable-next-line import/no-extraneous-dependencies
90
90
  // const jsonSchemaMergeAllOf = require("json-schema-merge-allof");
91
91
  const mergeAllOf = (allOf) => {
@@ -93,7 +93,68 @@ const mergeAllOf = (allOf) => {
93
93
  console.warn(msg);
94
94
  };
95
95
  const mergedSchemas = (0, allof_merge_1.merge)(allOf, { onMergeError });
96
- return mergedSchemas;
96
+ return mergedSchemas ?? {};
97
+ };
98
+ /**
99
+ * Recursively searches for a property in a schema, including nested
100
+ * oneOf, anyOf, and allOf structures. This is needed for discriminators
101
+ * where the property definition may be in a nested schema.
102
+ */
103
+ const findProperty = (schema, propertyName) => {
104
+ // Check direct properties first
105
+ if (schema.properties?.[propertyName]) {
106
+ return schema.properties[propertyName];
107
+ }
108
+ // Search in oneOf schemas
109
+ if (schema.oneOf) {
110
+ for (const subschema of schema.oneOf) {
111
+ const found = findProperty(subschema, propertyName);
112
+ if (found) return found;
113
+ }
114
+ }
115
+ // Search in anyOf schemas
116
+ if (schema.anyOf) {
117
+ for (const subschema of schema.anyOf) {
118
+ const found = findProperty(subschema, propertyName);
119
+ if (found) return found;
120
+ }
121
+ }
122
+ // Search in allOf schemas
123
+ if (schema.allOf) {
124
+ for (const subschema of schema.allOf) {
125
+ const found = findProperty(subschema, propertyName);
126
+ if (found) return found;
127
+ }
128
+ }
129
+ return undefined;
130
+ };
131
+ /**
132
+ * Recursively searches for a discriminator in a schema, including nested
133
+ * oneOf, anyOf, and allOf structures.
134
+ */
135
+ const findDiscriminator = (schema) => {
136
+ if (schema.discriminator) {
137
+ return schema.discriminator;
138
+ }
139
+ if (schema.oneOf) {
140
+ for (const subschema of schema.oneOf) {
141
+ const found = findDiscriminator(subschema);
142
+ if (found) return found;
143
+ }
144
+ }
145
+ if (schema.anyOf) {
146
+ for (const subschema of schema.anyOf) {
147
+ const found = findDiscriminator(subschema);
148
+ if (found) return found;
149
+ }
150
+ }
151
+ if (schema.allOf) {
152
+ for (const subschema of schema.allOf) {
153
+ const found = findDiscriminator(subschema);
154
+ if (found) return found;
155
+ }
156
+ }
157
+ return undefined;
97
158
  };
98
159
  // Renders string as markdown, useful for descriptions and qualifiers
99
160
  const MarkdownWrapper = ({ text }) => {
@@ -165,6 +226,12 @@ const Summary = ({ name, schemaName, schema, required }) => {
165
226
  };
166
227
  const AnyOneOf = ({ schema, schemaType, schemaPath }) => {
167
228
  const key = schema.oneOf ? "oneOf" : "anyOf";
229
+ const schemaArray = schema[key];
230
+ // Empty oneOf/anyOf arrays are valid in OpenAPI specs but would cause the
231
+ // Tabs component to throw "requires at least one TabItem". Return null instead.
232
+ if (!schemaArray || !Array.isArray(schemaArray) || schemaArray.length === 0) {
233
+ return null;
234
+ }
168
235
  const type = schema.oneOf
169
236
  ? (0, Translate_1.translate)({
170
237
  id: translationIds_1.OPENAPI_SCHEMA_ITEM.ONE_OF,
@@ -244,9 +311,6 @@ const AnyOneOf = ({ schema, schemaType, schemaPath }) => {
244
311
  collapsible: false,
245
312
  name: undefined,
246
313
  schemaName: computedSchemaName,
247
- qualifierMessage: (0, schema_1.getQualifierMessage)(
248
- anyOneSchema
249
- ),
250
314
  schema: anyOneSchema,
251
315
  discriminator: false,
252
316
  children: null,
@@ -260,9 +324,6 @@ const AnyOneOf = ({ schema, schemaType, schemaPath }) => {
260
324
  collapsible: false,
261
325
  name: undefined,
262
326
  schemaName: computedSchemaName,
263
- qualifierMessage: (0, schema_1.getQualifierMessage)(
264
- anyOneSchema
265
- ),
266
327
  schema: anyOneSchema,
267
328
  discriminator: false,
268
329
  children: null,
@@ -321,12 +382,16 @@ const Properties = ({ schema, schemaType, schemaPath }) => {
321
382
  discriminator["mapping"] = inferredMapping;
322
383
  }
323
384
  if (Object.keys(schema.properties).length === 0) {
385
+ // Hide placeholder only for discriminator cleanup artifacts; preserve
386
+ // empty object rendering for schemas that intentionally define no properties.
387
+ if (discriminator) {
388
+ return null;
389
+ }
324
390
  return react_1.default.createElement(SchemaItem_1.default, {
325
391
  collapsible: false,
326
392
  name: "",
327
393
  required: false,
328
394
  schemaName: "object",
329
- qualifierMessage: undefined,
330
395
  schema: {},
331
396
  });
332
397
  }
@@ -448,10 +513,9 @@ const PropertyDiscriminator = ({
448
513
  const DiscriminatorNode = ({ discriminator, schema, schemaType }) => {
449
514
  let discriminatedSchemas = {};
450
515
  let inferredMapping = {};
451
- // default to empty object if no parent-level properties exist
452
- const discriminatorProperty = schema.properties
453
- ? schema.properties[discriminator.propertyName]
454
- : {};
516
+ // Search for the discriminator property in the schema, including nested structures
517
+ const discriminatorProperty =
518
+ findProperty(schema, discriminator.propertyName) ?? {};
455
519
  if (schema.allOf) {
456
520
  const mergedSchemas = mergeAllOf(schema);
457
521
  if (mergedSchemas.oneOf || mergedSchemas.anyOf) {
@@ -523,7 +587,6 @@ const AdditionalProperties = ({ schema, schemaType }) => {
523
587
  name: "property name*",
524
588
  required: false,
525
589
  schemaName: "any",
526
- qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
527
590
  schema: schema,
528
591
  collapsible: false,
529
592
  discriminator: false,
@@ -564,7 +627,6 @@ const AdditionalProperties = ({ schema, schemaType }) => {
564
627
  name: "property name*",
565
628
  required: false,
566
629
  schemaName: schemaName,
567
- qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
568
630
  schema: additionalProperties,
569
631
  collapsible: false,
570
632
  discriminator: false,
@@ -669,7 +731,6 @@ const Items = ({ schema, schemaType, schemaPath }) => {
669
731
  collapsible: false,
670
732
  name: "", // No name for array items
671
733
  schemaName: (0, schema_1.getSchemaName)(itemsSchema),
672
- qualifierMessage: (0, schema_1.getQualifierMessage)(itemsSchema),
673
734
  schema: itemsSchema,
674
735
  discriminator: false,
675
736
  children: null,
@@ -790,7 +851,6 @@ const SchemaEdge = ({
790
851
  name: name,
791
852
  required: Array.isArray(required) ? required.includes(name) : required,
792
853
  schemaName: schema.allOf[0],
793
- qualifierMessage: undefined,
794
854
  schema: schema.allOf[0],
795
855
  discriminator: false,
796
856
  children: null,
@@ -842,7 +902,6 @@ const SchemaEdge = ({
842
902
  name: name,
843
903
  required: Array.isArray(required) ? required.includes(name) : required,
844
904
  schemaName: mergedSchemaName,
845
- qualifierMessage: (0, schema_1.getQualifierMessage)(mergedSchemas),
846
905
  schema: mergedSchemas,
847
906
  discriminator: false,
848
907
  children: null,
@@ -853,7 +912,6 @@ const SchemaEdge = ({
853
912
  name: name,
854
913
  required: Array.isArray(required) ? required.includes(name) : required,
855
914
  schemaName: schemaName,
856
- qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
857
915
  schema: schema,
858
916
  discriminator: false,
859
917
  children: null,
@@ -901,11 +959,22 @@ const SchemaNode = ({ schema, schemaType, schemaPath }) => {
901
959
  ) {
902
960
  return null;
903
961
  }
904
- if (schema.discriminator) {
905
- const { discriminator } = schema;
962
+ // Resolve discriminator recursively so nested oneOf/anyOf/allOf compositions
963
+ // can still render discriminator tabs.
964
+ let workingSchema = schema;
965
+ const resolvedDiscriminator =
966
+ schema.discriminator ?? findDiscriminator(schema);
967
+ if (schema.allOf && !schema.discriminator && resolvedDiscriminator) {
968
+ workingSchema = mergeAllOf(schema);
969
+ }
970
+ if (!workingSchema.discriminator && resolvedDiscriminator) {
971
+ workingSchema.discriminator = resolvedDiscriminator;
972
+ }
973
+ if (workingSchema.discriminator) {
974
+ const { discriminator } = workingSchema;
906
975
  return react_1.default.createElement(DiscriminatorNode, {
907
976
  discriminator: discriminator,
908
- schema: schema,
977
+ schema: workingSchema,
909
978
  schemaType: schemaType,
910
979
  });
911
980
  }
@@ -1010,7 +1079,6 @@ const SchemaNode = ({ schema, schemaType, schemaPath }) => {
1010
1079
  name: schema.type,
1011
1080
  required: Boolean(schema.required),
1012
1081
  schemaName: schemaName,
1013
- qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
1014
1082
  schema: schema,
1015
1083
  discriminator: false,
1016
1084
  children: null,
@@ -18,6 +18,7 @@ const Example_1 = require("@theme/Example");
18
18
  const Markdown_1 = __importDefault(require("@theme/Markdown"));
19
19
  const translationIds_1 = require("@theme/translationIds");
20
20
  const clsx_1 = __importDefault(require("clsx"));
21
+ const schema_1 = require("../../markdown/schema");
21
22
  const utils_1 = require("../../markdown/utils");
22
23
  const transformEnumDescriptions = (enumDescriptions) => {
23
24
  if (enumDescriptions) {
@@ -127,8 +128,12 @@ function SchemaItem(props) {
127
128
  react_1.default.createElement(Markdown_1.default, null, description)
128
129
  )
129
130
  );
131
+ // Generate qualifierMessage from schema if not provided
132
+ const effectiveQualifierMessage =
133
+ qualifierMessage ??
134
+ (schema ? (0, schema_1.getQualifierMessage)(schema) : undefined);
130
135
  const renderQualifierMessage = (0, utils_1.guard)(
131
- qualifierMessage,
136
+ effectiveQualifierMessage,
132
137
  (message) =>
133
138
  react_1.default.createElement(
134
139
  react_1.default.Fragment,
@@ -7,4 +7,4 @@ export interface SchemaTabsProps extends TabProps {
7
7
  */
8
8
  onChange?: (index: number) => void;
9
9
  }
10
- export default function SchemaTabs(props: SchemaTabsProps): React.JSX.Element;
10
+ export default function SchemaTabs(props: SchemaTabsProps): React.JSX.Element | null;