docusaurus-theme-openapi-docs 4.7.0 → 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 (148) 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/Authorization/slice.d.ts +1 -1
  6. package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.js +0 -4
  7. package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +6 -2
  8. package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +191 -38
  9. package/lib/theme/ApiExplorer/Body/index.d.ts +1 -1
  10. package/lib/theme/ApiExplorer/Body/index.js +86 -15
  11. package/lib/theme/ApiExplorer/Body/resolveSchemaWithSelections.d.ts +1 -1
  12. package/lib/theme/ApiExplorer/Body/slice.d.ts +136 -544
  13. package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +2 -1
  14. package/lib/theme/ApiExplorer/CodeSnippets/index.js +4 -0
  15. package/lib/theme/ApiExplorer/CodeTabs/index.js +15 -16
  16. package/lib/theme/ApiExplorer/ContentType/index.js +7 -2
  17. package/lib/theme/ApiExplorer/EncodingSelection/slice.d.ts +17 -0
  18. package/lib/theme/ApiExplorer/EncodingSelection/slice.js +29 -0
  19. package/lib/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.d.ts +12 -0
  20. package/lib/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.js +39 -0
  21. package/lib/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
  22. package/lib/theme/ApiExplorer/FormItem/index.d.ts +1 -4
  23. package/lib/theme/ApiExplorer/FormItem/index.js +2 -26
  24. package/lib/theme/ApiExplorer/FormLabel/_FormLabel.scss +4 -0
  25. package/lib/theme/ApiExplorer/FormLabel/index.d.ts +9 -0
  26. package/lib/theme/ApiExplorer/FormLabel/index.js +50 -0
  27. package/lib/theme/ApiExplorer/FormMultiSelect/index.d.ts +4 -1
  28. package/lib/theme/ApiExplorer/FormMultiSelect/index.js +97 -19
  29. package/lib/theme/ApiExplorer/FormSelect/index.d.ts +6 -1
  30. package/lib/theme/ApiExplorer/FormSelect/index.js +96 -15
  31. package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +4 -1
  32. package/lib/theme/ApiExplorer/FormTextInput/index.js +71 -1
  33. package/lib/theme/ApiExplorer/MethodEndpoint/index.js +28 -0
  34. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.d.ts +4 -1
  35. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +11 -3
  36. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.d.ts +4 -1
  37. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +4 -1
  38. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.d.ts +4 -1
  39. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +6 -2
  40. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.d.ts +4 -1
  41. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +6 -2
  42. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.d.ts +4 -1
  43. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +8 -3
  44. package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
  45. package/lib/theme/ApiExplorer/ParamOptions/index.d.ts +10 -0
  46. package/lib/theme/ApiExplorer/ParamOptions/index.js +55 -5
  47. package/lib/theme/ApiExplorer/ParamOptions/slice.d.ts +1 -1
  48. package/lib/theme/ApiExplorer/Request/_Request.scss +11 -0
  49. package/lib/theme/ApiExplorer/Request/index.d.ts +1 -1
  50. package/lib/theme/ApiExplorer/Request/index.js +19 -5
  51. package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +3 -1
  52. package/lib/theme/ApiExplorer/Request/makeRequest.js +19 -3
  53. package/lib/theme/ApiExplorer/Response/_Response.scss +11 -0
  54. package/lib/theme/ApiExplorer/Response/index.d.ts +1 -1
  55. package/lib/theme/ApiExplorer/Response/index.js +98 -12
  56. package/lib/theme/ApiExplorer/SecuritySchemes/index.js +2 -2
  57. package/lib/theme/ApiExplorer/Server/index.d.ts +4 -1
  58. package/lib/theme/ApiExplorer/Server/index.js +6 -3
  59. package/lib/theme/ApiExplorer/Server/slice.d.ts +1 -1
  60. package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +5 -2
  61. package/lib/theme/ApiExplorer/buildPostmanRequest.js +46 -5
  62. package/lib/theme/ApiExplorer/index.d.ts +1 -1
  63. package/lib/theme/ApiExplorer/index.js +1 -0
  64. package/lib/theme/ApiExplorer/persistenceMiddleware.d.ts +2 -0
  65. package/lib/theme/ApiItem/hooks.d.ts +1 -0
  66. package/lib/theme/ApiItem/index.js +2 -1
  67. package/lib/theme/ApiItem/store.d.ts +6 -0
  68. package/lib/theme/ApiItem/store.js +11 -7
  69. package/lib/theme/ApiTabs/index.js +10 -11
  70. package/lib/theme/DiscriminatorTabs/index.js +10 -11
  71. package/lib/theme/MimeTabs/index.js +10 -11
  72. package/lib/theme/OperationTabs/index.js +10 -11
  73. package/lib/theme/ParamsDetails/index.js +2 -2
  74. package/lib/theme/ParamsItem/index.js +27 -0
  75. package/lib/theme/RequestSchema/index.d.ts +1 -1
  76. package/lib/theme/RequestSchema/index.js +174 -111
  77. package/lib/theme/ResponseHeaders/index.js +0 -1
  78. package/lib/theme/ResponseSchema/index.d.ts +1 -1
  79. package/lib/theme/Schema/index.d.ts +1 -1
  80. package/lib/theme/Schema/index.js +91 -23
  81. package/lib/theme/SchemaItem/index.js +6 -1
  82. package/lib/theme/SchemaTabs/index.d.ts +1 -1
  83. package/lib/theme/SchemaTabs/index.js +31 -12
  84. package/lib/theme/StatusCodes/index.d.ts +1 -1
  85. package/lib/theme/styles.scss +1 -0
  86. package/lib/theme/translationIds.d.ts +3 -0
  87. package/lib/theme/translationIds.js +3 -0
  88. package/package.json +9 -8
  89. package/src/index.ts +2 -0
  90. package/src/markdown/schema.ts +69 -13
  91. package/src/theme/ApiExplorer/Accept/index.tsx +2 -1
  92. package/src/theme/ApiExplorer/Authorization/index.tsx +27 -33
  93. package/src/theme/ApiExplorer/Authorization/slice.ts +1 -1
  94. package/src/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.tsx +2 -5
  95. package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +119 -39
  96. package/src/theme/ApiExplorer/Body/index.tsx +88 -21
  97. package/src/theme/ApiExplorer/Body/resolveSchemaWithSelections.ts +1 -1
  98. package/src/theme/ApiExplorer/CodeSnippets/index.tsx +9 -1
  99. package/src/theme/ApiExplorer/CodeTabs/index.tsx +19 -19
  100. package/src/theme/ApiExplorer/ContentType/index.tsx +7 -4
  101. package/src/theme/ApiExplorer/EncodingSelection/slice.ts +31 -0
  102. package/src/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.ts +43 -0
  103. package/src/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
  104. package/src/theme/ApiExplorer/FormItem/index.tsx +2 -17
  105. package/src/theme/ApiExplorer/FormLabel/_FormLabel.scss +4 -0
  106. package/src/theme/ApiExplorer/FormLabel/index.tsx +43 -0
  107. package/src/theme/ApiExplorer/FormMultiSelect/index.tsx +40 -20
  108. package/src/theme/ApiExplorer/FormSelect/index.tsx +41 -15
  109. package/src/theme/ApiExplorer/FormTextInput/index.tsx +15 -1
  110. package/src/theme/ApiExplorer/MethodEndpoint/index.tsx +21 -0
  111. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +13 -2
  112. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +12 -1
  113. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +14 -2
  114. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +14 -2
  115. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +16 -3
  116. package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
  117. package/src/theme/ApiExplorer/ParamOptions/index.tsx +97 -11
  118. package/src/theme/ApiExplorer/ParamOptions/slice.ts +1 -1
  119. package/src/theme/ApiExplorer/Request/_Request.scss +11 -0
  120. package/src/theme/ApiExplorer/Request/index.tsx +22 -10
  121. package/src/theme/ApiExplorer/Request/makeRequest.ts +19 -3
  122. package/src/theme/ApiExplorer/Response/_Response.scss +11 -0
  123. package/src/theme/ApiExplorer/Response/index.tsx +37 -17
  124. package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +2 -3
  125. package/src/theme/ApiExplorer/Server/index.tsx +10 -3
  126. package/src/theme/ApiExplorer/Server/slice.ts +1 -1
  127. package/src/theme/ApiExplorer/buildPostmanRequest.ts +53 -6
  128. package/src/theme/ApiExplorer/index.tsx +2 -1
  129. package/src/theme/ApiItem/index.tsx +3 -2
  130. package/src/theme/ApiItem/store.ts +2 -0
  131. package/src/theme/ApiTabs/index.tsx +14 -19
  132. package/src/theme/DiscriminatorTabs/index.tsx +14 -19
  133. package/src/theme/MimeTabs/index.tsx +15 -19
  134. package/src/theme/OperationTabs/index.tsx +14 -19
  135. package/src/theme/ParamsDetails/index.tsx +2 -3
  136. package/src/theme/ParamsItem/index.tsx +25 -0
  137. package/src/theme/RequestSchema/index.tsx +144 -87
  138. package/src/theme/ResponseHeaders/index.tsx +1 -2
  139. package/src/theme/ResponseSchema/index.tsx +1 -1
  140. package/src/theme/Schema/index.tsx +112 -27
  141. package/src/theme/SchemaItem/index.tsx +6 -1
  142. package/src/theme/SchemaTabs/index.tsx +42 -21
  143. package/src/theme/StatusCodes/index.tsx +1 -1
  144. package/src/theme/styles.scss +1 -0
  145. package/src/theme/translationIds.ts +3 -0
  146. package/src/theme-classic.d.ts +25 -1
  147. package/src/types.d.ts +15 -52
  148. package/tsconfig.tsbuildinfo +1 -1
