docusaurus-plugin-openapi-docs 1.1.3 → 1.1.6
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/createRequestBodyDetails.d.ts +9 -2
- package/lib/markdown/createRequestBodyDetails.js +2 -2
- package/lib/markdown/createRequestSchema.d.ts +21 -0
- package/lib/markdown/createRequestSchema.js +680 -0
- package/lib/markdown/{createSchemaDetails.d.ts → createResponseSchema.d.ts} +2 -2
- package/lib/markdown/{createSchemaDetails.js → createResponseSchema.js} +110 -63
- package/lib/markdown/createStatusCodes.d.ts +2 -0
- package/lib/markdown/createStatusCodes.js +58 -56
- package/lib/markdown/index.js +5 -1
- package/lib/openapi/createExample.js +27 -14
- package/lib/openapi/openapi.d.ts +1 -1
- package/lib/openapi/openapi.js +21 -10
- package/lib/openapi/types.d.ts +1 -1
- package/lib/sidebars/index.d.ts +1 -1
- package/lib/sidebars/index.js +11 -3
- package/package.json +2 -2
- package/src/markdown/createRequestBodyDetails.ts +11 -4
- package/src/markdown/createRequestSchema.ts +848 -0
- package/src/markdown/{createSchemaDetails.ts → createResponseSchema.ts} +134 -72
- package/src/markdown/createStatusCodes.ts +53 -61
- package/src/markdown/index.ts +17 -1
- package/src/openapi/createExample.ts +31 -14
- package/src/openapi/openapi.ts +16 -8
- package/src/openapi/types.ts +1 -1
- package/src/sidebars/index.ts +13 -5
package/lib/sidebars/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ProcessedSidebar } from "@docusaurus/plugin-content-docs/src/sidebars/types";
|
|
2
2
|
import { TagObject } from "../openapi/types";
|
|
3
3
|
import type { SidebarOptions, APIOptions, ApiMetadata } from "../types";
|
|
4
|
-
export default function generateSidebarSlice(sidebarOptions: SidebarOptions, options: APIOptions, api: ApiMetadata[], tags: TagObject[], docPath: string): ProcessedSidebar;
|
|
4
|
+
export default function generateSidebarSlice(sidebarOptions: SidebarOptions, options: APIOptions, api: ApiMetadata[], tags: TagObject[][], docPath: string): ProcessedSidebar;
|
package/lib/sidebars/index.js
CHANGED
|
@@ -33,9 +33,16 @@ function groupByTags(items, sidebarOptions, options, tags, docPath) {
|
|
|
33
33
|
};
|
|
34
34
|
});
|
|
35
35
|
// TODO: make sure we only take the first tag
|
|
36
|
-
const
|
|
36
|
+
const operationTags = (0, uniq_1.default)(apiItems
|
|
37
37
|
.flatMap((item) => item.api.tags)
|
|
38
38
|
.filter((item) => !!item));
|
|
39
|
+
// Only include operation tags that are globally defined
|
|
40
|
+
const apiTags = [];
|
|
41
|
+
tags.flat().forEach((tag) => {
|
|
42
|
+
if (operationTags.includes(tag.name)) {
|
|
43
|
+
apiTags.push(tag.name);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
39
46
|
const basePath = docPath
|
|
40
47
|
? outputDir.split(docPath)[1].replace(/^\/+/g, "")
|
|
41
48
|
: outputDir.slice(outputDir.indexOf("/", 1)).replace(/^\/+/g, "");
|
|
@@ -66,11 +73,12 @@ function groupByTags(items, sidebarOptions, options, tags, docPath) {
|
|
|
66
73
|
}
|
|
67
74
|
const tagged = apiTags
|
|
68
75
|
.map((tag) => {
|
|
76
|
+
var _a;
|
|
69
77
|
// Map info object to tag
|
|
70
78
|
const taggedInfoObject = intros.find((i) => i.tags ? i.tags.includes(tag) : undefined);
|
|
71
79
|
const tagObject = tags.flat().find((t) => {
|
|
72
80
|
var _a;
|
|
73
|
-
return (_a =
|
|
81
|
+
return (_a = tag === t.name) !== null && _a !== void 0 ? _a : {
|
|
74
82
|
name: tag,
|
|
75
83
|
description: `${tag} Index`,
|
|
76
84
|
};
|
|
@@ -105,7 +113,7 @@ function groupByTags(items, sidebarOptions, options, tags, docPath) {
|
|
|
105
113
|
}
|
|
106
114
|
return {
|
|
107
115
|
type: "category",
|
|
108
|
-
label: tag,
|
|
116
|
+
label: (_a = tagObject === null || tagObject === void 0 ? void 0 : tagObject["x-displayName"]) !== null && _a !== void 0 ? _a : tag,
|
|
109
117
|
link: linkConfig,
|
|
110
118
|
collapsible: sidebarCollapsible,
|
|
111
119
|
collapsed: sidebarCollapsed,
|
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": "1.1.
|
|
4
|
+
"version": "1.1.6",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"engines": {
|
|
68
68
|
"node": ">=14"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "fbac87dcd52678751a3fe73ab416e4778e77bbb1"
|
|
71
71
|
}
|
|
@@ -5,13 +5,20 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { MediaTypeObject } from "../openapi/types";
|
|
9
|
+
import { createRequestSchema } from "./createRequestSchema";
|
|
9
10
|
|
|
10
11
|
interface Props {
|
|
11
12
|
title: string;
|
|
12
|
-
body:
|
|
13
|
+
body: {
|
|
14
|
+
content?: {
|
|
15
|
+
[key: string]: MediaTypeObject;
|
|
16
|
+
};
|
|
17
|
+
description?: string;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
};
|
|
13
20
|
}
|
|
14
21
|
|
|
15
|
-
export function createRequestBodyDetails({ title, body }: Props) {
|
|
16
|
-
return
|
|
22
|
+
export function createRequestBodyDetails({ title, body }: Props): any {
|
|
23
|
+
return createRequestSchema({ title, body });
|
|
17
24
|
}
|