docusaurus-theme-openapi-docs 0.0.0-1001 → 0.0.0-1003
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.
|
@@ -114,9 +114,10 @@ const AnyOneOf = ({ schema, schemaType }) => {
|
|
|
114
114
|
react_1.default.createElement(
|
|
115
115
|
TabItem_1.default,
|
|
116
116
|
{ key: index, label: label, value: `${index}-item-properties` },
|
|
117
|
-
["string", "number", "integer", "boolean"].includes(
|
|
117
|
+
(["string", "number", "integer", "boolean"].includes(
|
|
118
118
|
anyOneSchema.type
|
|
119
|
-
)
|
|
119
|
+
) ||
|
|
120
|
+
anyOneSchema.const) &&
|
|
120
121
|
react_1.default.createElement(SchemaItem_1.default, {
|
|
121
122
|
collapsible: false,
|
|
122
123
|
name: undefined,
|
|
@@ -51,6 +51,7 @@ function SchemaItem(props) {
|
|
|
51
51
|
let example;
|
|
52
52
|
let nullable;
|
|
53
53
|
let enumDescriptions = [];
|
|
54
|
+
let constValue;
|
|
54
55
|
if (schema) {
|
|
55
56
|
deprecated = schema.deprecated;
|
|
56
57
|
schemaDescription = schema.description;
|
|
@@ -60,6 +61,7 @@ function SchemaItem(props) {
|
|
|
60
61
|
nullable =
|
|
61
62
|
schema.nullable ||
|
|
62
63
|
(Array.isArray(schema.type) && schema.type.includes("null")); // support JSON Schema nullable
|
|
64
|
+
constValue = schema.const;
|
|
63
65
|
}
|
|
64
66
|
const renderRequired = (0, utils_1.guard)(
|
|
65
67
|
Array.isArray(required) ? required.includes(name) : required,
|
|
@@ -170,6 +172,37 @@ function SchemaItem(props) {
|
|
|
170
172
|
}
|
|
171
173
|
return undefined;
|
|
172
174
|
}
|
|
175
|
+
function renderConstValue() {
|
|
176
|
+
if (constValue !== undefined) {
|
|
177
|
+
if (typeof constValue === "string") {
|
|
178
|
+
return react_1.default.createElement(
|
|
179
|
+
"div",
|
|
180
|
+
null,
|
|
181
|
+
react_1.default.createElement("strong", null, "Constant value: "),
|
|
182
|
+
react_1.default.createElement(
|
|
183
|
+
"span",
|
|
184
|
+
null,
|
|
185
|
+
react_1.default.createElement("code", null, constValue)
|
|
186
|
+
)
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
return react_1.default.createElement(
|
|
190
|
+
"div",
|
|
191
|
+
null,
|
|
192
|
+
react_1.default.createElement("strong", null, "Constant value: "),
|
|
193
|
+
react_1.default.createElement(
|
|
194
|
+
"span",
|
|
195
|
+
null,
|
|
196
|
+
react_1.default.createElement(
|
|
197
|
+
"code",
|
|
198
|
+
null,
|
|
199
|
+
JSON.stringify(constValue)
|
|
200
|
+
)
|
|
201
|
+
)
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
173
206
|
const schemaContent = react_1.default.createElement(
|
|
174
207
|
"div",
|
|
175
208
|
null,
|
|
@@ -201,6 +234,7 @@ function SchemaItem(props) {
|
|
|
201
234
|
renderSchemaDescription,
|
|
202
235
|
renderEnumDescriptions,
|
|
203
236
|
renderQualifierMessage,
|
|
237
|
+
renderConstValue(),
|
|
204
238
|
renderDefaultValue(),
|
|
205
239
|
renderExample(),
|
|
206
240
|
collapsibleSchemaContent ?? collapsibleSchemaContent
|
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-1003",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@types/lodash": "^4.14.176",
|
|
37
37
|
"@types/pako": "^2.0.3",
|
|
38
38
|
"concurrently": "^5.2.0",
|
|
39
|
-
"docusaurus-plugin-openapi-docs": "0.0.0-
|
|
39
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-1003",
|
|
40
40
|
"docusaurus-plugin-sass": "^0.2.3",
|
|
41
41
|
"eslint-plugin-prettier": "^5.0.1"
|
|
42
42
|
},
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"engines": {
|
|
80
80
|
"node": ">=14"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "a88297191793fbd5400b0b4291e794853cf07222"
|
|
83
83
|
}
|
|
@@ -122,9 +122,10 @@ const AnyOneOf: React.FC<SchemaProps> = ({ schema, schemaType }) => {
|
|
|
122
122
|
value={`${index}-item-properties`}
|
|
123
123
|
>
|
|
124
124
|
{/* Handle primitive types directly */}
|
|
125
|
-
{["string", "number", "integer", "boolean"].includes(
|
|
125
|
+
{(["string", "number", "integer", "boolean"].includes(
|
|
126
126
|
anyOneSchema.type
|
|
127
|
-
)
|
|
127
|
+
) ||
|
|
128
|
+
anyOneSchema.const) && (
|
|
128
129
|
<SchemaItem
|
|
129
130
|
collapsible={false}
|
|
130
131
|
name={undefined}
|
|
@@ -65,6 +65,7 @@ export default function SchemaItem(props: Props) {
|
|
|
65
65
|
let example: string | undefined;
|
|
66
66
|
let nullable;
|
|
67
67
|
let enumDescriptions: [string, string][] = [];
|
|
68
|
+
let constValue: string | undefined;
|
|
68
69
|
|
|
69
70
|
if (schema) {
|
|
70
71
|
deprecated = schema.deprecated;
|
|
@@ -75,6 +76,7 @@ export default function SchemaItem(props: Props) {
|
|
|
75
76
|
nullable =
|
|
76
77
|
schema.nullable ||
|
|
77
78
|
(Array.isArray(schema.type) && schema.type.includes("null")); // support JSON Schema nullable
|
|
79
|
+
constValue = schema.const;
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
const renderRequired = guard(
|
|
@@ -161,6 +163,30 @@ export default function SchemaItem(props: Props) {
|
|
|
161
163
|
return undefined;
|
|
162
164
|
}
|
|
163
165
|
|
|
166
|
+
function renderConstValue() {
|
|
167
|
+
if (constValue !== undefined) {
|
|
168
|
+
if (typeof constValue === "string") {
|
|
169
|
+
return (
|
|
170
|
+
<div>
|
|
171
|
+
<strong>Constant value: </strong>
|
|
172
|
+
<span>
|
|
173
|
+
<code>{constValue}</code>
|
|
174
|
+
</span>
|
|
175
|
+
</div>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
return (
|
|
179
|
+
<div>
|
|
180
|
+
<strong>Constant value: </strong>
|
|
181
|
+
<span>
|
|
182
|
+
<code>{JSON.stringify(constValue)}</code>
|
|
183
|
+
</span>
|
|
184
|
+
</div>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
|
|
164
190
|
const schemaContent = (
|
|
165
191
|
<div>
|
|
166
192
|
<span className="openapi-schema__container">
|
|
@@ -184,6 +210,7 @@ export default function SchemaItem(props: Props) {
|
|
|
184
210
|
{renderSchemaDescription}
|
|
185
211
|
{renderEnumDescriptions}
|
|
186
212
|
{renderQualifierMessage}
|
|
213
|
+
{renderConstValue()}
|
|
187
214
|
{renderDefaultValue()}
|
|
188
215
|
{renderExample()}
|
|
189
216
|
{collapsibleSchemaContent ?? collapsibleSchemaContent}
|