docusaurus-plugin-openapi-docs 1.0.2 → 1.0.5

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.
Files changed (42) hide show
  1. package/README.md +106 -17
  2. package/lib/index.d.ts +7 -1
  3. package/lib/index.js +228 -18
  4. package/lib/markdown/createAuthentication.d.ts +2 -0
  5. package/lib/markdown/createAuthentication.js +139 -0
  6. package/lib/markdown/createParamsDetails.js +2 -0
  7. package/lib/markdown/createSchemaDetails.js +2 -0
  8. package/lib/markdown/index.d.ts +3 -2
  9. package/lib/markdown/index.js +10 -2
  10. package/lib/openapi/createExample.js +59 -49
  11. package/lib/openapi/openapi.d.ts +3 -3
  12. package/lib/openapi/openapi.js +71 -41
  13. package/lib/openapi/openapi.test.js +0 -6
  14. package/lib/openapi/utils/loadAndBundleSpec.d.ts +3 -0
  15. package/lib/openapi/utils/loadAndBundleSpec.js +44 -0
  16. package/lib/openapi/utils/types.d.ts +306 -0
  17. package/lib/openapi/utils/types.js +8 -0
  18. package/lib/options.d.ts +0 -2
  19. package/lib/options.js +36 -7
  20. package/lib/sidebars/index.d.ts +1 -1
  21. package/lib/sidebars/index.js +33 -30
  22. package/lib/sidebars/utils.d.ts +2 -0
  23. package/lib/sidebars/utils.js +31 -0
  24. package/lib/types.d.ts +34 -11
  25. package/package.json +10 -8
  26. package/src/index.ts +291 -20
  27. package/src/markdown/createAuthentication.ts +160 -0
  28. package/src/markdown/createParamsDetails.ts +2 -0
  29. package/src/markdown/createSchemaDetails.ts +2 -0
  30. package/src/markdown/index.ts +15 -2
  31. package/src/openapi/createExample.ts +59 -50
  32. package/src/openapi/openapi.test.ts +0 -6
  33. package/src/openapi/openapi.ts +85 -39
  34. package/src/openapi/utils/loadAndBundleSpec.ts +62 -0
  35. package/src/openapi/utils/types.ts +303 -0
  36. package/src/options.ts +41 -8
  37. package/src/sidebars/index.ts +40 -30
  38. package/src/sidebars/utils.ts +29 -0
  39. package/src/types.ts +35 -9
  40. package/src/openapi/__fixtures__/examples/yogurtstore/_category_.json +0 -4
  41. package/src/openapi/__fixtures__/examples/yogurtstore/froyo.yaml +0 -13
  42. package/src/openapi/__fixtures__/examples/yogurtstore/nested/nested.yaml +0 -13
