-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathopenapi.config.ts
More file actions
81 lines (75 loc) · 2.97 KB
/
openapi.config.ts
File metadata and controls
81 lines (75 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import type * as Plugin from "@docusaurus/types/src/plugin";
import type * as OpenApiPlugin from "docusaurus-plugin-openapi-docs";
export interface OpenApiVersion {
specPath: string;
outputDir: string;
label: string;
baseUrl: string;
downloadUrl: string;
}
export interface OpenApiConfig {
latestVersion: string;
showVersions: string[];
versions: Record<string, OpenApiVersion>;
}
export const openApiConfig: OpenApiConfig = {
latestVersion: "2025-11-08",
showVersions: ["2025-11-08", "2025-05-20", "2025-04-22"],
versions: {
"2025-11-08": {
specPath: "docs/reference/openapi-2025-11-08.yaml",
outputDir: "docs/reference/2025-11-08",
label: "2025-11-08",
baseUrl: "/docs/reference/2025-11-08/anytype-api",
downloadUrl: "https://raw.githubusercontent.com/anyproto/anytype-api/main/docs/reference/openapi-2025-11-08.yaml",
},
"2025-05-20": {
specPath: "docs/reference/openapi-2025-05-20.yaml",
outputDir: "docs/reference/2025-05-20",
label: "2025-05-20",
baseUrl: "/docs/reference/2025-05-20/anytype-api",
downloadUrl: "https://raw.githubusercontent.com/anyproto/anytype-api/main/docs/reference/openapi-2025-05-20.yaml",
},
"2025-04-22": {
specPath: "docs/reference/openapi-2025-04-22.yaml",
outputDir: "docs/reference/2025-04-22",
label: "2025-04-22",
baseUrl: "/docs/reference/2025-04-22/anytype-api",
downloadUrl: "https://raw.githubusercontent.com/anyproto/anytype-api/main/docs/reference/openapi-2025-04-22.yaml",
},
"2025-03-17": {
specPath: "docs/reference/openapi-2025-03-17.yaml",
outputDir: "docs/reference/2025-03-17",
label: "2025-03-17",
baseUrl: "/docs/reference/2025-03-17/anytype-api",
downloadUrl: "https://raw.githubusercontent.com/anyproto/anytype-api/main/docs/reference/openapi-2025-03-17.yaml",
},
"2025-02-12": {
specPath: "docs/reference/swagger-2025-02-12.yaml",
outputDir: "docs/reference/2025-02-12",
label: "2025-02-12",
baseUrl: "/docs/reference/2025-02-12/anytype-api",
downloadUrl: "https://raw.githubusercontent.com/anyproto/anytype-api/main/docs/reference/swagger-2025-02-12.yaml",
},
},
};
export function getOpenApiPluginConfig(): Plugin.PluginOptions {
const { latestVersion, showVersions, versions } = openApiConfig;
const latestVersionConfig = versions[latestVersion];
const filteredVersions = Object.fromEntries(Object.entries(versions).filter(([version]) => showVersions.includes(version)));
return {
anytype: {
specPath: latestVersionConfig.specPath,
outputDir: "docs/reference",
sidebarOptions: {
groupPathsBy: "tag",
categoryLinkSource: "tag",
},
version: latestVersion,
label: latestVersionConfig.label,
baseUrl: latestVersionConfig.baseUrl,
downloadUrl: latestVersionConfig.downloadUrl,
versions: filteredVersions,
} satisfies OpenApiPlugin.Options,
} satisfies Plugin.PluginOptions;
}