docusaurus-plugin-openapi-docs 0.0.0-803 → 0.0.0-824
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/markdown/createDeprecationNotice.js +5 -6
- package/lib/markdown/createParamsDetails.js +10 -4
- package/lib/markdown/createSchema.js +8 -8
- package/lib/openapi/types.d.ts +2 -0
- package/lib/openapi/utils/services/OpenAPIParser.js +1 -1
- package/package.json +2 -2
- package/src/markdown/createDeprecationNotice.ts +3 -2
- package/src/markdown/createParamsDetails.ts +10 -5
- package/src/markdown/createSchema.ts +8 -8
- package/src/openapi/types.ts +2 -0
- package/src/openapi/utils/services/OpenAPIParser.ts +1 -0
|
@@ -12,11 +12,10 @@ function createAdmonition({ children }) {
|
|
|
12
12
|
return `:::caution deprecated\n\n${(0, utils_1.render)(children)}\n\n:::`;
|
|
13
13
|
}
|
|
14
14
|
function createDeprecationNotice({ deprecated, description, }) {
|
|
15
|
-
return (0, utils_1.guard)(deprecated, () => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
15
|
+
return (0, utils_1.guard)(deprecated, () => createAdmonition({
|
|
16
|
+
children: description && description.length > 0
|
|
17
|
+
? (0, utils_1.clean)(description)
|
|
18
|
+
: "This endpoint has been deprecated and may be replaced or removed in future versions of the API.",
|
|
19
|
+
}));
|
|
21
20
|
}
|
|
22
21
|
exports.createDeprecationNotice = createDeprecationNotice;
|
|
@@ -35,10 +35,16 @@ function createParamsDetails({ parameters, type }) {
|
|
|
35
35
|
(0, utils_1.create)("div", {
|
|
36
36
|
children: [
|
|
37
37
|
(0, utils_1.create)("ul", {
|
|
38
|
-
children: params.map((param) =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
children: params.map((param) => {
|
|
39
|
+
var _a, _b, _c;
|
|
40
|
+
return (0, utils_1.create)("ParamsItem", {
|
|
41
|
+
className: "paramsItem",
|
|
42
|
+
param: {
|
|
43
|
+
...param,
|
|
44
|
+
enumDescriptions: Object.entries((_c = (_b = (_a = param === null || param === void 0 ? void 0 : param.schema) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b["x-enumDescriptions"]) !== null && _c !== void 0 ? _c : {}),
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}),
|
|
42
48
|
}),
|
|
43
49
|
],
|
|
44
50
|
}),
|
|
@@ -351,14 +351,14 @@ function createDetailsNode(name, schemaName, schema, required, nullable) {
|
|
|
351
351
|
(0, utils_1.create)("div", {
|
|
352
352
|
style: { marginLeft: "1rem" },
|
|
353
353
|
children: [
|
|
354
|
-
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema), (message) => (0, utils_1.create)("div", {
|
|
355
|
-
style: { marginTop: ".5rem", marginBottom: ".5rem" },
|
|
356
|
-
children: (0, createDescription_1.createDescription)(message),
|
|
357
|
-
})),
|
|
358
354
|
(0, utils_1.guard)(schema.description, (description) => (0, utils_1.create)("div", {
|
|
359
355
|
style: { marginTop: ".5rem", marginBottom: ".5rem" },
|
|
360
356
|
children: (0, createDescription_1.createDescription)(description),
|
|
361
357
|
})),
|
|
358
|
+
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema), (message) => (0, utils_1.create)("div", {
|
|
359
|
+
style: { marginTop: ".5rem", marginBottom: ".5rem" },
|
|
360
|
+
children: (0, createDescription_1.createDescription)(message),
|
|
361
|
+
})),
|
|
362
362
|
createNodes(schema, SCHEMA_TYPE),
|
|
363
363
|
],
|
|
364
364
|
}),
|
|
@@ -478,17 +478,17 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
478
478
|
]),
|
|
479
479
|
],
|
|
480
480
|
}),
|
|
481
|
-
(0, utils_1.guard)(
|
|
481
|
+
(0, utils_1.guard)(schema.description, (description) => (0, utils_1.create)("div", {
|
|
482
482
|
style: {
|
|
483
483
|
paddingLeft: "1rem",
|
|
484
484
|
},
|
|
485
|
-
children: (0, createDescription_1.createDescription)(
|
|
485
|
+
children: (0, createDescription_1.createDescription)(description),
|
|
486
486
|
})),
|
|
487
|
-
(0, utils_1.guard)(
|
|
487
|
+
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(discriminator), (message) => (0, utils_1.create)("div", {
|
|
488
488
|
style: {
|
|
489
489
|
paddingLeft: "1rem",
|
|
490
490
|
},
|
|
491
|
-
children: (0, createDescription_1.createDescription)(
|
|
491
|
+
children: (0, createDescription_1.createDescription)(message),
|
|
492
492
|
})),
|
|
493
493
|
(0, utils_1.create)("DiscriminatorTabs", {
|
|
494
494
|
className: "openapi-tabs__discriminator",
|
package/lib/openapi/types.d.ts
CHANGED
|
@@ -163,6 +163,7 @@ export interface ParameterObject {
|
|
|
163
163
|
examples?: Map<ExampleObject>;
|
|
164
164
|
content?: Map<MediaTypeObject>;
|
|
165
165
|
param?: Object;
|
|
166
|
+
"x-enumDescriptions"?: Record<string, string>;
|
|
166
167
|
}
|
|
167
168
|
export interface ParameterObjectWithRef {
|
|
168
169
|
name: string;
|
|
@@ -279,6 +280,7 @@ export type SchemaObject = Omit<JSONSchema, "type" | "allOf" | "oneOf" | "anyOf"
|
|
|
279
280
|
example?: any;
|
|
280
281
|
deprecated?: boolean;
|
|
281
282
|
"x-tags"?: string[];
|
|
283
|
+
"x-enumDescriptions"?: Record<string, string>;
|
|
282
284
|
};
|
|
283
285
|
export type SchemaObjectWithRef = Omit<JSONSchema, "type" | "allOf" | "oneOf" | "anyOf" | "not" | "items" | "properties" | "additionalProperties"> & {
|
|
284
286
|
type?: "string" | "number" | "integer" | "boolean" | "object" | "array";
|
|
@@ -215,7 +215,7 @@ class OpenAPIParser {
|
|
|
215
215
|
})
|
|
216
216
|
.filter((child) => child !== undefined);
|
|
217
217
|
for (const { $ref: subSchemaRef, schema: subSchema } of allOfSchemas) {
|
|
218
|
-
const { type, enum: enumProperty, properties, items, required, oneOf, anyOf, title, ...otherConstraints } = subSchema;
|
|
218
|
+
const { type, enum: enumProperty, "x-enumDescription": enumDescription, properties, items, required, oneOf, anyOf, title, ...otherConstraints } = subSchema;
|
|
219
219
|
if (receiver.type !== type &&
|
|
220
220
|
receiver.type !== undefined &&
|
|
221
221
|
type !== undefined) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-plugin-openapi-docs",
|
|
3
3
|
"description": "OpenAPI plugin for Docusaurus.",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-824",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=14"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "34abb2de0893a52b7e236e054e8d391f01ff0bc1"
|
|
66
66
|
}
|
|
@@ -23,8 +23,9 @@ export function createDeprecationNotice({
|
|
|
23
23
|
return guard(deprecated, () =>
|
|
24
24
|
createAdmonition({
|
|
25
25
|
children:
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
description && description.length > 0
|
|
27
|
+
? clean(description)
|
|
28
|
+
: "This endpoint has been deprecated and may be replaced or removed in future versions of the API.",
|
|
28
29
|
})
|
|
29
30
|
);
|
|
30
31
|
}
|
|
@@ -43,12 +43,17 @@ export function createParamsDetails({ parameters, type }: Props) {
|
|
|
43
43
|
create("div", {
|
|
44
44
|
children: [
|
|
45
45
|
create("ul", {
|
|
46
|
-
children: params.map((param) =>
|
|
47
|
-
create("ParamsItem", {
|
|
46
|
+
children: params.map((param) => {
|
|
47
|
+
return create("ParamsItem", {
|
|
48
48
|
className: "paramsItem",
|
|
49
|
-
param:
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
param: {
|
|
50
|
+
...param,
|
|
51
|
+
enumDescriptions: Object.entries(
|
|
52
|
+
param?.schema?.items?.["x-enumDescriptions"] ?? {}
|
|
53
|
+
),
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}),
|
|
52
57
|
}),
|
|
53
58
|
],
|
|
54
59
|
}),
|
|
@@ -416,16 +416,16 @@ function createDetailsNode(
|
|
|
416
416
|
create("div", {
|
|
417
417
|
style: { marginLeft: "1rem" },
|
|
418
418
|
children: [
|
|
419
|
-
guard(
|
|
419
|
+
guard(schema.description, (description) =>
|
|
420
420
|
create("div", {
|
|
421
421
|
style: { marginTop: ".5rem", marginBottom: ".5rem" },
|
|
422
|
-
children: createDescription(
|
|
422
|
+
children: createDescription(description),
|
|
423
423
|
})
|
|
424
424
|
),
|
|
425
|
-
guard(schema
|
|
425
|
+
guard(getQualifierMessage(schema), (message) =>
|
|
426
426
|
create("div", {
|
|
427
427
|
style: { marginTop: ".5rem", marginBottom: ".5rem" },
|
|
428
|
-
children: createDescription(
|
|
428
|
+
children: createDescription(message),
|
|
429
429
|
})
|
|
430
430
|
),
|
|
431
431
|
createNodes(schema, SCHEMA_TYPE),
|
|
@@ -559,20 +559,20 @@ function createPropertyDiscriminator(
|
|
|
559
559
|
]),
|
|
560
560
|
],
|
|
561
561
|
}),
|
|
562
|
-
guard(
|
|
562
|
+
guard(schema.description, (description) =>
|
|
563
563
|
create("div", {
|
|
564
564
|
style: {
|
|
565
565
|
paddingLeft: "1rem",
|
|
566
566
|
},
|
|
567
|
-
children: createDescription(
|
|
567
|
+
children: createDescription(description),
|
|
568
568
|
})
|
|
569
569
|
),
|
|
570
|
-
guard(
|
|
570
|
+
guard(getQualifierMessage(discriminator), (message) =>
|
|
571
571
|
create("div", {
|
|
572
572
|
style: {
|
|
573
573
|
paddingLeft: "1rem",
|
|
574
574
|
},
|
|
575
|
-
children: createDescription(
|
|
575
|
+
children: createDescription(message),
|
|
576
576
|
})
|
|
577
577
|
),
|
|
578
578
|
create("DiscriminatorTabs", {
|
package/src/openapi/types.ts
CHANGED
|
@@ -197,6 +197,7 @@ export interface ParameterObject {
|
|
|
197
197
|
param?: Object;
|
|
198
198
|
// ignoring stylings: matrix, label, form, simple, spaceDelimited,
|
|
199
199
|
// pipeDelimited and deepObject
|
|
200
|
+
"x-enumDescriptions"?: Record<string, string>;
|
|
200
201
|
}
|
|
201
202
|
|
|
202
203
|
export interface ParameterObjectWithRef {
|
|
@@ -353,6 +354,7 @@ export type SchemaObject = Omit<
|
|
|
353
354
|
example?: any;
|
|
354
355
|
deprecated?: boolean;
|
|
355
356
|
"x-tags"?: string[];
|
|
357
|
+
"x-enumDescriptions"?: Record<string, string>;
|
|
356
358
|
};
|
|
357
359
|
|
|
358
360
|
export type SchemaObjectWithRef = Omit<
|