docusaurus-theme-openapi-docs 0.0.0-1110 → 0.0.0-1151

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 (70) hide show
  1. package/lib/index.js +2 -0
  2. package/lib/theme/ApiExplorer/Accept/index.js +2 -1
  3. package/lib/theme/ApiExplorer/Authorization/index.js +12 -18
  4. package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +3 -1
  5. package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +61 -29
  6. package/lib/theme/ApiExplorer/Body/index.js +4 -6
  7. package/lib/theme/ApiExplorer/Body/slice.d.ts +136 -544
  8. package/lib/theme/ApiExplorer/ContentType/index.js +2 -1
  9. package/lib/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
  10. package/lib/theme/ApiExplorer/FormItem/index.d.ts +1 -4
  11. package/lib/theme/ApiExplorer/FormItem/index.js +2 -26
  12. package/lib/theme/ApiExplorer/FormLabel/_FormLabel.scss +4 -0
  13. package/lib/theme/ApiExplorer/FormLabel/index.d.ts +9 -0
  14. package/lib/theme/ApiExplorer/FormLabel/index.js +50 -0
  15. package/lib/theme/ApiExplorer/FormMultiSelect/index.d.ts +4 -1
  16. package/lib/theme/ApiExplorer/FormMultiSelect/index.js +97 -19
  17. package/lib/theme/ApiExplorer/FormSelect/index.d.ts +6 -1
  18. package/lib/theme/ApiExplorer/FormSelect/index.js +96 -15
  19. package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +4 -1
  20. package/lib/theme/ApiExplorer/FormTextInput/index.js +71 -1
  21. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.d.ts +4 -1
  22. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +11 -3
  23. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.d.ts +4 -1
  24. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +4 -1
  25. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.d.ts +4 -1
  26. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +4 -1
  27. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.d.ts +4 -1
  28. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +4 -1
  29. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.d.ts +4 -1
  30. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +4 -1
  31. package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
  32. package/lib/theme/ApiExplorer/ParamOptions/index.d.ts +5 -0
  33. package/lib/theme/ApiExplorer/ParamOptions/index.js +27 -3
  34. package/lib/theme/ApiExplorer/Request/_Request.scss +11 -0
  35. package/lib/theme/ApiExplorer/Request/index.js +10 -4
  36. package/lib/theme/ApiExplorer/Response/_Response.scss +11 -0
  37. package/lib/theme/ApiExplorer/Response/index.js +2 -1
  38. package/lib/theme/ApiExplorer/Server/index.d.ts +4 -1
  39. package/lib/theme/ApiExplorer/Server/index.js +6 -3
  40. package/lib/theme/ApiItem/index.js +1 -1
  41. package/lib/theme/styles.scss +1 -0
  42. package/package.json +4 -3
  43. package/src/index.ts +2 -0
  44. package/src/theme/ApiExplorer/Accept/index.tsx +2 -1
  45. package/src/theme/ApiExplorer/Authorization/index.tsx +27 -33
  46. package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +44 -26
  47. package/src/theme/ApiExplorer/Body/index.tsx +7 -8
  48. package/src/theme/ApiExplorer/ContentType/index.tsx +2 -1
  49. package/src/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
  50. package/src/theme/ApiExplorer/FormItem/index.tsx +2 -16
  51. package/src/theme/ApiExplorer/FormLabel/_FormLabel.scss +4 -0
  52. package/src/theme/ApiExplorer/FormLabel/index.tsx +43 -0
  53. package/src/theme/ApiExplorer/FormMultiSelect/index.tsx +40 -20
  54. package/src/theme/ApiExplorer/FormSelect/index.tsx +41 -15
  55. package/src/theme/ApiExplorer/FormTextInput/index.tsx +15 -1
  56. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +13 -2
  57. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +12 -1
  58. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +12 -1
  59. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +12 -1
  60. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +12 -1
  61. package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
  62. package/src/theme/ApiExplorer/ParamOptions/index.tsx +65 -9
  63. package/src/theme/ApiExplorer/Request/_Request.scss +11 -0
  64. package/src/theme/ApiExplorer/Request/index.tsx +12 -7
  65. package/src/theme/ApiExplorer/Response/_Response.scss +11 -0
  66. package/src/theme/ApiExplorer/Response/index.tsx +3 -2
  67. package/src/theme/ApiExplorer/Server/index.tsx +10 -3
  68. package/src/theme/ApiItem/index.tsx +1 -1
  69. package/src/theme/styles.scss +1 -0
  70. package/tsconfig.tsbuildinfo +1 -1