@@ -0,0 +1,306 @@
1
+ declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
2
+ export interface OpenAPISpec {
3
+ openapi: string;
4
+ info: OpenAPIInfo;
5
+ servers?: OpenAPIServer[];
6
+ paths: OpenAPIPaths;
7
+ components?: OpenAPIComponents;
8
+ security?: OpenAPISecurityRequirement[];
9
+ tags?: OpenAPITag[];
10
+ externalDocs?: OpenAPIExternalDocumentation;
11
+ "x-webhooks"?: OpenAPIPaths;
12
+ webhooks?: OpenAPIPaths;
13
+ }
14
+ export interface OpenAPIInfo {
15
+ title: string;
16
+ version: string;
17
+ description?: string;
18
+ summary?: string;
19
+ termsOfService?: string;
20
+ contact?: OpenAPIContact;
21
+ license?: OpenAPILicense;
22
+ }
23
+ export interface OpenAPIServer {
24
+ url: string;
25
+ description?: string;
26
+ variables?: {
27
+ [name: string]: OpenAPIServerVariable;
28
+ };
29
+ }
30
+ export interface OpenAPIServerVariable {
31
+ enum?: string[];
32
+ default: string;
33
+ description?: string;
34
+ }
35
+ export interface OpenAPIPaths {
36
+ [path: string]: OpenAPIPath;
37
+ }
38
+ export interface OpenAPIRef {
39
+ $ref: string;
40
+ }
41
+ export declare type Referenced<T> = OpenAPIRef | T;
42
+ export interface OpenAPIPath {
43
+ summary?: string;
44
+ description?: string;
45
+ get?: OpenAPIOperation;
46
+ put?: OpenAPIOperation;
47
+ post?: OpenAPIOperation;
48
+ delete?: OpenAPIOperation;
49
+ options?: OpenAPIOperation;
50
+ head?: OpenAPIOperation;
51
+ patch?: OpenAPIOperation;
52
+ trace?: OpenAPIOperation;
53
+ servers?: OpenAPIServer[];
54
+ parameters?: Array<Referenced<OpenAPIParameter>>;
55
+ $ref?: string;
56
+ }
57
+ export interface OpenAPIXCodeSample {
58
+ lang: string;
59
+ label?: string;
60
+ source: string;
61
+ }
62
+ export interface OpenAPIOperation {
63
+ tags?: string[];
64
+ summary?: string;
65
+ description?: string;
66
+ externalDocs?: OpenAPIExternalDocumentation;
67
+ operationId?: string;
68
+ parameters?: Array<Referenced<OpenAPIParameter>>;
69
+ requestBody?: Referenced<OpenAPIRequestBody>;
70
+ responses: OpenAPIResponses;
71
+ callbacks?: {
72
+ [name: string]: Referenced<OpenAPICallback>;
73
+ };
74
+ deprecated?: boolean;
75
+ security?: OpenAPISecurityRequirement[];
76
+ servers?: OpenAPIServer[];
77
+ "x-codeSamples"?: OpenAPIXCodeSample[];
78
+ "x-code-samples"?: OpenAPIXCodeSample[];
79
+ }
80
+ export interface OpenAPIParameter {
81
+ name: string;
82
+ in?: OpenAPIParameterLocation;
83
+ description?: string;
84
+ required?: boolean;
85
+ deprecated?: boolean;
86
+ allowEmptyValue?: boolean;
87
+ style?: OpenAPIParameterStyle;
88
+ explode?: boolean;
89
+ allowReserved?: boolean;
90
+ schema?: Referenced<OpenAPISchema>;
91
+ example?: any;
92
+ examples?: {
93
+ [media: string]: Referenced<OpenAPIExample>;
94
+ };
95
+ content?: {
96
+ [media: string]: OpenAPIMediaType;
97
+ };
98
+ encoding?: Record<string, OpenAPIEncoding>;
99
+ const?: any;
100
+ }
101
+ export interface OpenAPIExample {
102
+ value: any;
103
+ summary?: string;
104
+ description?: string;
105
+ externalValue?: string;
106
+ }
107
+ export interface OpenAPISchema {
108
+ $ref?: string;
109
+ type?: string | string[];
110
+ properties?: {
111
+ [name: string]: OpenAPISchema;
112
+ };
113
+ patternProperties?: {
114
+ [name: string]: OpenAPISchema;
115
+ };
116
+ additionalProperties?: boolean | OpenAPISchema;
117
+ unevaluatedProperties?: boolean | OpenAPISchema;
118
+ description?: string;
119
+ default?: any;
120
+ items?: OpenAPISchema | OpenAPISchema[] | boolean;
121
+ required?: string[];
122
+ readOnly?: boolean;
123
+ writeOnly?: boolean;
124
+ deprecated?: boolean;
125
+ format?: string;
126
+ externalDocs?: OpenAPIExternalDocumentation;
127
+ discriminator?: OpenAPIDiscriminator;
128
+ nullable?: boolean;
129
+ oneOf?: OpenAPISchema[];
130
+ anyOf?: OpenAPISchema[];
131
+ allOf?: OpenAPISchema[];
132
+ not?: OpenAPISchema;
133
+ title?: string;
134
+ multipleOf?: number;
135
+ maximum?: number;
136
+ exclusiveMaximum?: boolean | number;
137
+ minimum?: number;
138
+ exclusiveMinimum?: boolean | number;
139
+ maxLength?: number;
140
+ minLength?: number;
141
+ pattern?: string;
142
+ maxItems?: number;
143
+ minItems?: number;
144
+ uniqueItems?: boolean;
145
+ maxProperties?: number;
146
+ minProperties?: number;
147
+ enum?: any[];
148
+ example?: any;
149
+ if?: OpenAPISchema;
150
+ else?: OpenAPISchema;
151
+ then?: OpenAPISchema;
152
+ examples?: any[];
153
+ const?: string;
154
+ contentEncoding?: string;
155
+ contentMediaType?: string;
156
+ prefixItems?: OpenAPISchema[];
157
+ additionalItems?: OpenAPISchema | boolean;
158
+ }
159
+ export interface OpenAPIDiscriminator {
160
+ propertyName: string;
161
+ mapping?: {
162
+ [name: string]: string;
163
+ };
164
+ "x-explicitMappingOnly"?: boolean;
165
+ }
166
+ export interface OpenAPIMediaType {
167
+ schema?: Referenced<OpenAPISchema>;
168
+ example?: any;
169
+ examples?: {
170
+ [name: string]: Referenced<OpenAPIExample>;
171
+ };
172
+ encoding?: {
173
+ [field: string]: OpenAPIEncoding;
174
+ };
175
+ }
176
+ export interface OpenAPIEncoding {
177
+ contentType: string;
178
+ headers?: {
179
+ [name: string]: Referenced<OpenAPIHeader>;
180
+ };
181
+ style: OpenAPIParameterStyle;
182
+ explode: boolean;
183
+ allowReserved: boolean;
184
+ }
185
+ export declare type OpenAPIParameterLocation = "query" | "header" | "path" | "cookie";
186
+ export declare type OpenAPIParameterStyle = "matrix" | "label" | "form" | "simple" | "spaceDelimited" | "pipeDelimited" | "deepObject";
187
+ export interface OpenAPIRequestBody {
188
+ description?: string;
189
+ required?: boolean;
190
+ content: {
191
+ [mime: string]: OpenAPIMediaType;
192
+ };
193
+ "x-examples"?: {
194
+ [mime: string]: {
195
+ [name: string]: Referenced<OpenAPIExample>;
196
+ };
197
+ };
198
+ "x-example"?: {
199
+ [mime: string]: any;
200
+ };
201
+ }
202
+ export interface OpenAPIResponses {
203
+ [code: string]: Referenced<OpenAPIResponse>;
204
+ }
205
+ export interface OpenAPIResponse extends Pick<OpenAPIRequestBody, "description" | "x-examples" | "x-example"> {
206
+ headers?: {
207
+ [name: string]: Referenced<OpenAPIHeader>;
208
+ };
209
+ links?: {
210
+ [name: string]: Referenced<OpenAPILink>;
211
+ };
212
+ content?: {
213
+ [mime: string]: OpenAPIMediaType;
214
+ };
215
+ }
216
+ export interface OpenAPILink {
217
+ $ref?: string;
218
+ }
219
+ export declare type OpenAPIHeader = Omit<OpenAPIParameter, "in" | "name">;
220
+ export interface OpenAPICallback {
221
+ [name: string]: OpenAPIPath;
222
+ }
223
+ export interface OpenAPIComponents {
224
+ schemas?: {
225
+ [name: string]: Referenced<OpenAPISchema>;
226
+ };
227
+ responses?: {
228
+ [name: string]: Referenced<OpenAPIResponse>;
229
+ };
230
+ parameters?: {
231
+ [name: string]: Referenced<OpenAPIParameter>;
232
+ };
233
+ examples?: {
234
+ [name: string]: Referenced<OpenAPIExample>;
235
+ };
236
+ requestBodies?: {
237
+ [name: string]: Referenced<OpenAPIRequestBody>;
238
+ };
239
+ headers?: {
240
+ [name: string]: Referenced<OpenAPIHeader>;
241
+ };
242
+ securitySchemes?: {
243
+ [name: string]: Referenced<OpenAPISecurityScheme>;
244
+ };
245
+ links?: {
246
+ [name: string]: Referenced<OpenAPILink>;
247
+ };
248
+ callbacks?: {
249
+ [name: string]: Referenced<OpenAPICallback>;
250
+ };
251
+ }
252
+ export interface OpenAPISecurityRequirement {
253
+ [name: string]: string[];
254
+ }
255
+ export interface OpenAPISecurityScheme {
256
+ type: "apiKey" | "http" | "oauth2" | "openIdConnect";
257
+ description?: string;
258
+ name?: string;
259
+ in?: "query" | "header" | "cookie";
260
+ scheme?: string;
261
+ bearerFormat: string;
262
+ flows: {
263
+ implicit?: {
264
+ refreshUrl?: string;
265
+ scopes: Record<string, string>;
266
+ authorizationUrl: string;
267
+ };
268
+ password?: {
269
+ refreshUrl?: string;
270
+ scopes: Record<string, string>;
271
+ tokenUrl: string;
272
+ };
273
+ clientCredentials?: {
274
+ refreshUrl?: string;
275
+ scopes: Record<string, string>;
276
+ tokenUrl: string;
277
+ };
278
+ authorizationCode?: {
279
+ refreshUrl?: string;
280
+ scopes: Record<string, string>;
281
+ tokenUrl: string;
282
+ };
283
+ };
284
+ openIdConnectUrl?: string;
285
+ }
286
+ export interface OpenAPITag {
287
+ name: string;
288
+ description?: string;
289
+ externalDocs?: OpenAPIExternalDocumentation;
290
+ "x-displayName"?: string;
291
+ }
292
+ export interface OpenAPIExternalDocumentation {
293
+ description?: string;
294
+ url: string;
295
+ }
296
+ export interface OpenAPIContact {
297
+ name?: string;
298
+ url?: string;
299
+ email?: string;
300
+ }
301
+ export interface OpenAPILicense {
302
+ name: string;
303
+ url?: string;
304
+ identifier?: string;
305
+ }
306
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /* ============================================================================
3
+ * Copyright (c) Palo Alto Networks
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ * ========================================================================== */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
package/lib/options.d.ts CHANGED
@@ -1,4 +1,2 @@
1
1
  import { Joi } from "@docusaurus/utils-validation";
