docusaurus-theme-openapi-docs 0.0.0-1157 → 0.0.0-1159
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.
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +4 -2
- package/lib/theme/ApiExplorer/ParamOptions/index.js +4 -0
- package/lib/theme/ParamsItem/index.js +27 -0
- package/package.json +3 -3
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +4 -2
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +5 -0
- package/src/theme/ParamsItem/index.tsx +25 -0
|
@@ -32,9 +32,11 @@ function ParamTextFormItem({ param, label, type, required }) {
|
|
|
32
32
|
(0, slice_1.setParam)({
|
|
33
33
|
...param,
|
|
34
34
|
value:
|
|
35
|
-
param.in === "path"
|
|
35
|
+
param.in === "path"
|
|
36
36
|
? e.target.value.replace(/\s/g, "%20")
|
|
37
|
-
:
|
|
37
|
+
: param.in === "query"
|
|
38
|
+
? encodeURIComponent(e.target.value)
|
|
39
|
+
: e.target.value,
|
|
38
40
|
})
|
|
39
41
|
),
|
|
40
42
|
});
|
|
@@ -105,6 +105,10 @@ function getSchemaEnum(schema) {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
+
// const is semantically a single-value enum
|
|
109
|
+
if (schema?.const !== undefined) {
|
|
110
|
+
return [schema.const];
|
|
111
|
+
}
|
|
108
112
|
return undefined;
|
|
109
113
|
}
|
|
110
114
|
function ParamOption({ param, label, type, required }) {
|
|
@@ -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(),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-theme-openapi-docs",
|
|
3
3
|
"description": "OpenAPI theme for Docusaurus.",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-1159",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@types/postman-collection": "^3.5.11",
|
|
39
39
|
"@types/react-modal": "^3.16.3",
|
|
40
40
|
"concurrently": "^9.2.0",
|
|
41
|
-
"docusaurus-plugin-openapi-docs": "0.0.0-
|
|
41
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-1159",
|
|
42
42
|
"docusaurus-plugin-sass": "^0.2.6",
|
|
43
43
|
"eslint-plugin-prettier": "^5.5.1"
|
|
44
44
|
},
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=14"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "dd28b8fc4741bbdccfe9d941e248b7dbef0924e6"
|
|
86
86
|
}
|
|
@@ -38,9 +38,11 @@ export default function ParamTextFormItem({
|
|
|
38
38
|
setParam({
|
|
39
39
|
...param,
|
|
40
40
|
value:
|
|
41
|
-
param.in === "path"
|
|
41
|
+
param.in === "path"
|
|
42
42
|
? e.target.value.replace(/\s/g, "%20")
|
|
43
|
-
:
|
|
43
|
+
: param.in === "query"
|
|
44
|
+
? encodeURIComponent(e.target.value)
|
|
45
|
+
: e.target.value,
|
|
44
46
|
})
|
|
45
47
|
)
|
|
46
48
|
}
|
|
@@ -102,10 +102,34 @@ function ParamsItem({ param, ...rest }: Props) {
|
|
|
102
102
|
</span>
|
|
103
103
|
));
|
|
104
104
|
|
|
105
|
+
const constValue = schema?.const;
|
|
106
|
+
|
|
105
107
|
const renderQualifier = guard(getQualifierMessage(schema), (qualifier) => (
|
|
106
108
|
<Markdown>{qualifier}</Markdown>
|
|
107
109
|
));
|
|
108
110
|
|
|
111
|
+
function renderConstValue() {
|
|
112
|
+
if (constValue === undefined) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
const label = translate({
|
|
116
|
+
id: OPENAPI_SCHEMA_ITEM.CONSTANT_VALUE,
|
|
117
|
+
message: "Constant value:",
|
|
118
|
+
});
|
|
119
|
+
return (
|
|
120
|
+
<div>
|
|
121
|
+
<strong>{label} </strong>
|
|
122
|
+
<span>
|
|
123
|
+
<code>
|
|
124
|
+
{typeof constValue === "string"
|
|
125
|
+
? constValue
|
|
126
|
+
: JSON.stringify(constValue)}
|
|
127
|
+
</code>
|
|
128
|
+
</span>
|
|
129
|
+
</div>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
109
133
|
const renderDescription = guard(description, (description) => (
|
|
110
134
|
<Markdown>{description}</Markdown>
|
|
111
135
|
));
|
|
@@ -173,6 +197,7 @@ function ParamsItem({ param, ...rest }: Props) {
|
|
|
173
197
|
{renderDeprecated}
|
|
174
198
|
</span>
|
|
175
199
|
{renderQualifier}
|
|
200
|
+
{renderConstValue()}
|
|
176
201
|
{renderDescription}
|
|
177
202
|
{renderEnumDescriptions}
|
|
178
203
|
{renderDefaultValue()}
|