docusaurus-plugin-openapi-docs 2.0.0-beta.2 → 2.0.0-beta.4

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 (39) hide show
  1. package/README.md +2 -1
  2. package/lib/index.js +20 -7
  3. package/lib/markdown/createAuthorization.d.ts +1 -0
  4. package/lib/markdown/createAuthorization.js +16 -0
  5. package/lib/markdown/createParamsDetails.js +2 -1
  6. package/lib/markdown/createRequestHeader.d.ts +1 -0
  7. package/lib/markdown/createRequestHeader.js +13 -0
  8. package/lib/markdown/createRequestSchema.d.ts +1 -8
  9. package/lib/markdown/createRequestSchema.js +21 -633
  10. package/lib/markdown/createResponseSchema.d.ts +1 -8
  11. package/lib/markdown/createResponseSchema.js +8 -626
  12. package/lib/markdown/createSchema.d.ts +12 -0
  13. package/lib/markdown/createSchema.js +647 -0
  14. package/lib/markdown/createVendorExtensions.d.ts +1 -0
  15. package/lib/markdown/createVendorExtensions.js +25 -0
  16. package/lib/markdown/index.d.ts +1 -1
  17. package/lib/markdown/index.js +11 -4
  18. package/lib/openapi/createRequestExample.js +3 -3
  19. package/lib/openapi/createResponseExample.js +3 -3
  20. package/lib/openapi/openapi.js +22 -0
  21. package/lib/openapi/utils/loadAndResolveSpec.js +9 -2
  22. package/lib/options.js +1 -0
  23. package/lib/types.d.ts +2 -0
  24. package/package.json +9 -17
  25. package/src/index.ts +21 -8
  26. package/src/markdown/createAuthorization.ts +13 -0
  27. package/src/markdown/createParamsDetails.ts +2 -1
  28. package/src/markdown/createRequestHeader.ts +10 -0
  29. package/src/markdown/createRequestSchema.ts +20 -839
  30. package/src/markdown/createResponseSchema.ts +8 -834
  31. package/src/markdown/createSchema.ts +850 -0
  32. package/src/markdown/createVendorExtensions.ts +22 -0
  33. package/src/markdown/index.ts +13 -3
  34. package/src/openapi/createRequestExample.ts +1 -1
  35. package/src/openapi/createResponseExample.ts +1 -1
  36. package/src/openapi/openapi.ts +26 -0
  37. package/src/openapi/utils/loadAndResolveSpec.ts +10 -1
  38. package/src/options.ts +1 -0
  39. package/src/types.ts +2 -0
package/README.md CHANGED
@@ -22,7 +22,7 @@ The `docusaurus-plugin-openapi-docs` package extends the Docusaurus CLI with com
22
22
 
23
23
  Key Features:
24
24
 
25
- - **Compatible:** Works with Swagger 2.0 and OpenAPI 3.x.
25
+ - **Compatible:** Works with Swagger 2.0 and OpenAPI 3.0.
26
26
  - **Fast:** Convert large OpenAPI specs into MDX docs in seconds. 🔥
