docusaurus-theme-openapi-docs 4.7.1 → 5.0.1

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 (129) 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/ApiCodeBlock/CopyButton/index.js +16 -5
  5. package/lib/theme/ApiExplorer/Authorization/index.js +12 -18
  6. package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.js +0 -4
  7. package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +5 -1
  8. package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +190 -37
  9. package/lib/theme/ApiExplorer/Body/index.js +84 -13
  10. package/lib/theme/ApiExplorer/Body/slice.d.ts +136 -544
  11. package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +2 -1
  12. package/lib/theme/ApiExplorer/CodeSnippets/index.js +4 -0
  13. package/lib/theme/ApiExplorer/CodeTabs/index.js +15 -16
  14. package/lib/theme/ApiExplorer/ContentType/index.js +7 -2
  15. package/lib/theme/ApiExplorer/EncodingSelection/slice.d.ts +17 -0
  16. package/lib/theme/ApiExplorer/EncodingSelection/slice.js +29 -0
  17. package/lib/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.d.ts +12 -0
  18. package/lib/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.js +39 -0
  19. package/lib/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
  20. package/lib/theme/ApiExplorer/FormItem/index.d.ts +1 -4
  21. package/lib/theme/ApiExplorer/FormItem/index.js +2 -26
  22. package/lib/theme/ApiExplorer/FormLabel/_FormLabel.scss +4 -0
  23. package/lib/theme/ApiExplorer/FormLabel/index.d.ts +9 -0
  24. package/lib/theme/ApiExplorer/FormLabel/index.js +50 -0
  25. package/lib/theme/ApiExplorer/FormMultiSelect/index.d.ts +4 -1
  26. package/lib/theme/ApiExplorer/FormMultiSelect/index.js +97 -19
  27. package/lib/theme/ApiExplorer/FormSelect/index.d.ts +6 -1
  28. package/lib/theme/ApiExplorer/FormSelect/index.js +96 -15
  29. package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +4 -1
  30. package/lib/theme/ApiExplorer/FormTextInput/index.js +71 -1
  31. package/lib/theme/ApiExplorer/MethodEndpoint/index.js +28 -0
  32. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.d.ts +4 -1
  33. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +11 -3
  34. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.d.ts +4 -1
  35. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +4 -1
  36. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.d.ts +4 -1
  37. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +6 -2
  38. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.d.ts +4 -1
  39. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +6 -2
  40. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.d.ts +4 -1
  41. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +8 -3
  42. package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
  43. package/lib/theme/ApiExplorer/ParamOptions/index.d.ts +10 -0
  44. package/lib/theme/ApiExplorer/ParamOptions/index.js +55 -5
  45. package/lib/theme/ApiExplorer/Request/_Request.scss +11 -0
  46. package/lib/theme/ApiExplorer/Request/index.js +19 -5
  47. package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +3 -1
  48. package/lib/theme/ApiExplorer/Request/makeRequest.js +19 -3
  49. package/lib/theme/ApiExplorer/Response/_Response.scss +11 -0
  50. package/lib/theme/ApiExplorer/Response/index.js +98 -12
  51. package/lib/theme/ApiExplorer/Server/index.d.ts +4 -1
  52. package/lib/theme/ApiExplorer/Server/index.js +6 -3
  53. package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +4 -1
  54. package/lib/theme/ApiExplorer/buildPostmanRequest.js +46 -5
  55. package/lib/theme/ApiExplorer/index.js +1 -0
  56. package/lib/theme/ApiExplorer/persistenceMiddleware.d.ts +2 -0
  57. package/lib/theme/ApiItem/hooks.d.ts +1 -0
  58. package/lib/theme/ApiItem/index.js +2 -1
  59. package/lib/theme/ApiItem/store.d.ts +6 -0
  60. package/lib/theme/ApiItem/store.js +11 -7
  61. package/lib/theme/ApiTabs/index.js +10 -11
  62. package/lib/theme/DiscriminatorTabs/index.js +10 -11
  63. package/lib/theme/MimeTabs/index.js +10 -11
  64. package/lib/theme/OperationTabs/index.js +10 -11
  65. package/lib/theme/ParamsItem/index.js +27 -0
  66. package/lib/theme/RequestSchema/index.js +172 -109
  67. package/lib/theme/ResponseHeaders/index.js +0 -1
  68. package/lib/theme/Schema/index.d.ts +1 -1
  69. package/lib/theme/Schema/index.js +91 -23
  70. package/lib/theme/SchemaItem/index.js +6 -1
  71. package/lib/theme/SchemaTabs/index.d.ts +1 -1
  72. package/lib/theme/SchemaTabs/index.js +31 -12
  73. package/lib/theme/styles.scss +1 -0
  74. package/lib/theme/translationIds.d.ts +3 -0
  75. package/lib/theme/translationIds.js +3 -0
  76. package/package.json +9 -8
  77. package/src/index.ts +2 -0
  78. package/src/markdown/schema.ts +69 -13
  79. package/src/theme/ApiExplorer/Accept/index.tsx +2 -1
  80. package/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.tsx +15 -3
  81. package/src/theme/ApiExplorer/Authorization/index.tsx +27 -33
  82. package/src/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.tsx +0 -5
  83. package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +115 -37
  84. package/src/theme/ApiExplorer/Body/index.tsx +85 -17
  85. package/src/theme/ApiExplorer/CodeSnippets/index.tsx +9 -1
  86. package/src/theme/ApiExplorer/CodeTabs/index.tsx +19 -19
  87. package/src/theme/ApiExplorer/ContentType/index.tsx +7 -4
  88. package/src/theme/ApiExplorer/EncodingSelection/slice.ts +31 -0
  89. package/src/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.ts +43 -0
  90. package/src/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
  91. package/src/theme/ApiExplorer/FormItem/index.tsx +2 -16
  92. package/src/theme/ApiExplorer/FormLabel/_FormLabel.scss +4 -0
  93. package/src/theme/ApiExplorer/FormLabel/index.tsx +43 -0
  94. package/src/theme/ApiExplorer/FormMultiSelect/index.tsx +40 -20
  95. package/src/theme/ApiExplorer/FormSelect/index.tsx +41 -15
  96. package/src/theme/ApiExplorer/FormTextInput/index.tsx +15 -1
  97. package/src/theme/ApiExplorer/MethodEndpoint/index.tsx +21 -0
  98. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +13 -2
  99. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +12 -1
  100. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +14 -2
  101. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +14 -2
  102. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +16 -3
  103. package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
  104. package/src/theme/ApiExplorer/ParamOptions/index.tsx +97 -11
  105. package/src/theme/ApiExplorer/Request/_Request.scss +11 -0
  106. package/src/theme/ApiExplorer/Request/index.tsx +20 -8
  107. package/src/theme/ApiExplorer/Request/makeRequest.ts +19 -3
  108. package/src/theme/ApiExplorer/Response/_Response.scss +11 -0
  109. package/src/theme/ApiExplorer/Response/index.tsx +35 -14
  110. package/src/theme/ApiExplorer/Server/index.tsx +10 -3
  111. package/src/theme/ApiExplorer/buildPostmanRequest.ts +52 -5
  112. package/src/theme/ApiExplorer/index.tsx +1 -0
  113. package/src/theme/ApiItem/index.tsx +2 -1
  114. package/src/theme/ApiItem/store.ts +2 -0
  115. package/src/theme/ApiTabs/index.tsx +14 -19
  116. package/src/theme/DiscriminatorTabs/index.tsx +14 -19
  117. package/src/theme/MimeTabs/index.tsx +15 -19
  118. package/src/theme/OperationTabs/index.tsx +14 -19
  119. package/src/theme/ParamsItem/index.tsx +25 -0
  120. package/src/theme/RequestSchema/index.tsx +141 -83
  121. package/src/theme/ResponseHeaders/index.tsx +1 -2
  122. package/src/theme/Schema/index.tsx +112 -27
  123. package/src/theme/SchemaItem/index.tsx +6 -1
  124. package/src/theme/SchemaTabs/index.tsx +42 -21
  125. package/src/theme/styles.scss +1 -0
  126. package/src/theme/translationIds.ts +3 -0
  127. package/src/theme-classic.d.ts +25 -1
  128. package/src/types.d.ts +7 -0
  129. package/tsconfig.tsbuildinfo +1 -1
@@ -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) {