2
- import type { PluginOptions } from "./types";
3
- export declare const DEFAULT_OPTIONS: PluginOptions;
4
2
  export declare const OptionsSchema: Joi.ObjectSchema<any>;
package/lib/options.js CHANGED
@@ -6,13 +6,42 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  * ========================================================================== */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.OptionsSchema = exports.DEFAULT_OPTIONS = void 0;
9
+ exports.OptionsSchema = void 0;
10
10
  const utils_validation_1 = require("@docusaurus/utils-validation");
11
- exports.DEFAULT_OPTIONS = {
12
- id: "default",
13
- config: {},
14
- };
11
+ const sidebarOptions = utils_validation_1.Joi.object({
12
+ groupPathsBy: utils_validation_1.Joi.string().valid("tag"),
13
+ categoryLinkSource: utils_validation_1.Joi.string().valid("tag", "info"),
14
+ customProps: utils_validation_1.Joi.object(),
15
+ sidebarCollapsible: utils_validation_1.Joi.boolean(),
16
+ sidebarCollapsed: utils_validation_1.Joi.boolean(),
17
+ });
15
18
  exports.OptionsSchema = utils_validation_1.Joi.object({
16
- id: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.id),
17
- config: utils_validation_1.Joi.object().default(exports.DEFAULT_OPTIONS.config),
19
+ id: utils_validation_1.Joi.string().required(),
20
+ docPluginId: utils_validation_1.Joi.string().required(),
21
+ config: utils_validation_1.Joi.object()
22
+ .pattern(/^/, utils_validation_1.Joi.object({
23
+ specPath: utils_validation_1.Joi.string().required(),
24
+ outputDir: utils_validation_1.Joi.string().required(),
25
+ template: utils_validation_1.Joi.string(),
26
+ sidebarOptions: sidebarOptions,
27
+ version: utils_validation_1.Joi.string().when("versions", {
28
+ is: utils_validation_1.Joi.exist(),
29
+ then: utils_validation_1.Joi.required(),
30
+ }),
31
+ label: utils_validation_1.Joi.string().when("versions", {
32
+ is: utils_validation_1.Joi.exist(),
33
+ then: utils_validation_1.Joi.required(),
34
+ }),
35
+ baseUrl: utils_validation_1.Joi.string().when("versions", {
36
+ is: utils_validation_1.Joi.exist(),
37
+ then: utils_validation_1.Joi.required(),
38
+ }),
39
+ versions: utils_validation_1.Joi.object().pattern(/^/, utils_validation_1.Joi.object({
40
+ specPath: utils_validation_1.Joi.string().required(),
41
+ outputDir: utils_validation_1.Joi.string().required(),
42
+ label: utils_validation_1.Joi.string().required(),
43
+ baseUrl: utils_validation_1.Joi.string().required(),
44
+ })),
45
+ }))
46
+ .required(),
18
47
  });