27
27
  - **Stylish:** Based on the same [Infima styling framework](https://infima.dev/) that powers the Docusaurus UI.
28
28
  - **Capable:** Supports single, multi and _even micro_ OpenAPI specs.
@@ -125,6 +125,7 @@ The `docusaurus-plugin-openapi-docs` plugin can be configured with the following
125
125
  | `template` | `string` | `null` | _Optional:_ Customize MDX content with a desired template. |
126
126
  | `downloadUrl` | `string` | `null` | _Optional:_ Designated URL for downloading OpenAPI specification. (requires `info` section/doc) |
127
127
  | `hideSendButton` | `boolean` | `null` | _Optional:_ If set to `true`, hides the "Send API Request" button in API demo panel |
128
+ | `showExtensions` | `boolean` | `null` | _Optional:_ If set to `true`, renders operation-level vendor-extensions in description. |
128
129
  | `sidebarOptions` | `object` | `null` | _Optional:_ Set of options for sidebar configuration. See below for a list of supported options. |
129
130
  | `version` | `string` | `null` | _Optional:_ Version assigned to single or micro-spec API specified in `specPath`. |
130
131
  | `label` | `string` | `null` | _Optional:_ Version label used when generating version selector dropdown menu. |
package/lib/index.js CHANGED
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getDocsPluginConfig = exports.isURL = void 0;
13
13
  const fs_1 = __importDefault(require("fs"));
14
14
  const path_1 = __importDefault(require("path"));
15
+ const zlib_1 = __importDefault(require("zlib"));
15
16
  const utils_1 = require("@docusaurus/utils");
16
17
  const chalk_1 = __importDefault(require("chalk"));
17
18
  const mustache_1 = require("mustache");
@@ -152,6 +153,9 @@ proxy: {{{frontMatter.proxy}}}
152
153
  {{#frontMatter.hide_send_button}}
153
154
  hide_send_button: true
154
155
  {{/frontMatter.hide_send_button}}
156
+ {{#frontMatter.show_extensions}}
157
+ show_extensions: true
158
+ {{/frontMatter.show_extensions}}
155
159
  ---
156
160
 
157
161
  {{{markdown}}}
@@ -196,14 +200,17 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
196
200
  item.downloadUrl = downloadUrl;
197
201
  }
198
202
  }
199
- const markdown = item.type === "api"
200
- ? (0, markdown_1.createApiPageMD)(item)
201
- : item.type === "info"
202
- ? (0, markdown_1.createInfoPageMD)(item)
203
- : (0, markdown_1.createTagPageMD)(item);
204
- item.markdown = markdown;
205
203
  if (item.type === "api") {
206
- item.json = JSON.stringify(item.api);
204
+ // opportunity to compress JSON
205
+ // const serialize = (o: any) => {
206
+ // return zlib.deflateSync(JSON.stringify(o)).toString("base64");
207
+ // };
208
+ // const deserialize = (s: any) => {
209
+ // return zlib.inflateSync(Buffer.from(s, "base64")).toString();
210
+ // };
211
+ item.json = zlib_1.default
212
+ .deflateSync(JSON.stringify(item.api))
213
+ .toString("base64");
207
214
  let infoBasePath = `${outputDir}/${item.infoId}`;
208
215
  if (docRouteBasePath) {
209
216
  infoBasePath = `${docRouteBasePath}/${outputDir
@@ -213,6 +220,12 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
213
220
  if (item.infoId)
214
221
  item.infoPath = infoBasePath;
215
222
  }
223
+ const markdown = item.type === "api"
224
+ ? (0, markdown_1.createApiPageMD)(item)
225
+ : item.type === "info"
226
+ ? (0, markdown_1.createInfoPageMD)(item)
227
+ : (0, markdown_1.createTagPageMD)(item);
228
+ item.markdown = markdown;
216
229
  const view = (0, mustache_1.render)(mdTemplate, item);
217
230
  const utils = (0, mustache_1.render)(infoMdTemplate, item);
218
231
  // eslint-disable-next-line testing-library/render-result-naming-convention
@@ -0,0 +1 @@
1
+ export declare function createAuthorization(infoPath: string): string[] | undefined;
@@ -0,0 +1,16 @@
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.createAuthorization = void 0;
10
+ const utils_1 = require("./utils");
11
+ function createAuthorization(infoPath) {
12
+ if (!infoPath)
13
+ return undefined;
14
+ return [(0, utils_1.create)("SecuritySchemes", { infoPath: infoPath }), "\n\n"];
15
+ }
16
+ exports.createAuthorization = createAuthorization;
@@ -26,7 +26,8 @@ function createParamsDetails({ parameters, type }) {
26
26
  children: [
27
27
  (0, createDetailsSummary_1.createDetailsSummary)({
28
28
  children: [
29
- (0, utils_1.create)("strong", {
29
+ (0, utils_1.create)("h3", {
30
+ className: "openapi-markdown__details-summary-header-params",
30
31
  children: `${type.charAt(0).toUpperCase() + type.slice(1)} Parameters`,
31
32
  }),
32
33
  ],
@@ -0,0 +1 @@
1
+ export declare function createRequestHeader(header: string): string;
@@ -0,0 +1,13 @@
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.createRequestHeader = void 0;
10
+ function createRequestHeader(header) {
11
+ return `## ${header}\n\n`;
12
+ }
13
+ exports.createRequestHeader = createRequestHeader;
@@ -1,11 +1,4 @@
1
- import { MediaTypeObject, SchemaObject } from "../openapi/types";
2
- /**
3
- * Returns a merged representation of allOf array of schemas.
4
- */
5
- export declare function mergeAllOf(allOf: SchemaObject[]): {
6
- mergedSchemas: any;
7
- required: any;
8
- };
1
+ import { MediaTypeObject } from "../openapi/types";
9
2
  interface Props {
10
3
  style?: any;
11
4
  title: string;