docusaurus-theme-openapi-docs 0.0.0-849 → 0.0.0-852
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.
|
@@ -51,6 +51,7 @@ function SchemaItem(props) {
|
|
|
51
51
|
let deprecated;
|
|
52
52
|
let schemaDescription;
|
|
53
53
|
let defaultValue;
|
|
54
|
+
let example;
|
|
54
55
|
let nullable;
|
|
55
56
|
let enumDescriptions = [];
|
|
56
57
|
if (schema) {
|
|
@@ -58,6 +59,7 @@ function SchemaItem(props) {
|
|
|
58
59
|
schemaDescription = schema.description;
|
|
59
60
|
enumDescriptions = transformEnumDescriptions(schema["x-enumDescriptions"]);
|
|
60
61
|
defaultValue = schema.default;
|
|
62
|
+
example = schema.example;
|
|
61
63
|
nullable = schema.nullable;
|
|
62
64
|
}
|
|
63
65
|
const renderRequired = (0, utils_1.guard)(
|
|
@@ -167,6 +169,33 @@ function SchemaItem(props) {
|
|
|
167
169
|
}
|
|
168
170
|
return undefined;
|
|
169
171
|
}
|
|
172
|
+
function renderExample() {
|
|
173
|
+
if (example !== undefined) {
|
|
174
|
+
if (typeof example === "string") {
|
|
175
|
+
return react_1.default.createElement(
|
|
176
|
+
"div",
|
|
177
|
+
null,
|
|
178
|
+
react_1.default.createElement("strong", null, "Example: "),
|
|
179
|
+
react_1.default.createElement(
|
|
180
|
+
"span",
|
|
181
|
+
null,
|
|
182
|
+
react_1.default.createElement("code", null, example)
|
|
183
|
+
)
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
return react_1.default.createElement(
|
|
187
|
+
"div",
|
|
188
|
+
null,
|
|
189
|
+
react_1.default.createElement("strong", null, "Example: "),
|
|
190
|
+
react_1.default.createElement(
|
|
191
|
+
"span",
|
|
192
|
+
null,
|
|
193
|
+
react_1.default.createElement("code", null, JSON.stringify(example))
|
|
194
|
+
)
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
170
199
|
const schemaContent = react_1.default.createElement(
|
|
171
200
|
"div",
|
|
172
201
|
null,
|
|
@@ -200,6 +229,7 @@ function SchemaItem(props) {
|
|
|
200
229
|
renderEnumDescriptions,
|
|
201
230
|
renderQualifierMessage,
|
|
202
231
|
renderDefaultValue(),
|
|
232
|
+
renderExample(),
|
|
203
233
|
collapsibleSchemaContent ?? collapsibleSchemaContent
|
|
204
234
|
);
|
|
205
235
|
return react_1.default.createElement(
|
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-852",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"clsx": "^1.1.1",
|
|
43
43
|
"copy-text-to-clipboard": "^3.1.0",
|
|
44
44
|
"crypto-js": "^4.1.1",
|
|
45
|
-
"docusaurus-plugin-openapi-docs": "0.0.0-
|
|
45
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-852",
|
|
46
46
|
"docusaurus-plugin-sass": "^0.2.3",
|
|
47
47
|
"file-saver": "^2.0.5",
|
|
48
48
|
"lodash": "^4.17.20",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"engines": {
|
|
71
71
|
"node": ">=14"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "a352f9c4ce4e9fb46044d7cba30c132aaa81518f"
|
|
74
74
|
}
|
|
@@ -66,6 +66,7 @@ export default function SchemaItem(props: Props) {
|
|
|
66
66
|
let deprecated;
|
|
67
67
|
let schemaDescription;
|
|
68
68
|
let defaultValue: string | undefined;
|
|
69
|
+
let example: string | undefined;
|
|
69
70
|
let nullable;
|
|
70
71
|
let enumDescriptions: [string, string][] = [];
|
|
71
72
|
|
|
@@ -74,6 +75,7 @@ export default function SchemaItem(props: Props) {
|
|
|
74
75
|
schemaDescription = schema.description;
|
|
75
76
|
enumDescriptions = transformEnumDescriptions(schema["x-enumDescriptions"]);
|
|
76
77
|
defaultValue = schema.default;
|
|
78
|
+
example = schema.example;
|
|
77
79
|
nullable = schema.nullable;
|
|
78
80
|
}
|
|
79
81
|
|
|
@@ -157,6 +159,30 @@ export default function SchemaItem(props: Props) {
|
|
|
157
159
|
return undefined;
|
|
158
160
|
}
|
|
159
161
|
|
|
162
|
+
function renderExample() {
|
|
163
|
+
if (example !== undefined) {
|
|
164
|
+
if (typeof example === "string") {
|
|
165
|
+
return (
|
|
166
|
+
<div>
|
|
167
|
+
<strong>Example: </strong>
|
|
168
|
+
<span>
|
|
169
|
+
<code>{example}</code>
|
|
170
|
+
</span>
|
|
171
|
+
</div>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
return (
|
|
175
|
+
<div>
|
|
176
|
+
<strong>Example: </strong>
|
|
177
|
+
<span>
|
|
178
|
+
<code>{JSON.stringify(example)}</code>
|
|
179
|
+
</span>
|
|
180
|
+
</div>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
|
|
160
186
|
const schemaContent = (
|
|
161
187
|
<div>
|
|
162
188
|
<span className="openapi-schema__container">
|
|
@@ -179,6 +205,7 @@ export default function SchemaItem(props: Props) {
|
|
|
179
205
|
{renderEnumDescriptions}
|
|
180
206
|
{renderQualifierMessage}
|
|
181
207
|
{renderDefaultValue()}
|
|
208
|
+
{renderExample()}
|
|
182
209
|
{collapsibleSchemaContent ?? collapsibleSchemaContent}
|
|
183
210
|
</div>
|
|
184
211
|
);
|