-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
148 lines (141 loc) · 5.27 KB
/
index.ts
File metadata and controls
148 lines (141 loc) · 5.27 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/* ============================================================================
* Copyright (c) Palo Alto Networks
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* ========================================================================== */
import { createAuthentication } from "./createAuthentication";
import { createContactInfo } from "./createContactInfo";
// import { createDeprecationNotice } from "./createDeprecationNotice";
import { createDescription } from "./createDescription";
import { createDownload } from "./createDownload";
import { createEndpoint } from "./createEndpoint";
import { createLicense } from "./createLicense";
import { createLogo } from "./createLogo";
import { createParamsDetails } from "./createParamsDetails";
// import { createRequestBodyDetails } from "./createRequestBodyDetails";
import { createRequestSchema } from "./createRequestSchema";
import { createStatusCodes } from "./createStatusCodes";
import { createTermsOfService } from "./createTermsOfService";
// import { createVendorExtensions } from "./createVendorExtensions";
import { createVersionBadge } from "./createVersionBadge";
import { greaterThan, lessThan, render } from "./utils";
import {
ContactObject,
LicenseObject,
// MediaTypeObject,
SecuritySchemeObject,
} from "../openapi/types";
import { ApiPageMetadata, InfoPageMetadata, TagPageMetadata } from "../types";
// interface Props {
// title: string;
// body: {
// content?: {
// [key: string]: MediaTypeObject;
// };
// description?: string;
// required?: boolean;
// };
// }
export function createApiPageMD({
// title,
api: {
// deprecated,
// "x-deprecated-description": deprecatedDescription,
description,
// extensions,
parameters,
requestBody,
responses,
path,
method,
},
}: // frontMatter,
ApiPageMetadata) {
// return render([
// `import ApiTabs from "@theme/ApiTabs";\n`,
// `import MimeTabs from "@theme/MimeTabs";\n`,
// `import ParamsItem from "@theme/ParamsItem";\n`,
// `import ResponseSamples from "@theme/ResponseSamples";\n`,
// `import SchemaItem from "@theme/SchemaItem";\n`,
// `import SchemaTabs from "@theme/SchemaTabs";\n`,
// `import DiscriminatorTabs from "@theme/DiscriminatorTabs";\n`,
// `import SchemaTable from "@theme/SchemaTable";\n`,
// `import RequestBodyDetails from "@theme/RequestBodyDetails";\n`,
// `import TabItem from "@theme/TabItem";\n\n`,
// `## ${title.replace(lessThan, "<").replace(greaterThan, ">")}\n\n`,
// frontMatter.show_extensions && createVendorExtensions(extensions),
// createDeprecationNotice({ deprecated, description: deprecatedDescription }),
// createDescription(description),
// createParamsDetails({ parameters, type: "path" }),
// createParamsDetails({ parameters, type: "query" }),
// createParamsDetails({ parameters, type: "header" }),
// createParamsDetails({ parameters, type: "cookie" }),
// createRequestBodyDetails({
// title: "Request Body",
// body: requestBody,
// } as Props),
// createStatusCodes({ responses }),
// ]);
return render([
`import Layout from "@theme/Layout";\n`,
`import Endpoint from "@theme/Endpoint";\n`,
`import ParamDetails from "@theme/ParamDetails";\n`,
`import RequestBodyDetailsBase from "@theme/RequestBodyDetails/base";\n`,
`import RequestBodyDetails from "@theme/RequestBodyDetails";\n`,
`import Table from "@theme/SchemaTable";\n`,
`import MimeTabs from "@theme/MimeTabs";\n`,
`import ApiTabs from "@theme/ApiTabs";\n`,
`import SchemaTabs from "@theme/SchemaTabs";\n`,
`import ResponseSamples from "@theme/ResponseSamples";\n`,
`import TabItem from "@theme/TabItem";\n`,
// create("Layout", {
// children: [
description ? `\n\n${description.trim()}\n\n` : "",
createEndpoint(method, path),
createParamsDetails({ parameters, type: "path" }),
createParamsDetails({ parameters, type: "query" }),
createParamsDetails({ parameters, type: "header" }),
createParamsDetails({ parameters, type: "cookie" }),
requestBody
? createRequestSchema({ body: requestBody, title: "Request body" })
: "",
createStatusCodes({ responses }),
// ],
// }
// ),
]);
}
export function createInfoPageMD({
info: {
title,
version,
description,
contact,
license,
termsOfService,
logo,
darkLogo,
},
securitySchemes,
downloadUrl,
}: InfoPageMetadata) {
return render([
`import ApiLogo from "@theme/ApiLogo";\n`,
`import SchemaTabs from "@theme/SchemaTabs";\n`,
`import TabItem from "@theme/TabItem";\n`,
`import Export from "@theme/ApiExplorer/Export";\n\n`,
createVersionBadge(version),
createDownload(downloadUrl),
`# ${title.replace(lessThan, "<").replace(greaterThan, ">")}\n\n`,
createLogo(logo, darkLogo),
createDescription(description),
createAuthentication(securitySchemes as unknown as SecuritySchemeObject),
createContactInfo(contact as ContactObject),
createTermsOfService(termsOfService),
createLicense(license as LicenseObject),
]);
}
export function createTagPageMD({ tag: { description } }: TagPageMetadata) {
return render([createDescription(description)]);
}