package/lib/index.js CHANGED
@@ -38,6 +38,7 @@ function docusaurusThemeOpenAPI() {
38
38
  resolve: {
39
39
  fallback: {
40
40
  buffer: require.resolve("buffer/"),
41
+ path: require.resolve("path-browserify"),
41
42
  },
42
43
  },
43
44
  plugins: [
@@ -67,6 +68,7 @@ function docusaurusThemeOpenAPI() {
67
68
  resolve: {
68
69
  fallback: {
69
70
  buffer: require.resolve("buffer/"),
71
+ path: require.resolve("path-browserify"),
70
72
  },
71
73
  },
72
74
  plugins: [
@@ -27,8 +27,9 @@ function Accept() {
27
27
  }
28
28
  return react_1.default.createElement(
29
29
  FormItem_1.default,
30
- { label: "Accept" },
30
+ null,
31
31
  react_1.default.createElement(FormSelect_1.default, {
32
+ label: "Accept",
32
33
  value: value,
33
34
  options: options,
34
35
  onChange: (e) => dispatch((0, slice_1.setAccept)(e.target.value)),
@@ -39,13 +39,12 @@ function Authorization() {
39
39
  optionKeys.length > 1 &&
40
40
  react_1.default.createElement(
41
41
  FormItem_1.default,
42
- {
42
+ null,
43
+ react_1.default.createElement(FormSelect_1.default, {
43
44
  label: (0, Translate_1.translate)({
44
45
  id: translationIds_1.OPENAPI_AUTH.SECURITY_SCHEME,
45
46
  message: "Security Scheme",
46
47
  }),
47
- },
48
- react_1.default.createElement(FormSelect_1.default, {
49
48
  options: optionKeys,
50
49
  value: selected,
51
50
  onChange: (e) => {
@@ -57,14 +56,12 @@ function Authorization() {
57
56
  if (a.type === "http" && a.scheme === "bearer") {
58
57
  return react_1.default.createElement(
59
58
  FormItem_1.default,
60
- {
59
+ { key: a.key + "-bearer" },
60
+ react_1.default.createElement(FormTextInput_1.default, {
61
61
  label: (0, Translate_1.translate)({
62
62
  id: translationIds_1.OPENAPI_AUTH.BEARER_TOKEN,
63
63
  message: "Bearer Token",
64
64
  }),
65
- key: a.key + "-bearer",
66
- },
67
- react_1.default.createElement(FormTextInput_1.default, {
68
65
  placeholder: (0, Translate_1.translate)({
69
66
  id: translationIds_1.OPENAPI_AUTH.BEARER_TOKEN,
70
67
  message: "Bearer Token",
@@ -87,14 +84,12 @@ function Authorization() {
87
84
  if (a.type === "oauth2") {
88
85
  return react_1.default.createElement(
89
86
  FormItem_1.default,
90
- {
87
+ { key: a.key + "-oauth2" },
88
+ react_1.default.createElement(FormTextInput_1.default, {
91
89
  label: (0, Translate_1.translate)({
92
90
  id: translationIds_1.OPENAPI_AUTH.BEARER_TOKEN,
93
91
  message: "Bearer Token",
94
92
  }),
95
- key: a.key + "-oauth2",
96
- },
97
- react_1.default.createElement(FormTextInput_1.default, {
98
93
  placeholder: (0, Translate_1.translate)({
99
94
  id: translationIds_1.OPENAPI_AUTH.BEARER_TOKEN,
100
95
  message: "Bearer Token",
@@ -120,13 +115,12 @@ function Authorization() {
120
115
  { key: a.key + "-basic" },
121
116
  react_1.default.createElement(
122
117
  FormItem_1.default,
123
- {
118
+ null,
119
+ react_1.default.createElement(FormTextInput_1.default, {
124
120
  label: (0, Translate_1.translate)({
125
121
  id: translationIds_1.OPENAPI_AUTH.USERNAME,
126
122
  message: "Username",
127
123
  }),
128
- },
129
- react_1.default.createElement(FormTextInput_1.default, {
130
124
  placeholder: (0, Translate_1.translate)({
131
125
  id: translationIds_1.OPENAPI_AUTH.USERNAME,
132
126
  message: "Username",
@@ -146,13 +140,12 @@ function Authorization() {
146
140
  ),
147
141
  react_1.default.createElement(
148
142
  FormItem_1.default,
149
- {
143
+ null,
144
+ react_1.default.createElement(FormTextInput_1.default, {
150
145
  label: (0, Translate_1.translate)({
151
146
  id: translationIds_1.OPENAPI_AUTH.PASSWORD,
152
147
  message: "Password",
153
148
  }),
154
- },
155
- react_1.default.createElement(FormTextInput_1.default, {
156
149
  placeholder: (0, Translate_1.translate)({
157
150
  id: translationIds_1.OPENAPI_AUTH.PASSWORD,
158
151
  message: "Password",
@@ -176,8 +169,9 @@ function Authorization() {
176
169
  if (a.type === "apiKey") {
177
170
  return react_1.default.createElement(
178
171
  FormItem_1.default,
179
- { label: `${a.key}`, key: a.key + "-apikey" },
172
+ { key: a.key + "-apikey" },
180
173
  react_1.default.createElement(FormTextInput_1.default, {
174
+ label: `${a.key}`,
181
175
  placeholder: `${a.key}`,
182
176
  password: true,
183
177
  value: data[a.key].apiKey ?? "",
@@ -4,6 +4,8 @@ interface FormBodyItemProps {
4
4
  schemaObject: SchemaObject;
5
5
  id: string;
6
6
  schema: SchemaObject;
7
+ label?: string;
8
+ required?: boolean;
7
9
  }
8
- export default function FormBodyItem({ schemaObject, id, schema, }: FormBodyItemProps): React.JSX.Element;
10
+ export default function FormBodyItem({ schemaObject, id, schema, label, required, }: FormBodyItemProps): React.JSX.Element;
9
11
  export {};
@@ -16,6 +16,7 @@ const react_1 = __importDefault(require("react"));
16
16
  const FormFileUpload_1 = __importDefault(
17
17
  require("@theme/ApiExplorer/FormFileUpload")
18
18
  );
19
+ const FormLabel_1 = __importDefault(require("@theme/ApiExplorer/FormLabel"));
19
20
  const FormSelect_1 = __importDefault(require("@theme/ApiExplorer/FormSelect"));
20
21
  const FormTextInput_1 = __importDefault(
21
22
  require("@theme/ApiExplorer/FormTextInput")
@@ -26,36 +27,54 @@ const FileArrayFormBodyItem_1 = __importDefault(
26
27
  require("../FileArrayFormBodyItem")
27
28
  );
28
29
  const slice_1 = require("../slice");
29
- function FormBodyItem({ schemaObject, id, schema }) {
30
+ function FormBodyItem({ schemaObject, id, schema, label, required }) {
30
31
  const dispatch = (0, hooks_1.useTypedDispatch)();
31
32
  if (
32
33
  schemaObject.type === "array" &&
33
34
  schemaObject.items?.format === "binary"
34
35
  ) {
35
- return react_1.default.createElement(FileArrayFormBodyItem_1.default, {
36
- id: id,
37
- description: schemaObject.description,
38
- });
36
+ return react_1.default.createElement(
37
+ react_1.default.Fragment,
38
+ null,
39
+ label &&
40
+ react_1.default.createElement(FormLabel_1.default, {
41
+ label: label,
42
+ required: required,
43
+ }),
44
+ react_1.default.createElement(FileArrayFormBodyItem_1.default, {
45
+ id: id,
46
+ description: schemaObject.description,
47
+ })
48
+ );
39
49
  }
40
50
  if (schemaObject.format === "binary") {
41
- return react_1.default.createElement(FormFileUpload_1.default, {
42
- placeholder: schemaObject.description || id,
43
- onChange: (file) => {
44
- if (file === undefined) {
45
- dispatch((0, slice_1.clearFormBodyKey)(id));
46
- return;
47
- }
48
- dispatch(
49
- (0, slice_1.setFileFormBody)({
50
- key: id,
51
- value: {
52
- src: `/path/to/${file.name}`,
53
- content: file,
54
- },
55
- })
56
- );
57
- },
58
- });
51
+ return react_1.default.createElement(
52
+ react_1.default.Fragment,
53
+ null,
54
+ label &&
55
+ react_1.default.createElement(FormLabel_1.default, {
56
+ label: label,
57
+ required: required,
58
+ }),
59
+ react_1.default.createElement(FormFileUpload_1.default, {
60
+ placeholder: schemaObject.description || id,
61
+ onChange: (file) => {
62
+ if (file === undefined) {
63
+ dispatch((0, slice_1.clearFormBodyKey)(id));
64
+ return;
65
+ }
66
+ dispatch(
67
+ (0, slice_1.setFileFormBody)({
68
+ key: id,
69
+ value: {
70
+ src: `/path/to/${file.name}`,
71
+ content: file,
72
+ },
73
+ })
74
+ );
75
+ },
76
+ })
77
+ );
59
78
  }
60
79
  if (
61
80
  schemaObject.type === "object" &&
@@ -67,12 +86,21 @@ function FormBodyItem({ schemaObject, id, schema }) {
67
86
  2
68
87
  );
69
88
  return react_1.default.createElement(
70
- LiveEditor_1.default,
71
- {
72
- action: (code) =>
73
- dispatch((0, slice_1.setStringFormBody)({ key: id, value: code })),
74
- },
75
- objectExample
89
+ react_1.default.Fragment,
90
+ null,
91
+ label &&
92
+ react_1.default.createElement(FormLabel_1.default, {
93
+ label: label,
94
+ required: required,
95
+ }),
96
+ react_1.default.createElement(
97
+ LiveEditor_1.default,
98
+ {
99
+ action: (code) =>
100
+ dispatch((0, slice_1.setStringFormBody)({ key: id, value: code })),
101
+ },
102
+ objectExample
103
+ )
76
104
  );
77
105
  }
78
106
  if (
@@ -80,6 +108,8 @@ function FormBodyItem({ schemaObject, id, schema }) {
80
108
  schemaObject.enum.every((value) => typeof value === "string")
81
109
  ) {
82
110
  return react_1.default.createElement(FormSelect_1.default, {
111
+ label: label,
112
+ required: required,
83
113
  options: ["---", ...schemaObject.enum],
84
114
  onChange: (e) => {
85
115
  const val = e.target.value;
@@ -98,6 +128,8 @@ function FormBodyItem({ schemaObject, id, schema }) {
98
128
  }
99
129
  // TODO: support all the other types.
100
130
  return react_1.default.createElement(FormTextInput_1.default, {
131
+ label: label,
132
+ required: required,
101
133
  paramName: id,
102
134
  isRequired: Array.isArray(schema.required) && schema.required.includes(id),
103
135
  placeholder: schemaObject.description || id,
@@ -368,16 +368,14 @@ function Body({
368
368
  Object.entries(schema.properties ?? {}).map(([key, val]) => {
369
369
  return react_1.default.createElement(
370
370
  FormItem_1.default,
371
- {
372
- key: key,
373
- label: key,
374
- required:
375
- Array.isArray(schema.required) && schema.required.includes(key),
376
- },
371
+ { key: key },
377
372
  react_1.default.createElement(FormBodyItem_1.default, {
378
373
  schemaObject: val,
379
374
  id: key,
380
375
  schema: schema,
376
+ label: key,
377
+ required:
378
+ Array.isArray(schema.required) && schema.required.includes(key),
381
379
  })
382
380
  );
383
381
  })