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
@@ -8,6 +8,7 @@
8
8
  import React from "react";
9
9
 
10
10
  import BrowserOnly from "@docusaurus/BrowserOnly";
11
+ import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment";
11
12
  import { useTypedSelector } from "@theme/ApiItem/hooks";
12
13
 
13
14
  function colorForMethod(method: string) {
@@ -38,6 +39,26 @@ export interface Props {
38
39
  }
39
40
 
40
41
  function MethodEndpoint({ method, path, context }: Props) {
42
+ // During SSR, render without Redux store access to avoid "Cannot read properties
43
+ // of null (reading 'store')" errors caused by useSelector running outside a Provider.
44
+ if (!ExecutionEnvironment.canUseDOM) {
45
+ return (
46
+ <>
47
+ <pre className="openapi__method-endpoint">
48
+ <span className={"badge badge--" + colorForMethod(method)}>
49
+ {method === "event" ? "Webhook" : method.toUpperCase()}
50
+ </span>{" "}
51
+ {method !== "event" && (
52
+ <h2 className="openapi__method-endpoint-path">
53
+ {`${path.replace(/{([a-z0-9-_]+)}/gi, ":$1")}`}
54
+ </h2>
55
+ )}
56
+ </pre>
57
+ <div className="openapi__divider" />
58
+ </>
59
+ );
60
+ }
61
+
41
62
  let serverValue = useTypedSelector((state: any) => state.server.value);
42
63
  let serverUrlWithVariables = "";
43
64
 
@@ -10,6 +10,7 @@ import React, { useEffect, useState } from "react";
10
10
  import { translate } from "@docusaurus/Translate";
11
11
  import { ErrorMessage } from "@hookform/error-message";
12
12
  import { nanoid } from "@reduxjs/toolkit";
13
+ import FormLabel from "@theme/ApiExplorer/FormLabel";
13
14
  import FormSelect from "@theme/ApiExplorer/FormSelect";
14
15
  import FormTextInput from "@theme/ApiExplorer/FormTextInput";
15
16
  import { Param, setParam } from "@theme/ApiExplorer/ParamOptions/slice";
@@ -19,6 +20,9 @@ import { Controller, useFormContext } from "react-hook-form";
19
20
 
20
21
  export interface ParamProps {
21
22
  param: Param;
23
+ label?: string;
24
+ type?: string;
25
+ required?: boolean;
22
26
  }
23
27
 
24
28
  function ArrayItem({
@@ -31,6 +35,7 @@ function ArrayItem({
31
35
  if (param.schema?.items?.type === "boolean") {
32
36
  return (
33
37
  <FormSelect
38
+ ariaLabel={param.description || param.name}
34
39
  options={["---", "true", "false"]}
35
40
  onChange={(e: React.ChangeEvent<HTMLSelectElement>) => {
36
41
  const val = e.target.value;
@@ -52,7 +57,12 @@ function ArrayItem({
52
57
  );
53
58
  }
54
59
 
55
- export default function ParamArrayFormItem({ param }: ParamProps) {
60
+ export default function ParamArrayFormItem({
61
+ param,
62
+ label,
63
+ type,
64
+ required,
65
+ }: ParamProps) {
56
66
  const [items, setItems] = useState<{ id: string; value?: string }[]>([]);
57
67
  const dispatch = useTypedDispatch();
58
68
 
@@ -122,6 +132,7 @@ export default function ParamArrayFormItem({ param }: ParamProps) {
122
132
 
123
133
  return (
124
134
  <>
135
+ {label && <FormLabel label={label} type={type} required={required} />}
125
136
  <Controller
126
137
  control={control}
127
138
  rules={{
@@ -145,6 +156,7 @@ export default function ParamArrayFormItem({ param }: ParamProps) {
145
156
  <button
146
157
  className="openapi-explorer__delete-btn"
147
158
  onClick={handleDeleteItem(item)}
159
+ aria-label="Delete"
148
160
  >
149
161
  <svg
150
162
  focusable="false"
@@ -157,7 +169,6 @@ export default function ParamArrayFormItem({ param }: ParamProps) {
157
169
  aria-hidden="true"
158
170
  >
159
171
  <path d="M24 9.4L22.6 8 16 14.6 9.4 8 8 9.4 14.6 16 8 22.6 9.4 24 16 17.4 22.6 24 24 22.6 17.4 16 24 9.4z"></path>
160
- <title>Delete</title>
161
172
  </svg>
162
173
  </button>
163
174
  </div>
@@ -17,9 +17,17 @@ import { Controller, useFormContext } from "react-hook-form";
17
17
 
18
18
  export interface ParamProps {
19
19
  param: Param;
20
+ label?: string;
21
+ type?: string;
22
+ required?: boolean;
20
23
  }
21
24
 
22
- export default function ParamBooleanFormItem({ param }: ParamProps) {
25
+ export default function ParamBooleanFormItem({
26
+ param,
27
+ label,
28
+ type,
29
+ required,
30
+ }: ParamProps) {
23
31
  const dispatch = useTypedDispatch();
24
32
 
25
33
  const {
@@ -44,6 +52,9 @@ export default function ParamBooleanFormItem({ param }: ParamProps) {
44
52
  name="paramBoolean"
45
53
  render={({ field: { onChange } }) => (
46
54
  <FormSelect
55
+ label={label}
56
+ type={type}
57
+ required={required}
47
58
  options={["---", "true", "false"]}
48
59
  onChange={(e: React.ChangeEvent<HTMLSelectElement>) => {
49
60
  const val = e.target.value;
@@ -10,6 +10,7 @@ import React from "react";
10
10
  import { translate } from "@docusaurus/Translate";
11
11
  import { ErrorMessage } from "@hookform/error-message";
12
12
  import FormMultiSelect from "@theme/ApiExplorer/FormMultiSelect";
13
+ import { getSchemaEnum } from "@theme/ApiExplorer/ParamOptions";
13
14
  import { Param, setParam } from "@theme/ApiExplorer/ParamOptions/slice";
14
15
  import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
15
16
  import { OPENAPI_FORM } from "@theme/translationIds";
@@ -17,9 +18,17 @@ import { Controller, useFormContext } from "react-hook-form";
17
18
 
18
19
  export interface ParamProps {
19
20
  param: Param;
21
+ label?: string;
22
+ type?: string;
23
+ required?: boolean;
20
24
  }
21
25
 
22
- export default function ParamMultiSelectFormItem({ param }: ParamProps) {
26
+ export default function ParamMultiSelectFormItem({
27
+ param,
28
+ label,
29
+ type,
30
+ required,
31
+ }: ParamProps) {
23
32
  const {
24
33
  control,
25
34
  formState: { errors },
@@ -29,7 +38,7 @@ export default function ParamMultiSelectFormItem({ param }: ParamProps) {
29
38
 
30
39
  const dispatch = useTypedDispatch();
31
40
 
32
- const options = param.schema?.items?.enum ?? [];
41
+ const options = getSchemaEnum(param.schema?.items) ?? [];
33
42
 
34
43
  const pathParams = useTypedSelector((state: any) => state.params.path);
35
44
  const queryParams = useTypedSelector((state: any) => state.params.query);
@@ -74,6 +83,9 @@ export default function ParamMultiSelectFormItem({ param }: ParamProps) {
74
83
  name="paramMultiSelect"
75
84
  render={({ field: { onChange } }) => (
76
85
  <FormMultiSelect
86
+ label={label}
87
+ type={type}
88
+ required={required}
77
89
  options={options as string[]}
78
90
  onChange={(e: any) => handleChange(e, onChange)}
79
91
  showErrors={!!showErrorMessage}
@@ -10,6 +10,7 @@ import React from "react";
10
10
  import { translate } from "@docusaurus/Translate";
11
11
  import { ErrorMessage } from "@hookform/error-message";
12
12
  import FormSelect from "@theme/ApiExplorer/FormSelect";
13
+ import { getSchemaEnum } from "@theme/ApiExplorer/ParamOptions";
13
14
  import { Param, setParam } from "@theme/ApiExplorer/ParamOptions/slice";
14
15
  import { useTypedDispatch } from "@theme/ApiItem/hooks";
15
16
  import { OPENAPI_FORM } from "@theme/translationIds";
@@ -17,9 +18,17 @@ import { Controller, useFormContext } from "react-hook-form";
17
18
 
18
19
  export interface ParamProps {
19
20
  param: Param;
21
+ label?: string;
22
+ type?: string;
23
+ required?: boolean;
20
24
  }
21
25
 
22
- export default function ParamSelectFormItem({ param }: ParamProps) {
26
+ export default function ParamSelectFormItem({
27
+ param,
28
+ label,
29
+ type,
30
+ required,
31
+ }: ParamProps) {
23
32
  const {
24
33
  control,
25
34
  formState: { errors },
@@ -29,7 +38,7 @@ export default function ParamSelectFormItem({ param }: ParamProps) {
29
38
 
30
39
  const dispatch = useTypedDispatch();
31
40
 
32
- const options = param.schema?.enum ?? [];
41
+ const options = getSchemaEnum(param.schema) ?? [];
33
42
 
34
43
  return (
35
44
  <>
@@ -46,6 +55,9 @@ export default function ParamSelectFormItem({ param }: ParamProps) {
46
55
  name="paramSelect"
47
56
  render={({ field: { onChange } }) => (
48
57
  <FormSelect
58
+ label={label}
59
+ type={type}
60
+ required={required}
49
61
  options={["---", ...(options as string[])]}
50
62
  onChange={(e: React.ChangeEvent<HTMLSelectElement>) => {
51
63
  const val = e.target.value;
@@ -13,12 +13,23 @@ import { useTypedDispatch } from "@theme/ApiItem/hooks";
13
13
 
14
14
  export interface ParamProps {
15
15
  param: Param;
16
+ label?: string;
17
+ type?: string;
18
+ required?: boolean;
16
19
  }
17
20
 
18
- export default function ParamTextFormItem({ param }: ParamProps) {
21
+ export default function ParamTextFormItem({
22
+ param,
23
+ label,
24
+ type,
25
+ required,
26
+ }: ParamProps) {
19
27
  const dispatch = useTypedDispatch();
20
28
  return (
21
29
  <FormTextInput
30
+ label={label}
31
+ type={type}
32
+ required={required}
22
33
  isRequired={param.required}
23
34
  paramName={param.name}
24
35
  placeholder={param.description || param.name}
@@ -27,9 +38,11 @@ export default function ParamTextFormItem({ param }: ParamProps) {
27
38
  setParam({
28
39
  ...param,
29
40
  value:
30
- param.in === "path" || param.in === "query"
41
+ param.in === "path"
31
42
  ? e.target.value.replace(/\s/g, "%20")
32
- : e.target.value,
43
+ : param.in === "query"
44
+ ? encodeURIComponent(e.target.value)
45
+ : e.target.value,
33
46
  })
34
47
  )
35
48
  }
@@ -63,15 +63,10 @@
63
63
  margin-top: calc(var(--ifm-pre-padding) / 2);
64
64
  background-color: var(--openapi-input-background);
65
65
  border: none;
66
- outline: none;
67
66
  color: var(--ifm-pre-color);
68
67
  border-radius: 4px;
69
68
  margin-left: 4px;
70
69
 
71
- &:focus {
72
- outline: 0;
73
- }
74
-
75
70
  &:active {
76
71
  box-shadow: inset 0px 0px 0px 2px var(--openapi-input-border);
77
72
  }
@@ -102,10 +97,6 @@
102
97
  background-color: var(--openapi-input-border);
103
98
  }
104
99
 
105
- &:focus {
106
- outline: 0;
107
- }
108
-
109
100
  &:active {
110
101
  box-shadow:
111
102
  inset 0 0 0 1px var(--openapi-input-border),
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
- import React, { useState } from "react";
8
+ import React, { useState, useId } from "react";
9
9
 
10
10
  import { translate } from "@docusaurus/Translate";
11
11
  import FormItem from "@theme/ApiExplorer/FormItem";
@@ -19,36 +19,117 @@ import { OPENAPI_PARAM_OPTIONS } from "@theme/translationIds";
19
19
 
20
20
  import { Param } from "./slice";
21
21
 
22
+ export interface LabelProps {
23
+ label?: string;
24
+ type?: string;
25
+ required?: boolean;
26
+ }
27
+
22
28
  export interface ParamProps {
23
29
  param: Param;
24
30
  }
25
31
 
26
- function ParamOption({ param }: ParamProps) {
27
- if (param.schema?.type === "array" && param.schema.items?.enum) {
28
- return <ParamMultiSelectFormItem param={param} />;
32
+ /**
33
+ * Extracts enum values from a schema, including when wrapped in allOf.
34
+ * This handles cases where an enum is referenced via allOf for composition.
35
+ */
36
+ export function getSchemaEnum(schema: any): any[] | undefined {
37
+ // Direct enum on schema
38
+ if (schema?.enum) {
39
+ return schema.enum;
40
+ }
41
+
42
+ // Enum inside allOf - check each item
43
+ if (schema?.allOf && Array.isArray(schema.allOf)) {
44
+ for (const item of schema.allOf) {
45
+ if (item.enum) {
46
+ return item.enum;
47
+ }
48
+ }
49
+ }
50
+
51
+ // const is semantically a single-value enum
52
+ if (schema?.const !== undefined) {
53
+ return [schema.const];
54
+ }
55
+
56
+ return undefined;
57
+ }
58
+
59
+ function ParamOption({
60
+ param,
61
+ label,
62
+ type,
63
+ required,
64
+ }: ParamProps & LabelProps) {
65
+ const schemaEnum = getSchemaEnum(param.schema);
66
+ const itemsEnum = getSchemaEnum(param.schema?.items);
67
+
68
+ if (param.schema?.type === "array" && itemsEnum) {
69
+ return (
70
+ <ParamMultiSelectFormItem
71
+ param={param}
72
+ label={label}
73
+ type={type}
74
+ required={required}
75
+ />
76
+ );
29
77
  }
30
78
 
31
79
  if (param.schema?.type === "array") {
32
- return <ParamArrayFormItem param={param} />;
80
+ return (
81
+ <ParamArrayFormItem
82
+ param={param}
83
+ label={label}
84
+ type={type}
85
+ required={required}
86
+ />
87
+ );
33
88
  }
34
89
 
35
- if (param.schema?.enum) {
36
- return <ParamSelectFormItem param={param} />;
90
+ if (schemaEnum) {
91
+ return (
92
+ <ParamSelectFormItem
93
+ param={param}
94
+ label={label}
95
+ type={type}
96
+ required={required}
97
+ />
98
+ );
37
99
  }
38
100
 
39
101
  if (param.schema?.type === "boolean") {
40
- return <ParamBooleanFormItem param={param} />;
102
+ return (
103
+ <ParamBooleanFormItem
104
+ param={param}
105
+ label={label}
106
+ type={type}
107
+ required={required}
108
+ />
109
+ );
41
110
  }
42
111
 
43
112
  // integer, number, string, int32, int64, float, double, object, byte, binary,
44
113
  // date-time, date, password
45
- return <ParamTextFormItem param={param} />;
114
+ return (
115
+ <ParamTextFormItem
116
+ param={param}
117
+ label={label}
118
+ type={type}
119
+ required={required}
120
+ />
121
+ );
46
122
  }
47
123
 
48
124
  function ParamOptionWrapper({ param }: ParamProps) {
49
125
  return (
50
- <FormItem label={param.name} type={param.in} required={param.required}>
51
- <ParamOption param={param} />
126
+ <FormItem>
127
+ <ParamOption
128
+ param={param}
129
+ label={param.name}
130
+ type={param.in}
131
+ required={param.required}
132
+ />
52
133
  </FormItem>
53
134
  );
54
135
  }
@@ -56,6 +137,8 @@ function ParamOptionWrapper({ param }: ParamProps) {
56
137
  function ParamOptions() {
57
138
  const [showOptional, setShowOptional] = useState(false);
58
139
 
140
+ const optionalId = useId();
141
+
59
142
  const pathParams = useTypedSelector((state: any) => state.params.path);
60
143
  const queryParams = useTypedSelector((state: any) => state.params.query);
61
144
  const cookieParams = useTypedSelector((state: any) => state.params.cookie);
@@ -84,6 +167,8 @@ function ParamOptions() {
84
167
  <button
85
168
  type="button"
86
169
  className="openapi-explorer__show-more-btn"
170
+ aria-expanded={showOptional}
171
+ aria-controls={optionalId}
87
172
  onClick={() => setShowOptional((prev) => !prev)}
88
173
  >
89
174
  <span
@@ -137,6 +222,7 @@ function ParamOptions() {
137
222
  ? "openapi-explorer__show-options"
138
223
  : "openapi-explorer__hide-options"
139
224
  }
225
+ id={optionalId}
140
226
  >
141
227
  {optionalParams.map((param) => (
142
228
  <ParamOptionWrapper
@@ -48,6 +48,17 @@
48
48
  }
49
49
 
50
50
  .openapi-explorer__expand-details-btn {
51
+ -webkit-appearance: none;
52
+ -moz-appearance: none;
53
+ appearance: none;
54
+ padding: 0;
55
+ cursor: pointer;
56
+ border: 0px solid transparent;
57
+ background-color: transparent;
58
+ text-transform: inherit;
59
+ font-weight: inherit;
60
+ font-size: inherit;
61
+
51
62
  &:hover {
52
63
  cursor: pointer;
53
64
  }
@@ -6,7 +6,7 @@
6
6
  * ========================================================================== */
7
7
 
8
8
  // @ts-nocheck
9
- import React, { useState } from "react";
9
+ import React, { useState, useId } from "react";
10
10
 
11
11
  import { useDoc } from "@docusaurus/plugin-content-docs/client";
12
12
  import { translate } from "@docusaurus/Translate";
@@ -25,6 +25,7 @@ import {
25
25
  clearHeaders,
26
26
  } from "@theme/ApiExplorer/Response/slice";
27
27
  import Server from "@theme/ApiExplorer/Server";
28
+ import { useResolvedEncoding } from "@theme/ApiExplorer/EncodingSelection/useResolvedEncoding";
28
29
  import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
29
30
  import { OPENAPI_REQUEST } from "@theme/translationIds";
30
31
  import type { ParameterObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
@@ -43,6 +44,7 @@ function Request({ item }: { item: ApiItem }) {
43
44
  const { siteConfig } = useDocusaurusContext();
44
45
  const themeConfig = siteConfig.themeConfig as ThemeConfig;
45
46
  const requestTimeout = themeConfig.api?.requestTimeout;
47
+ const requestCredentials = themeConfig.api?.requestCredentials;
46
48
  // Frontmatter proxy (per-spec) takes precedence over theme config proxy (site-wide)
47
49
  const proxy = frontMatterProxy ?? themeConfig.api?.proxy;
48
50
 
@@ -66,6 +68,8 @@ function Request({ item }: { item: ApiItem }) {
66
68
  const [expandParams, setExpandParams] = useState(true);
67
69
  const [expandServer, setExpandServer] = useState(true);
68
70
 
71
+ const serverLabelId = useId();
72
+
69
73
  const allParams = [
70
74
  ...pathParams,
71
75
  ...queryParams,
@@ -73,6 +77,8 @@ function Request({ item }: { item: ApiItem }) {
73
77
  ...headerParams,
74
78
  ];
75
79
 
80
+ const encoding = useResolvedEncoding(item.requestBody);
81
+
76
82
  const postmanRequest = buildPostmanRequest(postman, {
77
83
  queryParams,
78
84
  pathParams,
@@ -83,6 +89,7 @@ function Request({ item }: { item: ApiItem }) {
83
89
  body,
84
90
  server,
85
91
  auth,
92
+ encoding,
86
93
  });
87
94
 
88
95
  const delay = (ms: number) =>
@@ -99,7 +106,7 @@ function Request({ item }: { item: ApiItem }) {
99
106
  (param: { in: "path" | "query" | "header" | "cookie" }) => {
100
107
  const paramType = param.in;
101
108
  const paramsArray: ParameterObject[] = paramsObject[paramType];
102
- paramsArray.push(param as ParameterObject);
109
+ paramsArray?.push(param as ParameterObject);
103
110
  }
104
111
  );
105
112
 
@@ -171,7 +178,9 @@ function Request({ item }: { item: ApiItem }) {
171
178
  postmanRequest,
172
179
  proxy,
173
180
  body,
174
- requestTimeout
181
+ requestTimeout,
182
+ requestCredentials,
183
+ encoding
175
184
  );
176
185
  if (res.headers.get("content-type")?.includes("text/event-stream")) {
177
186
  await handleEventStream(res);
@@ -249,7 +258,8 @@ function Request({ item }: { item: ApiItem }) {
249
258
  })}
250
259
  </span>
251
260
  {allDetailsExpanded ? (
252
- <span
261
+ <button
262
+ type="button"
253
263
  className="openapi-explorer__expand-details-btn"
254
264
  onClick={collapseAllDetails}
255
265
  >
@@ -257,9 +267,10 @@ function Request({ item }: { item: ApiItem }) {
257
267
  id: OPENAPI_REQUEST.COLLAPSE_ALL,
258
268
  message: "Collapse all",
259
269
  })}
260
- </span>
270
+ </button>
261
271
  ) : (
262
- <span
272
+ <button
273
+ type="button"
263
274
  className="openapi-explorer__expand-details-btn"
264
275
  onClick={expandAllDetails}
265
276
  >
@@ -267,7 +278,7 @@ function Request({ item }: { item: ApiItem }) {
267
278
  id: OPENAPI_REQUEST.EXPAND_ALL,
268
279
  message: "Expand all",
269
280
  })}
270
- </span>
281
+ </button>
271
282
  )}
272
283
  </div>
273
284
  <div className="openapi-explorer__details-outer-container">
@@ -277,6 +288,7 @@ function Request({ item }: { item: ApiItem }) {
277
288
  className="openapi-explorer__details-container"
278
289
  >
279
290
  <summary
291
+ id={serverLabelId}
280
292
  className="openapi-explorer__details-summary"
281
293
  onClick={(e) => {
282
294
  e.preventDefault();
@@ -288,7 +300,7 @@ function Request({ item }: { item: ApiItem }) {
288
300
  message: "Base URL",
289
301
  })}
290
302
  </summary>
291
- <Server />
303
+ <Server labelId={serverLabelId} />
292
304
  </details>
293
305
  )}
294
306
  {showAuth && (
@@ -114,7 +114,9 @@ async function makeRequest(
114
114
  request: sdk.Request,
115
115
  proxy: string | undefined,
116
116
  _body: Body,
117
- timeout: number = DEFAULT_REQUEST_TIMEOUT
117
+ timeout: number = DEFAULT_REQUEST_TIMEOUT,
118
+ credentials?: RequestCredentials,
119
+ encoding?: Record<string, { contentType?: string }>
118
120
  ) {
119
121
  const headers = request.toJSON().header;
120
122
 
@@ -226,12 +228,25 @@ async function makeRequest(
226
228
  const members = (request.body as any)?.formdata?.members;
227
229
  if (Array.isArray(members)) {
228
230
  for (const data of members) {
231
+ const partContentType = encoding?.[data.key]?.contentType
232
+ ?.split(",")[0]
233
+ .trim();
229
234
  if (data.key && data.value.content) {
230
- myBody.append(data.key, data.value.content);
235
+ const blob = partContentType
236
+ ? new Blob([data.value.content], { type: partContentType })
237
+ : data.value.content;
238
+ myBody.append(data.key, blob);
231
239
  }
232
240
  // handle generic key-value payload
233
241
  if (data.key && typeof data.value === "string") {
234
- myBody.append(data.key, data.value);
242
+ if (partContentType) {
243
+ myBody.append(
244
+ data.key,
245
+ new Blob([data.value], { type: partContentType })
246
+ );
247
+ } else {
248
+ myBody.append(data.key, data.value);
249
+ }
235
250
  }
236
251
  }
237
252
  }
@@ -252,6 +267,7 @@ async function makeRequest(
252
267
  method: request.method,
253
268
  headers: myHeaders,
254
269
  body: myBody,
270
+ ...(credentials && { credentials }),
255
271
  };
256
272
 
257
273
  let finalUrl = request.url.toString();
@@ -43,6 +43,17 @@
43
43
  }
44
44
 
45
45
  .openapi-explorer__response-clear-btn {
46
+ -webkit-appearance: none;
47
+ -moz-appearance: none;
48
+ appearance: none;
49
+ padding: 0;
50
+ cursor: pointer;
51
+ border: 0px solid transparent;
52
+ background-color: transparent;
53
+ text-transform: inherit;
54
+ font-weight: inherit;
55
+ font-size: inherit;
56
+
46
57
  &:hover {
47
58
  cursor: pointer;
48
59
  }