@@ -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[]): ProcessedSidebar;
4
+ export default function generateSidebarSlice(sidebarOptions: SidebarOptions, options: APIOptions, api: ApiMetadata[], tags: TagObject[], docPath: string): ProcessedSidebar;
@@ -18,7 +18,7 @@ function isApiItem(item) {
18
18
  function isInfoItem(item) {
19
19
  return item.type === "info";
20
20
  }
21
- function groupByTags(items, sidebarOptions, options, tags) {
21
+ function groupByTags(items, sidebarOptions, options, tags, docPath) {
22
22
  const { outputDir } = options;
23
23
  const { sidebarCollapsed, sidebarCollapsible, customProps, categoryLinkSource, } = sidebarOptions;
24
24
  const apiItems = items.filter(isApiItem);
@@ -35,10 +35,9 @@ function groupByTags(items, sidebarOptions, options, tags) {
35
35
  const apiTags = (0, uniq_1.default)(apiItems
36
36
  .flatMap((item) => item.api.tags)
37
37
  .filter((item) => !!item));
38
- // TODO: optimize this or make it a function
39
- const basePath = outputDir
40
- .slice(outputDir.indexOf("/", 1))
41
- .replace(/^\/+/g, "");
38
+ const basePath = docPath
39
+ ? outputDir.split(docPath)[1].replace(/^\/+/g, "")
40
+ : outputDir.slice(outputDir.indexOf("/", 1)).replace(/^\/+/g, "");
42
41
  function createDocItem(item) {
43
42
  var _a, _b;
44
43
  const sidebar_label = item.frontMatter.sidebar_label;
@@ -46,7 +45,7 @@ function groupByTags(items, sidebarOptions, options, tags) {
46
45
  const id = item.id;
47
46
  return {
48
47
  type: "doc",
49
- id: `${basePath}/${item.id}`,
48
+ id: basePath === "" || undefined ? `${item.id}` : `${basePath}/${item.id}`,
50
49
  label: (_b = (_a = sidebar_label) !== null && _a !== void 0 ? _a : title) !== null && _b !== void 0 ? _b : id,
51
50
  customProps: customProps,
52
51
  className: (0, clsx_1.default)({
@@ -67,7 +66,7 @@ function groupByTags(items, sidebarOptions, options, tags) {
67
66
  const tagged = apiTags
68
67
  .map((tag) => {
69
68
  // Map info object to tag
70
- const infoObject = intros.find((i) => i.tags.includes(tag));
69
+ const taggedInfoObject = intros.find((i) => i.tags ? i.tags.includes(tag) : undefined);
71
70
  const tagObject = tags.flat().find((t) => {
72
71
  var _a;
73
72
  return (_a = (tag === t.name || tag === t["x-displayName"])) !== null && _a !== void 0 ? _a : {
@@ -77,20 +76,18 @@ function groupByTags(items, sidebarOptions, options, tags) {
77
76
  });
78
77
  // TODO: perhaps move this into a getLinkConfig() function
79
78
  let linkConfig = undefined;
80
- if (infoObject !== undefined && categoryLinkSource === "info") {
79
+ if (taggedInfoObject !== undefined && categoryLinkSource === "info") {
81
80
  linkConfig = {
82
81
  type: "doc",
83
- id: `${basePath}/${infoObject.id}`,
82
+ id: `${basePath}/${taggedInfoObject.id}`,
84
83
  };
85
84
  }
86
85
  // TODO: perhaps move this into a getLinkConfig() function
87
86
  if (tagObject !== undefined && categoryLinkSource === "tag") {
88
- const linkDescription = tagObject === null || tagObject === void 0 ? void 0 : tagObject.description;
87
+ const tagId = (0, lodash_1.kebabCase)(tagObject.name);
89
88
  linkConfig = {
90
- type: "generated-index",
91
- title: tag,
92
- description: linkDescription,
93
- slug: "/category/" + (0, lodash_1.kebabCase)(tag),
89
+ type: "doc",
90
+ id: `${basePath}/${tagId}`,
94
91
  };
95
92
  }
96
93
  // Default behavior
@@ -113,29 +110,35 @@ function groupByTags(items, sidebarOptions, options, tags) {
113
110
  };
114
111
  })
115
112
  .filter((item) => item.items.length > 0); // Filter out any categories with no items.
116
- // TODO: determine how we want to handle these
117
- // const untagged = [
118
- // {
119
- // type: "category" as const,
120
- // label: "UNTAGGED",
121
- // collapsible: sidebarCollapsible,
122
- // collapsed: sidebarCollapsed,
123
- // items: apiItems
124
- // .filter(({ api }) => api.tags === undefined || api.tags.length === 0)
125
- // .map(createDocItem),
126
- // },
127
- // ];
113
+ // Handle items with no tag
114
+ const untaggedItems = apiItems
115
+ .filter(({ api }) => api.tags === undefined || api.tags.length === 0)
116
+ .map(createDocItem);
117
+ let untagged = [];
118
+ if (untaggedItems.length > 0) {
119
+ untagged = [
120
+ {
121
+ type: "category",
122
+ label: "UNTAGGED",
123
+ collapsible: sidebarCollapsible,
124
+ collapsed: sidebarCollapsed,
125
+ items: apiItems
126
+ .filter(({ api }) => api.tags === undefined || api.tags.length === 0)
127
+ .map(createDocItem),
128
+ },
129
+ ];
130
+ }
128
131
  // Shift root intro doc to top of sidebar
129
132
  // TODO: Add input validation for categoryLinkSource options
130
133
  if (rootIntroDoc && categoryLinkSource !== "info") {
131
134
  tagged.unshift(rootIntroDoc);
132
135
  }
133
- return [...tagged];
136
+ return [...tagged, ...untagged];
134
137
  }
135
- function generateSidebarSlice(sidebarOptions, options, api, tags) {
138
+ function generateSidebarSlice(sidebarOptions, options, api, tags, docPath) {
136
139
  let sidebarSlice = [];
137
- if (sidebarOptions.groupPathsBy === "tags") {
138
- sidebarSlice = groupByTags(api, sidebarOptions, options, tags);
140
+ if (sidebarOptions.groupPathsBy === "tag") {
141
+ sidebarSlice = groupByTags(api, sidebarOptions, options, tags, docPath);
139
142
  }
140
143
  return sidebarSlice;
141
144
  }
@@ -0,0 +1,2 @@
1
+ export declare function versionSelector(versions: object[]): string;
2
+ export declare function versionCrumb(version: string): string;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /* ============================================================================
3
+ * Copyright (c) Palo Alto Networks
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ * ========================================================================== */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.versionCrumb = exports.versionSelector = void 0;
10
+ const mustache_1 = require("mustache");
11
+ function versionSelector(versions) {
12
+ const template = `<div class="dropdown dropdown--hoverable dropdown--right">
13
+ <button class="button button--block button--sm button--secondary"><span>Select API Version</span></button>
14
+ <ul class="dropdown__menu">
15
+ {{#.}}<li><a class="dropdown__link" href="{{{baseUrl}}}">{{{label}}}</a></li>{{/.}}
16
+ </ul>
17
+ </div>
18
+ `;
19
+ const view = (0, mustache_1.render)(template, versions);
20
+ return view;
21
+ }
22
+ exports.versionSelector = versionSelector;
23
+ function versionCrumb(version) {
24
+ const template = `<ul style="display: flex;" class="breadcrumbs breadcrumbs--sm">
25
+ <li style="margin-left: auto; margin-right: 0;" class="breadcrumbs__item breadcrumbs__item--active">
26
+ <a class="breadcrumbs__link"><span>{{{.}}}</span></a></li></ul>
27
+ `;
28
+ const view = (0, mustache_1.render)(template, version);
29
+ return view;
30
+ }
31
+ exports.versionCrumb = versionCrumb;
package/lib/types.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import type Request from "@paloaltonetworks/postman-collection";
2
- import { InfoObject, OperationObject, SecuritySchemeObject } from "./openapi/types";
2
+ import { InfoObject, OperationObject, SecuritySchemeObject, TagObject } from "./openapi/types";
3
3
  export type { PropSidebarItemCategory, SidebarItemLink, PropSidebar, PropSidebarItem, } from "@docusaurus/plugin-content-docs-types";
4
4
  export interface PluginOptions {
5
5
  id?: string;
6
+ docPluginId: string;
6
7
  config: {
7
8
  [key: string]: APIOptions;
8
9
  };
@@ -12,17 +13,40 @@ export interface APIOptions {
12
13
  outputDir: string;
13
14
  template?: string;
14
15
  sidebarOptions?: SidebarOptions;
16
+ version?: string;
17
+ label?: string;
18
+ baseUrl?: string;
19
+ versions?: {
20
+ [key: string]: APIVersionOptions;
21
+ };
22
+ }
23
+ export interface SidebarOptions {
24
+ groupPathsBy?: string;
25
+ categoryLinkSource?: string;
26
+ customProps?: {
27
+ [key: string]: unknown;
28
+ };
29
+ sidebarCollapsible?: boolean;
30
+ sidebarCollapsed?: boolean;
31
+ }
32
+ export interface APIVersionOptions {
33
+ specPath: string;
34
+ outputDir: string;
35
+ label: string;
36
+ baseUrl: string;
15
37
  }
16
38
  export interface LoadedContent {
17
39
  loadedApi: ApiMetadata[];
18
40
  }
19
- export declare type ApiMetadata = ApiPageMetadata | InfoPageMetadata;
41
+ export declare type ApiMetadata = ApiPageMetadata | InfoPageMetadata | TagPageMetadata;
20
42
  export interface ApiMetadataBase {
21
43
  sidebar?: string;
22
44
  previous?: ApiNavLink;
23
45
  next?: ApiNavLink;
24
46
  id: string;
25
47
  unversionedId: string;
48
+ infoId?: string;
49
+ infoPath?: string;
26
50
  title: string;
27
51
  description: string;
28
52
  source: string;
@@ -52,18 +76,17 @@ export interface InfoPageMetadata extends ApiMetadataBase {
52
76
  type: "info";
53
77
  info: ApiInfo;
54
78
  markdown?: string;
79
+ securitySchemes?: {
80
+ [key: string]: SecuritySchemeObject;
81
+ };
82
+ }
83
+ export interface TagPageMetadata extends ApiMetadataBase {
84
+ type: "tag";
85
+ tag: TagObject;
86
+ markdown?: string;
55
87
  }
56
88
  export declare type ApiInfo = InfoObject;
57
89
  export interface ApiNavLink {
58
90
  title: string;
59
91
  permalink: string;
60
92
  }
61
- export interface SidebarOptions {
62
- groupPathsBy?: string;
63
- categoryLinkSource?: string;
64
- customProps?: {
65
- [key: string]: unknown;
66
- };
67
- sidebarCollapsible?: boolean;
68
- sidebarCollapsed?: boolean;
69
- }
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.0.2",
4
+ "version": "1.0.5",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -28,20 +28,21 @@
28
28
  "watch": "tsc --watch"
29
29
  },
30
30
  "devDependencies": {
31
- "@docusaurus/module-type-aliases": "2.0.0-beta.18",
32
- "@docusaurus/types": "2.0.0-beta.18",
31
+ "@docusaurus/module-type-aliases": "2.0.0-beta.21",
32
+ "@docusaurus/types": "2.0.0-beta.21",
33
33
  "@types/fs-extra": "^9.0.13",
34
34
  "@types/json-schema": "^7.0.9",
35
35
  "@types/lodash": "^4.14.176",
36
36
  "utility-types": "^3.10.0"
37
37
  },
38
38
  "dependencies": {
39
- "@docusaurus/mdx-loader": "2.0.0-beta.18",
40
- "@docusaurus/plugin-content-docs": "2.0.0-beta.18",
41
- "@docusaurus/utils": "2.0.0-beta.18",
42
- "@docusaurus/utils-validation": "2.0.0-beta.18",
39
+ "@docusaurus/mdx-loader": "2.0.0-beta.21",
40
+ "@docusaurus/plugin-content-docs": "2.0.0-beta.21",
41
+ "@docusaurus/utils": "2.0.0-beta.21",
42
+ "@docusaurus/utils-validation": "2.0.0-beta.21",
43
43
  "@paloaltonetworks/openapi-to-postmanv2": "3.1.0-hotfix.1",
44
44
  "@paloaltonetworks/postman-collection": "^4.1.0",
45
+ "@redocly/openapi-core": "^1.0.0-beta.100",
45
46
  "@types/js-yaml": "^4.0.5",
46
47
  "@types/mustache": "^4.1.2",
47
48
  "chalk": "^4.1.2",
@@ -52,6 +53,7 @@
52
53
  "json-schema-merge-allof": "^0.8.1",
53
54
  "lodash": "^4.17.20",
54
55
  "mustache": "^4.2.0",
56
+ "swagger2openapi": "^7.0.8",
55
57
  "webpack": "^5.61.0"
56
58
  },
57
59
  "peerDependencies": {
@@ -60,5 +62,5 @@
60
62
  "engines": {
61
63
  "node": ">=14"
62
64
  },
63
- "gitHead": "526f2d10bc187bc7095ac70d5b1453b9b92c114f"
65
+ "gitHead": "fe58997d349cdab4f113c4a7449cd650882dcab6"
64
66
  }