@@ -80,11 +80,11 @@ const Markdown_1 = __importDefault(require("@theme/Markdown"));
80
80
  const SchemaTabs_1 = __importDefault(require("@theme/SchemaTabs"));
81
81
  const TabItem_1 = __importDefault(require("@theme/TabItem"));
82
82
  const translationIds_1 = require("@theme/translationIds");
83
- const createSchemaExample_1 = require("docusaurus-plugin-openapi-docs/src/openapi/createSchemaExample");
83
+ const createSchemaExample_1 = require("docusaurus-plugin-openapi-docs/lib/openapi/createSchemaExample");
84
84
  const xml_formatter_1 = __importDefault(require("xml-formatter"));
85
- const slice_1 = require("./slice");
86
85
  const FormBodyItem_1 = __importDefault(require("./FormBodyItem"));
87
86
  const resolveSchemaWithSelections_1 = require("./resolveSchemaWithSelections");
87
+ const slice_1 = require("./slice");
88
88
  function BodyWrap({
89
89
  requestBodyMetadata,
90
90
  jsonRequestBodyExample,
@@ -140,6 +140,7 @@ function Body({
140
140
  const rawSchema = requestBodyMetadata?.content?.[contentType]?.schema;
141
141
  const example = requestBodyMetadata?.content?.[contentType]?.example;
142
142
  const examples = requestBodyMetadata?.content?.[contentType]?.examples;
143
+ const encoding = requestBodyMetadata?.content?.[contentType]?.encoding;
143
144
  // Resolve the schema based on user's anyOf/oneOf tab selections
144
145
  const schema = (0, react_1.useMemo)(() => {
145
146
  if (!rawSchema) return rawSchema;
@@ -365,22 +366,92 @@ function Body({
365
366
  return react_1.default.createElement(
366
367
  FormItem_1.default,
367
368
  { className: "openapi-explorer__form-item-body-container" },
368
- Object.entries(schema.properties ?? {}).map(([key, val]) => {
369
- return react_1.default.createElement(
370
- FormItem_1.default,
369
+ react_1.default.createElement(
370
+ SchemaTabs_1.default,
371
+ { className: "openapi-tabs__schema", lazy: true },
372
+ react_1.default.createElement(
373
+ TabItem_1.default,
371
374
  {
372
- key: key,
373
- label: key,
374
- required:
375
- Array.isArray(schema.required) && schema.required.includes(key),
375
+ label: (0, Translate_1.translate)({
376
+ id: translationIds_1.OPENAPI_BODY.EXAMPLE_FROM_SCHEMA,
377
+ message: "Example (from schema)",
378
+ }),
379
+ value: "Example (from schema)",
380
+ default: true,
376
381
  },
377
- react_1.default.createElement(FormBodyItem_1.default, {
378
- schemaObject: val,
379
- id: key,
380
- schema: schema,
382
+ Object.entries(schema.properties ?? {}).map(([key, val]) => {
383
+ return react_1.default.createElement(
384
+ FormItem_1.default,
385
+ { key: key },
386
+ react_1.default.createElement(FormBodyItem_1.default, {
387
+ schemaObject: val,
388
+ id: key,
389
+ schema: schema,
390
+ exampleValue: val.example,
391
+ label: key,
392
+ required:
393
+ Array.isArray(schema.required) &&
394
+ schema.required.includes(key),
395
+ fieldEncoding: encoding?.[key]?.contentType,
396
+ })
397
+ );
381
398
  })
382
- );
383
- })
399
+ ),
400
+ example &&
401
+ // @ts-ignore
402
+ react_1.default.createElement(
403
+ TabItem_1.default,
404
+ { label: "Example", value: "example" },
405
+ Object.entries(schema.properties ?? {}).map(
406
+ ([schemaKey, schemaVal]) => {
407
+ return react_1.default.createElement(
408
+ FormItem_1.default,
409
+ { key: schemaKey },
410
+ react_1.default.createElement(FormBodyItem_1.default, {
411
+ schemaObject: schemaVal,
412
+ id: schemaKey,
413
+ schema: schema,
414
+ exampleValue: example[schemaKey],
415
+ label: schemaKey,
416
+ required:
417
+ Array.isArray(schema.required) &&
418
+ schema.required.includes(schemaKey),
419
+ fieldEncoding: encoding?.[schemaKey]?.contentType,
420
+ })
421
+ );
422
+ }
423
+ )
424
+ ),
425
+ examples &&
426
+ Object.entries(examples).map(([key, value]) => {
427
+ return (
428
+ // @ts-ignore
429
+ react_1.default.createElement(
430
+ TabItem_1.default,
431
+ { label: key, value: key, key: key },
432
+ Object.entries(schema.properties ?? {}).map(
433
+ ([schemaKey, schemaVal]) => {
434
+ return react_1.default.createElement(
435
+ FormItem_1.default,
436
+ { key: schemaKey },
437
+ react_1.default.createElement(FormBodyItem_1.default, {
438
+ schemaObject: schemaVal,
439
+ id: schemaKey,
440
+ schema: schema,
441
+ exampleValue: value.value?.[schemaKey],
442
+ label: schemaKey,
443
+ required:
444
+ Array.isArray(schema.required) &&
445
+ schema.required.includes(schemaKey),
446
+ fieldEncoding: encoding?.[schemaKey]?.contentType,
447
+ })
448
+ );
449
+ }
450
+ )
451
+ )
452
+ );
453
+ })
454
+ )
384
455
  );
385
456
  }
386
457
  if (exampleBody) {
@@ -1,4 +1,4 @@
1
- import { SchemaObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
1
+ import type { SchemaObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
2
2
  export interface SchemaSelections {
3
3
  [schemaPath: string]: number;
4
4
  }