docusaurus-plugin-openapi-docs 1.0.0
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/LICENSE +21 -0
- package/README.md +194 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +194 -0
- package/lib/markdown/createDeprecationNotice.d.ts +6 -0
- package/lib/markdown/createDeprecationNotice.js +19 -0
- package/lib/markdown/createDescription.d.ts +1 -0
- package/lib/markdown/createDescription.js +16 -0
- package/lib/markdown/createDetails.d.ts +2 -0
- package/lib/markdown/createDetails.js +18 -0
- package/lib/markdown/createDetailsSummary.d.ts +2 -0
- package/lib/markdown/createDetailsSummary.js +18 -0
- package/lib/markdown/createFullWidthTable.d.ts +2 -0
- package/lib/markdown/createFullWidthTable.js +18 -0
- package/lib/markdown/createParamsDetails.d.ts +7 -0
- package/lib/markdown/createParamsDetails.js +44 -0
- package/lib/markdown/createParamsTable.d.ts +7 -0
- package/lib/markdown/createParamsTable.js +80 -0
- package/lib/markdown/createRequestBodyDetails.d.ts +6 -0
- package/lib/markdown/createRequestBodyDetails.js +14 -0
- package/lib/markdown/createRequestBodyTable.d.ts +6 -0
- package/lib/markdown/createRequestBodyTable.js +14 -0
- package/lib/markdown/createSchemaDetails.d.ts +14 -0
- package/lib/markdown/createSchemaDetails.js +241 -0
- package/lib/markdown/createSchemaTable.d.ts +14 -0
- package/lib/markdown/createSchemaTable.js +217 -0
- package/lib/markdown/createStatusCodes.d.ts +6 -0
- package/lib/markdown/createStatusCodes.js +47 -0
- package/lib/markdown/createVersionBadge.d.ts +1 -0
- package/lib/markdown/createVersionBadge.js +20 -0
- package/lib/markdown/index.d.ts +3 -0
- package/lib/markdown/index.js +43 -0
- package/lib/markdown/schema.d.ts +3 -0
- package/lib/markdown/schema.js +100 -0
- package/lib/markdown/schema.test.d.ts +1 -0
- package/lib/markdown/schema.test.js +171 -0
- package/lib/markdown/utils.d.ts +7 -0
- package/lib/markdown/utils.js +33 -0
- package/lib/openapi/createExample.d.ts +2 -0
- package/lib/openapi/createExample.js +113 -0
- package/lib/openapi/index.d.ts +1 -0
- package/lib/openapi/index.js +12 -0
- package/lib/openapi/openapi.d.ts +11 -0
- package/lib/openapi/openapi.js +233 -0
- package/lib/openapi/openapi.test.d.ts +1 -0
- package/lib/openapi/openapi.test.js +33 -0
- package/lib/openapi/types.d.ts +331 -0
- package/lib/openapi/types.js +8 -0
- package/lib/options.d.ts +4 -0
- package/lib/options.js +18 -0
- package/lib/sidebars/index.d.ts +3 -0
- package/lib/sidebars/index.js +89 -0
- package/lib/types.d.ts +68 -0
- package/lib/types.js +8 -0
- package/package.json +58 -0
- package/src/index.ts +244 -0
- package/src/markdown/createDeprecationNotice.ts +30 -0
- package/src/markdown/createDescription.ts +13 -0
- package/src/markdown/createDetails.ts +16 -0
- package/src/markdown/createDetailsSummary.ts +16 -0
- package/src/markdown/createFullWidthTable.ts +16 -0
- package/src/markdown/createParamsDetails.ts +53 -0
- package/src/markdown/createParamsTable.ts +102 -0
- package/src/markdown/createRequestBodyDetails.ts +17 -0
- package/src/markdown/createRequestBodyTable.ts +17 -0
- package/src/markdown/createSchemaDetails.ts +302 -0
- package/src/markdown/createSchemaTable.ts +275 -0
- package/src/markdown/createStatusCodes.ts +52 -0
- package/src/markdown/createVersionBadge.ts +18 -0
- package/src/markdown/index.ts +55 -0
- package/src/markdown/schema.test.ts +196 -0
- package/src/markdown/schema.ts +115 -0
- package/src/markdown/utils.ts +39 -0
- package/src/openapi/__fixtures__/examples/openapi.yaml +13 -0
- package/src/openapi/__fixtures__/examples/yogurtstore/_category_.json +4 -0
- package/src/openapi/__fixtures__/examples/yogurtstore/froyo.yaml +13 -0
- package/src/openapi/__fixtures__/examples/yogurtstore/nested/nested.yaml +13 -0
- package/src/openapi/createExample.ts +143 -0
- package/src/openapi/index.ts +8 -0
- package/src/openapi/openapi.test.ts +37 -0
- package/src/openapi/openapi.ts +293 -0
- package/src/openapi/types.ts +430 -0
- package/src/openapi-to-postmanv2.d.ts +10 -0
- package/src/options.ts +20 -0
- package/src/plugin-content-docs-types.d.ts +42 -0
- package/src/plugin-openapi.d.ts +87 -0
- package/src/sidebars/index.ts +121 -0
- package/src/types.ts +97 -0
- package/tsconfig.json +7 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import type { JSONSchema4, JSONSchema6, JSONSchema7 } from "json-schema";
|
|
9
|
+
|
|
10
|
+
interface Map<T> {
|
|
11
|
+
[key: string]: T;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface OpenApiObject {
|
|
15
|
+
openapi: string;
|
|
16
|
+
info: InfoObject;
|
|
17
|
+
servers?: ServerObject[];
|
|
18
|
+
paths: PathsObject;
|
|
19
|
+
components?: ComponentsObject;
|
|
20
|
+
security?: SecurityRequirementObject[];
|
|
21
|
+
tags?: TagObject[];
|
|
22
|
+
externalDocs?: ExternalDocumentationObject;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface OpenApiObjectWithRef {
|
|
26
|
+
openapi: string;
|
|
27
|
+
info: InfoObject;
|
|
28
|
+
servers?: ServerObject[];
|
|
29
|
+
paths: PathsObjectWithRef;
|
|
30
|
+
components?: ComponentsObjectWithRef;
|
|
31
|
+
security?: SecurityRequirementObject[];
|
|
32
|
+
tags?: TagObject[];
|
|
33
|
+
externalDocs?: ExternalDocumentationObject;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface InfoObject {
|
|
37
|
+
title: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
termsOfService?: string;
|
|
40
|
+
contact?: ContactObject;
|
|
41
|
+
license?: LicenseObject;
|
|
42
|
+
version: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ContactObject {
|
|
46
|
+
name?: string;
|
|
47
|
+
url?: string;
|
|
48
|
+
email?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface LicenseObject {
|
|
52
|
+
name: string;
|
|
53
|
+
url?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface ServerObject {
|
|
57
|
+
url: string;
|
|
58
|
+
description?: string;
|
|
59
|
+
variables?: Map<ServerVariable>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ServerVariable {
|
|
63
|
+
enum?: string[];
|
|
64
|
+
default: string;
|
|
65
|
+
description?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface ComponentsObject {
|
|
69
|
+
schemas?: Map<SchemaObject>;
|
|
70
|
+
responses?: Map<ResponseObject>;
|
|
71
|
+
parameters?: Map<ParameterObject>;
|
|
72
|
+
examples?: Map<ExampleObject>;
|
|
73
|
+
requestBodies?: Map<RequestBodyObject>;
|
|
74
|
+
headers?: Map<HeaderObject>;
|
|
75
|
+
securitySchemes?: Map<SecuritySchemeObject>;
|
|
76
|
+
links?: Map<LinkObject>;
|
|
77
|
+
callbacks?: Map<CallbackObject>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface ComponentsObjectWithRef {
|
|
81
|
+
schemas?: Map<SchemaObjectWithRef | ReferenceObject>;
|
|
82
|
+
responses?: Map<ResponseObjectWithRef | ReferenceObject>;
|
|
83
|
+
parameters?: Map<ParameterObjectWithRef | ReferenceObject>;
|
|
84
|
+
examples?: Map<ExampleObject | ReferenceObject>;
|
|
85
|
+
requestBodies?: Map<RequestBodyObjectWithRef | ReferenceObject>;
|
|
86
|
+
headers?: Map<HeaderObjectWithRef | ReferenceObject>;
|
|
87
|
+
securitySchemes?: Map<SecuritySchemeObject | ReferenceObject>;
|
|
88
|
+
links?: Map<LinkObject | ReferenceObject>;
|
|
89
|
+
callbacks?: Map<CallbackObjectWithRef | ReferenceObject>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type PathsObject = Map<PathItemObject>;
|
|
93
|
+
|
|
94
|
+
export type PathsObjectWithRef = Map<PathItemObjectWithRef>;
|
|
95
|
+
|
|
96
|
+
export interface PathItemObject {
|
|
97
|
+
$ref?: string;
|
|
98
|
+
summary?: string;
|
|
99
|
+
description?: string;
|
|
100
|
+
get?: OperationObject;
|
|
101
|
+
put?: OperationObject;
|
|
102
|
+
post?: OperationObject;
|
|
103
|
+
delete?: OperationObject;
|
|
104
|
+
options?: OperationObject;
|
|
105
|
+
head?: OperationObject;
|
|
106
|
+
patch?: OperationObject;
|
|
107
|
+
trace?: OperationObject;
|
|
108
|
+
servers?: ServerObject[];
|
|
109
|
+
parameters?: ParameterObject[];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface PathItemObjectWithRef {
|
|
113
|
+
$ref?: string;
|
|
114
|
+
summary?: string;
|
|
115
|
+
description?: string;
|
|
116
|
+
get?: OperationObjectWithRef;
|
|
117
|
+
put?: OperationObjectWithRef;
|
|
118
|
+
post?: OperationObjectWithRef;
|
|
119
|
+
delete?: OperationObjectWithRef;
|
|
120
|
+
options?: OperationObjectWithRef;
|
|
121
|
+
head?: OperationObjectWithRef;
|
|
122
|
+
patch?: OperationObjectWithRef;
|
|
123
|
+
trace?: OperationObjectWithRef;
|
|
124
|
+
servers?: ServerObject[];
|
|
125
|
+
parameters?: (ParameterObjectWithRef | ReferenceObject)[];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface OperationObject {
|
|
129
|
+
tags?: string[];
|
|
130
|
+
summary?: string;
|
|
131
|
+
description?: string;
|
|
132
|
+
externalDocs?: ExternalDocumentationObject;
|
|
133
|
+
operationId?: string;
|
|
134
|
+
parameters?: ParameterObject[];
|
|
135
|
+
requestBody?: RequestBodyObject;
|
|
136
|
+
responses: ResponsesObject;
|
|
137
|
+
callbacks?: Map<CallbackObject>;
|
|
138
|
+
deprecated?: boolean;
|
|
139
|
+
security?: SecurityRequirementObject[];
|
|
140
|
+
servers?: ServerObject[];
|
|
141
|
+
|
|
142
|
+
// extensions
|
|
143
|
+
"x-deprecated-description"?: string;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface OperationObjectWithRef {
|
|
147
|
+
tags?: string[];
|
|
148
|
+
summary?: string;
|
|
149
|
+
description?: string;
|
|
150
|
+
externalDocs?: ExternalDocumentationObject;
|
|
151
|
+
operationId?: string;
|
|
152
|
+
parameters?: (ParameterObjectWithRef | ReferenceObject)[];
|
|
153
|
+
requestBody?: RequestBodyObjectWithRef | ReferenceObject;
|
|
154
|
+
responses: ResponsesObjectWithRef;
|
|
155
|
+
callbacks?: Map<CallbackObjectWithRef | ReferenceObject>;
|
|
156
|
+
deprecated?: boolean;
|
|
157
|
+
security?: SecurityRequirementObject[];
|
|
158
|
+
servers?: ServerObject[];
|
|
159
|
+
|
|
160
|
+
// extensions
|
|
161
|
+
"x-deprecated-description"?: string;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface ExternalDocumentationObject {
|
|
165
|
+
description?: string;
|
|
166
|
+
url: string;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface ParameterObject {
|
|
170
|
+
name: string;
|
|
171
|
+
in: "query" | "header" | "path" | "cookie";
|
|
172
|
+
description?: string;
|
|
173
|
+
required?: boolean;
|
|
174
|
+
deprecated?: boolean;
|
|
175
|
+
allowEmptyValue?: boolean;
|
|
176
|
+
//
|
|
177
|
+
style?: string;
|
|
178
|
+
explode?: string;
|
|
179
|
+
allowReserved?: boolean;
|
|
180
|
+
schema?: SchemaObject;
|
|
181
|
+
example?: any;
|
|
182
|
+
examples?: Map<ExampleObject>;
|
|
183
|
+
//
|
|
184
|
+
content?: Map<MediaTypeObject>;
|
|
185
|
+
// ignoring stylings: matrix, label, form, simple, spaceDelimited,
|
|
186
|
+
// pipeDelimited and deepObject
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface ParameterObjectWithRef {
|
|
190
|
+
name: string;
|
|
191
|
+
in: string;
|
|
192
|
+
description?: string;
|
|
193
|
+
required?: boolean;
|
|
194
|
+
deprecated?: boolean;
|
|
195
|
+
allowEmptyValue?: boolean;
|
|
196
|
+
//
|
|
197
|
+
style?: string;
|
|
198
|
+
explode?: string;
|
|
199
|
+
allowReserved?: boolean;
|
|
200
|
+
schema?: SchemaObjectWithRef | ReferenceObject;
|
|
201
|
+
example?: any;
|
|
202
|
+
examples?: Map<ExampleObject | ReferenceObject>;
|
|
203
|
+
//
|
|
204
|
+
content?: Map<MediaTypeObjectWithRef>;
|
|
205
|
+
// ignoring stylings: matrix, label, form, simple, spaceDelimited,
|
|
206
|
+
// pipeDelimited and deepObject
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface RequestBodyObject {
|
|
210
|
+
description?: string;
|
|
211
|
+
content: Map<MediaTypeObject>;
|
|
212
|
+
required?: boolean;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export interface RequestBodyObjectWithRef {
|
|
216
|
+
description?: string;
|
|
217
|
+
content: Map<MediaTypeObjectWithRef>;
|
|
218
|
+
required?: boolean;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export interface MediaTypeObject {
|
|
222
|
+
schema?: SchemaObject;
|
|
223
|
+
example?: any;
|
|
224
|
+
examples?: Map<ExampleObject>;
|
|
225
|
+
encoding?: Map<EncodingObject>;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface MediaTypeObjectWithRef {
|
|
229
|
+
schema?: SchemaObjectWithRef | ReferenceObject;
|
|
230
|
+
example?: any;
|
|
231
|
+
examples?: Map<ExampleObject | ReferenceObject>;
|
|
232
|
+
encoding?: Map<EncodingObjectWithRef>;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export interface EncodingObject {
|
|
236
|
+
contentType?: string;
|
|
237
|
+
headers?: Map<HeaderObject>;
|
|
238
|
+
style?: string;
|
|
239
|
+
explode?: boolean;
|
|
240
|
+
allowReserved?: boolean;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export interface EncodingObjectWithRef {
|
|
244
|
+
contentType?: string;
|
|
245
|
+
headers?: Map<HeaderObjectWithRef | ReferenceObject>;
|
|
246
|
+
style?: string;
|
|
247
|
+
explode?: boolean;
|
|
248
|
+
allowReserved?: boolean;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export type ResponsesObject = Map<ResponseObject>;
|
|
252
|
+
|
|
253
|
+
export type ResponsesObjectWithRef = Map<
|
|
254
|
+
ResponseObjectWithRef | ReferenceObject
|
|
255
|
+
>;
|
|
256
|
+
|
|
257
|
+
export interface ResponseObject {
|
|
258
|
+
description: string;
|
|
259
|
+
headers?: Map<HeaderObject>;
|
|
260
|
+
content?: Map<MediaTypeObject>;
|
|
261
|
+
links?: Map<LinkObject>;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export interface ResponseObjectWithRef {
|
|
265
|
+
description: string;
|
|
266
|
+
headers?: Map<HeaderObjectWithRef | ReferenceObject>;
|
|
267
|
+
content?: Map<MediaTypeObjectWithRef>;
|
|
268
|
+
links?: Map<LinkObject | ReferenceObject>;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export type CallbackObject = Map<PathItemObject>;
|
|
272
|
+
|
|
273
|
+
export type CallbackObjectWithRef = Map<PathItemObjectWithRef>;
|
|
274
|
+
|
|
275
|
+
export interface ExampleObject {
|
|
276
|
+
summary?: string;
|
|
277
|
+
description?: string;
|
|
278
|
+
value?: any;
|
|
279
|
+
externalValue?: string;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export interface LinkObject {
|
|
283
|
+
operationRef?: string;
|
|
284
|
+
operationId?: string;
|
|
285
|
+
parameters?: Map<any>;
|
|
286
|
+
requestBody?: any;
|
|
287
|
+
description?: string;
|
|
288
|
+
server?: ServerObject;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export type HeaderObject = Omit<ParameterObject, "name" | "in">;
|
|
292
|
+
|
|
293
|
+
export type HeaderObjectWithRef = Omit<ParameterObjectWithRef, "name" | "in">;
|
|
294
|
+
|
|
295
|
+
export interface TagObject {
|
|
296
|
+
name: string;
|
|
297
|
+
description?: string;
|
|
298
|
+
externalDocs?: ExternalDocumentationObject;
|
|
299
|
+
"x-displayName"?: string;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export interface ReferenceObject {
|
|
303
|
+
$ref: string;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export type JSONSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;
|
|
307
|
+
export type SchemaObject = Omit<
|
|
308
|
+
JSONSchema,
|
|
309
|
+
| "type"
|
|
310
|
+
| "allOf"
|
|
311
|
+
| "oneOf"
|
|
312
|
+
| "anyOf"
|
|
313
|
+
| "not"
|
|
314
|
+
| "items"
|
|
315
|
+
| "properties"
|
|
316
|
+
| "additionalProperties"
|
|
317
|
+
> & {
|
|
318
|
+
// OpenAPI specific overrides
|
|
319
|
+
type?: "string" | "number" | "integer" | "boolean" | "object" | "array";
|
|
320
|
+
allOf?: SchemaObject[];
|
|
321
|
+
oneOf?: SchemaObject[];
|
|
322
|
+
anyOf?: SchemaObject[];
|
|
323
|
+
not?: SchemaObject;
|
|
324
|
+
items?: SchemaObject;
|
|
325
|
+
properties?: Map<SchemaObject>;
|
|
326
|
+
additionalProperties?: boolean | SchemaObject;
|
|
327
|
+
|
|
328
|
+
// OpenAPI additions
|
|
329
|
+
nullable?: boolean;
|
|
330
|
+
discriminator?: DiscriminatorObject;
|
|
331
|
+
readOnly?: boolean;
|
|
332
|
+
writeOnly?: boolean;
|
|
333
|
+
xml?: XMLObject;
|
|
334
|
+
externalDocs?: ExternalDocumentationObject;
|
|
335
|
+
example?: any;
|
|
336
|
+
deprecated?: boolean;
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
export type SchemaObjectWithRef = Omit<
|
|
340
|
+
JSONSchema,
|
|
341
|
+
| "type"
|
|
342
|
+
| "allOf"
|
|
343
|
+
| "oneOf"
|
|
344
|
+
| "anyOf"
|
|
345
|
+
| "not"
|
|
346
|
+
| "items"
|
|
347
|
+
| "properties"
|
|
348
|
+
| "additionalProperties"
|
|
349
|
+
> & {
|
|
350
|
+
// OpenAPI specific overrides
|
|
351
|
+
type?: "string" | "number" | "integer" | "boolean" | "object" | "array";
|
|
352
|
+
allOf?: (SchemaObject | ReferenceObject)[];
|
|
353
|
+
oneOf?: (SchemaObject | ReferenceObject)[];
|
|
354
|
+
anyOf?: (SchemaObject | ReferenceObject)[];
|
|
355
|
+
not?: SchemaObject | ReferenceObject;
|
|
356
|
+
items?: SchemaObject | ReferenceObject;
|
|
357
|
+
properties?: Map<SchemaObject | ReferenceObject>;
|
|
358
|
+
additionalProperties?: boolean | SchemaObject | ReferenceObject;
|
|
359
|
+
|
|
360
|
+
// OpenAPI additions
|
|
361
|
+
nullable?: boolean;
|
|
362
|
+
discriminator?: DiscriminatorObject;
|
|
363
|
+
readOnly?: boolean;
|
|
364
|
+
writeOnly?: boolean;
|
|
365
|
+
xml?: XMLObject;
|
|
366
|
+
externalDocs?: ExternalDocumentationObject;
|
|
367
|
+
example?: any;
|
|
368
|
+
deprecated?: boolean;
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
export interface DiscriminatorObject {
|
|
372
|
+
propertyName: string;
|
|
373
|
+
mapping?: Map<string>;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export interface XMLObject {
|
|
377
|
+
name?: string;
|
|
378
|
+
namespace?: string;
|
|
379
|
+
prefix?: string;
|
|
380
|
+
attribute?: boolean;
|
|
381
|
+
wrapped?: boolean;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export type SecuritySchemeObject =
|
|
385
|
+
| ApiKeySecuritySchemeObject
|
|
386
|
+
| HttpSecuritySchemeObject
|
|
387
|
+
| Oauth2SecuritySchemeObject
|
|
388
|
+
| OpenIdConnectSecuritySchemeObject;
|
|
389
|
+
|
|
390
|
+
export interface ApiKeySecuritySchemeObject {
|
|
391
|
+
type: "apiKey";
|
|
392
|
+
description?: string;
|
|
393
|
+
name: string;
|
|
394
|
+
in: "query" | "header" | "cookie";
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
export interface HttpSecuritySchemeObject {
|
|
398
|
+
type: "http";
|
|
399
|
+
description?: string;
|
|
400
|
+
scheme: string;
|
|
401
|
+
bearerFormat?: string;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export interface Oauth2SecuritySchemeObject {
|
|
405
|
+
type: "oauth2";
|
|
406
|
+
description?: string;
|
|
407
|
+
flows: OAuthFlowsObject;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export interface OpenIdConnectSecuritySchemeObject {
|
|
411
|
+
type: "openIdConnect";
|
|
412
|
+
description?: string;
|
|
413
|
+
openIdConnectUrl: string;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
export interface OAuthFlowsObject {
|
|
417
|
+
implicit?: OAuthFlowObject;
|
|
418
|
+
password?: OAuthFlowObject;
|
|
419
|
+
clientCredentials?: OAuthFlowObject;
|
|
420
|
+
authorizationCode?: OAuthFlowObject;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export interface OAuthFlowObject {
|
|
424
|
+
authorizationUrl?: string; // required for some
|
|
425
|
+
tokenUrl?: string; // required for some
|
|
426
|
+
refreshUrl?: string;
|
|
427
|
+
scopes: Map<string>;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export type SecurityRequirementObject = Map<string[]>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
declare module "@paloaltonetworks/openapi-to-postmanv2" {
|
|
9
|
+
export default any;
|
|
10
|
+
}
|
package/src/options.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import { Joi } from "@docusaurus/utils-validation";
|
|
9
|
+
|
|
10
|
+
import type { PluginOptions } from "./types";
|
|
11
|
+
|
|
12
|
+
export const DEFAULT_OPTIONS: PluginOptions = {
|
|
13
|
+
id: "default",
|
|
14
|
+
config: {},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const OptionsSchema = Joi.object({
|
|
18
|
+
id: Joi.string().default(DEFAULT_OPTIONS.id),
|
|
19
|
+
config: Joi.object().default(DEFAULT_OPTIONS.config),
|
|
20
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
declare module "@docusaurus/plugin-content-docs-types" {
|
|
9
|
+
// Makes all properties visible when hovering over the type
|
|
10
|
+
type Expand<T extends Record<string, unknown>> = { [P in keyof T]: T[P] };
|
|
11
|
+
|
|
12
|
+
export type SidebarItemBase = {
|
|
13
|
+
className?: string;
|
|
14
|
+
customProps?: Record<string, unknown>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type SidebarItemLink = SidebarItemBase & {
|
|
18
|
+
type: "link";
|
|
19
|
+
href: string;
|
|
20
|
+
label: string;
|
|
21
|
+
docId: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type SidebarItemCategoryBase = SidebarItemBase & {
|
|
25
|
+
type: "category";
|
|
26
|
+
label: string;
|
|
27
|
+
collapsed: boolean;
|
|
28
|
+
collapsible: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type PropSidebarItemCategory = Expand<
|
|
32
|
+
SidebarItemCategoryBase & {
|
|
33
|
+
items: PropSidebarItem[];
|
|
34
|
+
}
|
|
35
|
+
>;
|
|
36
|
+
|
|
37
|
+
export type PropSidebarItem = SidebarItemLink | PropSidebarItemCategory;
|
|
38
|
+
export type PropSidebar = PropSidebarItem[];
|
|
39
|
+
export type PropSidebars = {
|
|
40
|
+
[sidebarId: string]: PropSidebar;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import type { FrontMatter as DocsFrontMatter } from "@docusaurus/types";
|
|
9
|
+
import type { Props as DocsProps } from "@docusaurus/types";
|
|
10
|
+
|
|
11
|
+
// TODO: figure out how to import this
|
|
12
|
+
declare module "docusaurus-plugin-openapi-docs" {
|
|
13
|
+
import type { PropSidebars } from "@docusaurus/plugin-content-docs-types";
|
|
14
|
+
|
|
15
|
+
export type Options = Partial<import("./types").APIOptions>;
|
|
16
|
+
|
|
17
|
+
export type PropApiMetadata = {
|
|
18
|
+
// TODO: adjust this to our needs
|
|
19
|
+
pluginId: string;
|
|
20
|
+
version: string;
|
|
21
|
+
label: string;
|
|
22
|
+
banner: VersionBanner | null;
|
|
23
|
+
badge: boolean;
|
|
24
|
+
className: string;
|
|
25
|
+
isLast: boolean;
|
|
26
|
+
apiSidebars: PropSidebars;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare module "@theme/ApiPage" {
|
|
31
|
+
import type { ApiRoute } from "@theme/ApiItem";
|
|
32
|
+
import type { PropApiMetadata } from "docusaurus-plugin-openapi";
|
|
33
|
+
|
|
34
|
+
export interface Props {
|
|
35
|
+
readonly location: { readonly pathname: string };
|
|
36
|
+
readonly apiMetadata: PropApiMetadata;
|
|
37
|
+
readonly route: {
|
|
38
|
+
readonly path: string;
|
|
39
|
+
readonly component: () => JSX.Element;
|
|
40
|
+
readonly routes: ApiRoute[];
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const ApiPage: (props: Props) => JSX.Element;
|
|
45
|
+
export default ApiPage;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
declare module "@theme/ApiItem" {
|
|
49
|
+
import type { Request } from "postman-collection";
|
|
50
|
+
|
|
51
|
+
import type { ApiItem } from "./types";
|
|
52
|
+
|
|
53
|
+
export type ApiRoute = {
|
|
54
|
+
readonly component: () => JSX.Element;
|
|
55
|
+
readonly exact: boolean;
|
|
56
|
+
readonly path: string;
|
|
57
|
+
readonly sidebar?: string;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export interface FrontMatter extends DocsFrontMatter {
|
|
61
|
+
readonly api?: object;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type Metadata = {
|
|
65
|
+
readonly description?: string;
|
|
66
|
+
readonly title?: string;
|
|
67
|
+
readonly permalink?: string;
|
|
68
|
+
readonly previous?: { readonly permalink: string; readonly title: string };
|
|
69
|
+
readonly next?: { readonly permalink: string; readonly title: string };
|
|
70
|
+
readonly api?: ApiItem & { postman: Request }; // TODO
|
|
71
|
+
readonly type?: string;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export interface Props extends DocsProps {
|
|
75
|
+
readonly route: ApiRoute;
|
|
76
|
+
readonly content: {
|
|
77
|
+
readonly frontMatter: FrontMatter;
|
|
78
|
+
readonly metadata: Metadata;
|
|
79
|
+
readonly contentTitle: string | undefined;
|
|
80
|
+
readonly toc: array | undefined;
|
|
81
|
+
(): JSX.Element;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const ApiItem: (props: Props) => JSX.Element;
|
|
86
|
+
export default ApiItem;
|
|
87
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
ProcessedSidebar,
|
|
10
|
+
SidebarItemDoc,
|
|
11
|
+
} from "@docusaurus/plugin-content-docs/src/sidebars/types";
|
|
12
|
+
import clsx from "clsx";
|
|
13
|
+
import uniq from "lodash/uniq";
|
|
14
|
+
|
|
15
|
+
import type {
|
|
16
|
+
SidebarOptions,
|
|
17
|
+
APIOptions,
|
|
18
|
+
ApiPageMetadata,
|
|
19
|
+
ApiMetadata,
|
|
20
|
+
} from "../types";
|
|
21
|
+
|
|
22
|
+
function isApiItem(item: ApiMetadata): item is ApiMetadata {
|
|
23
|
+
return item.type === "api";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function groupByTags(
|
|
27
|
+
items: ApiPageMetadata[],
|
|
28
|
+
sidebarOptions: SidebarOptions,
|
|
29
|
+
options: APIOptions
|
|
30
|
+
): ProcessedSidebar {
|
|
31
|
+
// TODO: Figure out how to handle these
|
|
32
|
+
// const intros = items.filter(isInfoItem).map((item) => {
|
|
33
|
+
// return {
|
|
34
|
+
// type: "link" as const,
|
|
35
|
+
// label: item.title,
|
|
36
|
+
// href: item.permalink,
|
|
37
|
+
// docId: item.id,
|
|
38
|
+
// };
|
|
39
|
+
// });
|
|
40
|
+
|
|
41
|
+
const { outputDir } = options;
|
|
42
|
+
const { sidebarCollapsed, sidebarCollapsible, customProps } = sidebarOptions;
|
|
43
|
+
|
|
44
|
+
const apiItems = items.filter(isApiItem);
|
|
45
|
+
|
|
46
|
+
// TODO: make sure we only take the first tag
|
|
47
|
+
const tags = uniq(
|
|
48
|
+
apiItems
|
|
49
|
+
.flatMap((item) => item.api.tags)
|
|
50
|
+
.filter((item): item is string => !!item)
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
// TODO: optimize this or make it a function
|
|
54
|
+
const basePath = outputDir
|
|
55
|
+
.slice(outputDir.indexOf("/", 1))
|
|
56
|
+
.replace(/^\/+/g, "");
|
|
57
|
+
|
|
58
|
+
function createDocItem(item: ApiPageMetadata): SidebarItemDoc {
|
|
59
|
+
const sidebar_label = item.frontMatter.sidebar_label;
|
|
60
|
+
const title = item.title;
|
|
61
|
+
const id = item.id;
|
|
62
|
+
return {
|
|
63
|
+
type: "doc" as const,
|
|
64
|
+
id: `${basePath}/${item.id}`,
|
|
65
|
+
label: (sidebar_label as string) ?? title ?? id,
|
|
66
|
+
customProps: customProps,
|
|
67
|
+
className: clsx(
|
|
68
|
+
{
|
|
69
|
+
"menu__list-item--deprecated": item.api.deprecated,
|
|
70
|
+
"api-method": !!item.api.method,
|
|
71
|
+
},
|
|
72
|
+
item.api.method
|
|
73
|
+
),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const tagged = tags
|
|
78
|
+
.map((tag) => {
|
|
79
|
+
return {
|
|
80
|
+
type: "category" as const,
|
|
81
|
+
label: tag,
|
|
82
|
+
collapsible: sidebarCollapsible,
|
|
83
|
+
collapsed: sidebarCollapsed,
|
|
84
|
+
items: apiItems
|
|
85
|
+
.filter((item) => !!item.api.tags?.includes(tag))
|
|
86
|
+
.map(createDocItem),
|
|
87
|
+
};
|
|
88
|
+
})
|
|
89
|
+
.filter((item) => item.items.length > 0); // Filter out any categories with no items.
|
|
90
|
+
|
|
91
|
+
// const untagged = [
|
|
92
|
+
// // TODO: determine if needed and how
|
|
93
|
+
// {
|
|
94
|
+
// type: "category" as const,
|
|
95
|
+
// label: "UNTAGGED",
|
|
96
|
+
// // collapsible: options.sidebarCollapsible, TODO: add option
|
|
97
|
+
// // collapsed: options.sidebarCollapsed, TODO: add option
|
|
98
|
+
// items: apiItems
|
|
99
|
+
// //@ts-ignore
|
|
100
|
+
// .filter(({ api }) => api.tags === undefined || api.tags.length === 0)
|
|
101
|
+
// .map(createDocItem),
|
|
102
|
+
// },
|
|
103
|
+
// ];
|
|
104
|
+
return [...tagged];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export default function generateSidebarSlice(
|
|
108
|
+
sidebarOptions: SidebarOptions,
|
|
109
|
+
options: APIOptions,
|
|
110
|
+
api: ApiMetadata[]
|
|
111
|
+
) {
|
|
112
|
+
let sidebarSlice: ProcessedSidebar = [];
|
|
113
|
+
if (sidebarOptions.groupPathsBy === "tags") {
|
|
114
|
+
sidebarSlice = groupByTags(
|
|
115
|
+
api as ApiPageMetadata[],
|
|
116
|
+
sidebarOptions,
|
|
117
|
+
options
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
return sidebarSlice;
|
|
121
|
+
}
|