docusaurus-plugin-openapi-docs 1.0.0 → 1.0.3

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 (58) hide show
  1. package/README.md +8 -7
  2. package/lib/index.d.ts +1 -0
  3. package/lib/index.js +80 -9
  4. package/lib/markdown/createAuthentication.d.ts +2 -0
  5. package/lib/markdown/createAuthentication.js +139 -0
  6. package/lib/markdown/createContactInfo.d.ts +2 -0
  7. package/lib/markdown/createContactInfo.js +49 -0
  8. package/lib/markdown/createLicense.d.ts +2 -0
  9. package/lib/markdown/createLicense.js +33 -0
  10. package/lib/markdown/createSchemaDetails.js +4 -1
  11. package/lib/markdown/createStatusCodes.js +1 -1
  12. package/lib/markdown/createTermsOfService.d.ts +1 -0
  13. package/lib/markdown/createTermsOfService.js +32 -0
  14. package/lib/markdown/index.d.ts +3 -2
  15. package/lib/markdown/index.js +17 -3
  16. package/lib/openapi/createExample.js +59 -49
  17. package/lib/openapi/openapi.d.ts +5 -4
  18. package/lib/openapi/openapi.js +94 -50
  19. package/lib/openapi/openapi.test.js +0 -6
  20. package/lib/openapi/types.d.ts +5 -1
  21. package/lib/openapi/utils/loadAndBundleSpec.d.ts +3 -0
  22. package/lib/openapi/utils/loadAndBundleSpec.js +44 -0
  23. package/lib/openapi/utils/types.d.ts +306 -0
  24. package/lib/{markdown/createRequestBodyTable.js → openapi/utils/types.js} +0 -6
  25. package/lib/sidebars/index.d.ts +2 -1
  26. package/lib/sidebars/index.js +87 -30
  27. package/lib/types.d.ts +14 -3
  28. package/package.json +19 -11
  29. package/src/index.ts +108 -11
  30. package/src/markdown/createAuthentication.ts +160 -0
  31. package/src/markdown/createContactInfo.ts +52 -0
  32. package/src/markdown/createLicense.ts +34 -0
  33. package/src/markdown/createSchemaDetails.ts +6 -2
  34. package/src/markdown/createStatusCodes.ts +1 -1
  35. package/src/markdown/createTermsOfService.ts +30 -0
  36. package/src/markdown/index.ts +23 -3
  37. package/src/openapi/createExample.ts +59 -50
  38. package/src/openapi/openapi.test.ts +0 -6
  39. package/src/openapi/openapi.ts +115 -53
  40. package/src/openapi/types.ts +5 -1
  41. package/src/openapi/utils/loadAndBundleSpec.ts +62 -0
  42. package/src/openapi/utils/types.ts +303 -0
  43. package/src/{markdown/createRequestBodyTable.ts → postman-collection.d.ts} +2 -9
  44. package/src/sidebars/index.ts +108 -31
  45. package/src/types.ts +15 -3
  46. package/lib/markdown/createFullWidthTable.d.ts +0 -2
  47. package/lib/markdown/createFullWidthTable.js +0 -18
  48. package/lib/markdown/createParamsTable.d.ts +0 -7
  49. package/lib/markdown/createParamsTable.js +0 -80
  50. package/lib/markdown/createRequestBodyTable.d.ts +0 -6
  51. package/lib/markdown/createSchemaTable.d.ts +0 -14
  52. package/lib/markdown/createSchemaTable.js +0 -217
  53. package/src/markdown/createFullWidthTable.ts +0 -16
  54. package/src/markdown/createParamsTable.ts +0 -102
  55. package/src/markdown/createSchemaTable.ts +0 -275
  56. package/src/openapi/__fixtures__/examples/yogurtstore/_category_.json +0 -4
  57. package/src/openapi/__fixtures__/examples/yogurtstore/froyo.yaml +0 -13
  58. package/src/openapi/__fixtures__/examples/yogurtstore/nested/nested.yaml +0 -13
package/README.md CHANGED
@@ -80,7 +80,7 @@ Here is an example of properly configuring your `docusaurus.config.js` file for
80
80
  specPath: "examples/petstore.yaml", // Path to designated spec file
81
81
  outputDir: "api/petstore", // Output directory for generated .mdx docs
82
82
  sidebarOptions: {
83
- groupPathsBy: "tags",
83
+ groupPathsBy: "tag",
84
84
  },
85
85
  },
86
86
  burgers: {
@@ -110,12 +110,13 @@ Here is an example of properly configuring your `docusaurus.config.js` file for
110
110
 
111
111
  `sidebarOptions` can be configured with the following options:
112
112
 
113
- | Name | Type | Default | Description |
114
- | -------------------- | --------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------- |
115
- | `groupPathsBy` | `string` | `null` | Organize and group sidebar slice by specified option. Note: Currently, `groupPathsBy` only contains support for grouping by "tags". |
116
- | `sidebarCollapsible` | `boolean` | `true` | Whether sidebar categories are collapsible by default. |
117
- | `sidebarCollapsed` | `boolean` | `true` | Whether sidebar categories are collapsed by default. |
118
- | `customProps` | `object` | `null` | Additional props for customizing a sidebar item. |
113
+ | Name | Type | Default | Description |
114
+ | -------------------- | --------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
115
+ | `groupPathsBy` | `string` | `null` | Organize and group sidebar slice by specified option. Note: Currently, `groupPathsBy` only contains support for grouping by `tag`. |
116
+ | `categoryLinkSource` | `string` | `null` | Defines what source to use for rendering category link pages when grouping paths by tag. <br/></br>The supported options are as follows: <br/></br> `tag`: Sets the category link config type to `generated-index` and uses the tag description as the link config description. <br/><br/>`info`: Sets the category link config type to `doc` and renders the `info` section as the category link (recommended only for multi/micro-spec scenarios). |
117
+ | `sidebarCollapsible` | `boolean` | `true` | Whether sidebar categories are collapsible by default. |
118
+ | `sidebarCollapsed` | `boolean` | `true` | Whether sidebar categories are collapsed by default. |
119
+ | `customProps` | `object` | `null` | Additional props for customizing a sidebar item. |
119
120
 
120
121
  > Note: You may optionally configure a `sidebarOptions`. In doing so, an individual `sidebar.js` slice with the configured options will be generated within the respective `outputDir`.
121
122
 
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import type { LoadContext, Plugin } from "@docusaurus/types";
2
2
  import type { PluginOptions, LoadedContent } from "./types";
3
+ export declare function isURL(str: string): boolean;
3
4
  export default function pluginOpenAPI(context: LoadContext, options: PluginOptions): Plugin<LoadedContent>;
package/lib/index.js CHANGED
@@ -9,6 +9,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.isURL = void 0;
12
13
  const fs_1 = __importDefault(require("fs"));
13
14
  const path_1 = __importDefault(require("path"));
14
15
  const utils_1 = require("@docusaurus/utils");
@@ -17,15 +18,21 @@ const mustache_1 = require("mustache");
17
18
  const markdown_1 = require("./markdown");
18
19
  const openapi_1 = require("./openapi");
19
20
  const sidebars_1 = __importDefault(require("./sidebars"));
21
+ function isURL(str) {
22
+ return /^(https?:)\/\//m.test(str);
23
+ }
24
+ exports.isURL = isURL;
20
25
  function pluginOpenAPI(context, options) {
21
26
  let { config } = options;
22
27
  let { siteDir } = context;
23
28
  async function generateApiDocs(options) {
24
29
  let { specPath, outputDir, template, sidebarOptions } = options;
25
- const contentPath = path_1.default.resolve(siteDir, specPath);
30
+ const contentPath = isURL(specPath)
31
+ ? specPath
32
+ : path_1.default.resolve(siteDir, specPath);
26
33
  try {
27
34
  const openapiFiles = await (0, openapi_1.readOpenapiFiles)(contentPath, {});
28
- const loadedApi = await (0, openapi_1.processOpenapiFiles)(openapiFiles);
35
+ const [loadedApi, tags] = await (0, openapi_1.processOpenapiFiles)(openapiFiles, sidebarOptions);
29
36
  if (!fs_1.default.existsSync(outputDir)) {
30
37
  try {
31
38
  fs_1.default.mkdirSync(outputDir, { recursive: true });
@@ -38,7 +45,7 @@ function pluginOpenAPI(context, options) {
38
45
  // TODO: figure out better way to set default
39
46
  if (Object.keys(sidebarOptions !== null && sidebarOptions !== void 0 ? sidebarOptions : {}).length > 0) {
40
47
  const sidebarSlice = (0, sidebars_1.default)(sidebarOptions, // TODO: find a better way to handle null
41
- options, loadedApi);
48
+ options, loadedApi, tags);
42
49
  const sidebarSliceTemplate = template
43
50
  ? fs_1.default.readFileSync(template).toString()
44
51
  : `module.exports = {{{slice}}};`;
@@ -59,7 +66,12 @@ function pluginOpenAPI(context, options) {
59
66
  ? fs_1.default.readFileSync(template).toString()
60
67
  : `---
61
68
  id: {{{id}}}
69
+ {{^api}}
70
+ sidebar_label: Introduction
71
+ {{/api}}
72
+ {{#api}}
62
73
  sidebar_label: {{{title}}}
74
+ {{/api}}
63
75
  {{^api}}
64
76
  sidebar_position: 0
65
77
  {{/api}}
@@ -73,17 +85,63 @@ api: {{{json}}}
73
85
  {{#api.method}}
74
86
  sidebar_class_name: "{{{api.method}}} api-method"
75
87
  {{/api.method}}
88
+ {{#infoPath}}
89
+ info_path: {{{infoPath}}}
90
+ {{/infoPath}}
91
+ ---
92
+
93
+ {{{markdown}}}
94
+ `;
95
+ const infoMdTemplate = template
96
+ ? fs_1.default.readFileSync(template).toString()
97
+ : `---
98
+ id: {{{id}}}
99
+ sidebar_label: {{{title}}}
100
+ hide_title: true
76
101
  ---
77
102
 
78
103
  {{{markdown}}}
104
+
105
+ \`\`\`mdx-code-block
106
+ import DocCardList from '@theme/DocCardList';
107
+ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
108
+
109
+ <DocCardList items={useCurrentSidebarCategory().items}/>
110
+ \`\`\`
111
+ `;
112
+ const tagMdTemplate = template
113
+ ? fs_1.default.readFileSync(template).toString()
114
+ : `---
115
+ id: {{{id}}}
116
+ title: {{{description}}}
117
+ description: {{{description}}}
118
+ ---
119
+
120
+ {{{markdown}}}
121
+
122
+ \`\`\`mdx-code-block
123
+ import DocCardList from '@theme/DocCardList';
124
+ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
125
+
126
+ <DocCardList items={useCurrentSidebarCategory().items}/>
127
+ \`\`\`
79
128
  `;
80
129
  loadedApi.map(async (item) => {
81
- const markdown = item.type === "api" ? (0, markdown_1.createApiPageMD)(item) : (0, markdown_1.createInfoPageMD)(item);
130
+ const markdown = item.type === "api"
131
+ ? (0, markdown_1.createApiPageMD)(item)
132
+ : item.type === "info"
133
+ ? (0, markdown_1.createInfoPageMD)(item)
134
+ : (0, markdown_1.createTagPageMD)(item);
82
135
  item.markdown = markdown;
83
136
  if (item.type === "api") {
84
137
  item.json = JSON.stringify(item.api);
138
+ if (item.infoId)
139
+ item.infoPath = `${outputDir}/${item.infoId}`;
85
140
  }
86
141
  const view = (0, mustache_1.render)(mdTemplate, item);
142
+ const utils = (0, mustache_1.render)(infoMdTemplate, item);
143
+ // eslint-disable-next-line testing-library/render-result-naming-convention
144
+ const tagUtils = (0, mustache_1.render)(tagMdTemplate, item);
87
145
  if (item.type === "api") {
88
146
  if (!fs_1.default.existsSync(`${outputDir}/${item.id}.api.mdx`)) {
89
147
  try {
@@ -97,13 +155,26 @@ sidebar_class_name: "{{{api.method}}} api-method"
97
155
  }
98
156
  // TODO: determine if we actually want/need this
99
157
  if (item.type === "info") {
100
- if (!fs_1.default.existsSync(`${outputDir}/index.api.mdx`)) {
158
+ if (!fs_1.default.existsSync(`${outputDir}/${item.id}.info.mdx`)) {
159
+ try {
160
+ (sidebarOptions === null || sidebarOptions === void 0 ? void 0 : sidebarOptions.categoryLinkSource) === "info" // Only use utils template if set to "info"
161
+ ? fs_1.default.writeFileSync(`${outputDir}/${item.id}.info.mdx`, utils, "utf8")
162
+ : fs_1.default.writeFileSync(`${outputDir}/${item.id}.info.mdx`, view, "utf8");
163
+ console.log(chalk_1.default.green(`Successfully created "${outputDir}/${item.id}.info.mdx"`));
164
+ }
165
+ catch (err) {
166
+ console.error(chalk_1.default.red(`Failed to write "${outputDir}/${item.id}.info.mdx"`), chalk_1.default.yellow(err));
167
+ }
168
+ }
169
+ }
170
+ if (item.type === "tag") {
171
+ if (!fs_1.default.existsSync(`${outputDir}/${item.id}.tag.mdx`)) {
101
172
  try {
102
- fs_1.default.writeFileSync(`${outputDir}/index.api.mdx`, view, "utf8");
103
- console.log(chalk_1.default.green(`Successfully created "${outputDir}/index.api.mdx"`));
173
+ fs_1.default.writeFileSync(`${outputDir}/${item.id}.tag.mdx`, tagUtils, "utf8");
174
+ console.log(chalk_1.default.green(`Successfully created "${outputDir}/${item.id}.tag.mdx"`));
104
175
  }
105
176
  catch (err) {
106
- console.error(chalk_1.default.red(`Failed to write "${outputDir}/index.api.mdx"`), chalk_1.default.yellow(err));
177
+ console.error(chalk_1.default.red(`Failed to write "${outputDir}/${item.id}.tag.mdx"`), chalk_1.default.yellow(err));
107
178
  }
108
179
  }
109
180
  }
@@ -119,7 +190,7 @@ sidebar_class_name: "{{{api.method}}} api-method"
119
190
  async function cleanApiDocs(options) {
120
191
  const { outputDir } = options;
121
192
  const apiDir = path_1.default.join(siteDir, outputDir);
122
- const apiMdxFiles = await (0, utils_1.Globby)(["*.api.mdx"], {
193
+ const apiMdxFiles = await (0, utils_1.Globby)(["*.api.mdx", "*.info.mdx", "*.tag.mdx"], {
123
194
  cwd: path_1.default.resolve(apiDir),
124
195
  });
125
196
  const sidebarFile = await (0, utils_1.Globby)(["sidebar.js"], {
@@ -0,0 +1,2 @@
1
+ import { SecuritySchemeObject } from "../openapi/types";
2
+ export declare function createAuthentication(securitySchemes: SecuritySchemeObject): string;
@@ -0,0 +1,139 @@
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.createAuthentication = void 0;
10
+ const createDescription_1 = require("./createDescription");
11
+ const utils_1 = require("./utils");
12
+ function createAuthentication(securitySchemes) {
13
+ if (!securitySchemes || !Object.keys(securitySchemes).length)
14
+ return "";
15
+ const createAuthenticationTable = (securityScheme) => {
16
+ const { bearerFormat, flows, name, scheme, type } = securityScheme;
17
+ const createSecuritySchemeTypeRow = () => (0, utils_1.create)("tr", {
18
+ children: [
19
+ (0, utils_1.create)("th", { children: "Security Scheme Type:" }),
20
+ (0, utils_1.create)("td", { children: type }),
21
+ ],
22
+ });
23
+ const createOAuthFlowRows = () => {
24
+ const flowRows = Object.entries(flows).map(([flowType, flowObj]) => {
25
+ const { authorizationUrl, tokenUrl, refreshUrl, scopes } = flowObj;
26
+ return (0, utils_1.create)("tr", {
27
+ children: [
28
+ (0, utils_1.create)("th", { children: `${flowType} OAuth Flow:` }),
29
+ (0, utils_1.create)("td", {
30
+ children: [
31
+ (0, utils_1.guard)(tokenUrl, () => (0, utils_1.create)("p", { children: `Token URL: ${tokenUrl}` })),
32
+ (0, utils_1.guard)(authorizationUrl, () => (0, utils_1.create)("p", {
33
+ children: `Authorization URL: ${authorizationUrl}`,
34
+ })),
35
+ (0, utils_1.guard)(refreshUrl, () => (0, utils_1.create)("p", { children: `Refresh URL: ${refreshUrl}` })),
36
+ (0, utils_1.create)("span", { children: "Scopes:" }),
37
+ (0, utils_1.create)("ul", {
38
+ children: Object.entries(scopes).map(([scope, description]) => (0, utils_1.create)("li", { children: `${scope}: ${description}` })),
39
+ }),
40
+ ],
41
+ }),
42
+ ],
43
+ });
44
+ });
45
+ return flowRows.join("");
46
+ };
47
+ switch (type) {
48
+ case "apiKey":
49
+ return (0, utils_1.create)("div", {
50
+ children: [
51
+ (0, utils_1.create)("table", {
52
+ children: (0, utils_1.create)("tbody", {
53
+ children: [
54
+ createSecuritySchemeTypeRow(),
55
+ (0, utils_1.create)("tr", {
56
+ children: [
57
+ (0, utils_1.create)("th", { children: "Header parameter name:" }),
58
+ (0, utils_1.create)("td", { children: name }),
59
+ ],
60
+ }),
61
+ ],
62
+ }),
63
+ }),
64
+ ],
65
+ });
66
+ case "http":
67
+ return (0, utils_1.create)("div", {
68
+ children: [
69
+ (0, utils_1.create)("table", {
70
+ children: (0, utils_1.create)("tbody", {
71
+ children: [
72
+ createSecuritySchemeTypeRow(),
73
+ (0, utils_1.create)("tr", {
74
+ children: [
75
+ (0, utils_1.create)("th", { children: "HTTP Authorization Scheme:" }),
76
+ (0, utils_1.create)("td", { children: scheme }),
77
+ ],
78
+ }),
79
+ (0, utils_1.create)("tr", {
80
+ children: [
81
+ (0, utils_1.create)("th", { children: "Bearer format:" }),
82
+ (0, utils_1.create)("td", { children: bearerFormat }),
83
+ ],
84
+ }),
85
+ ],
86
+ }),
87
+ }),
88
+ ],
89
+ });
90
+ case "oauth2":
91
+ return (0, utils_1.create)("div", {
92
+ children: [
93
+ (0, utils_1.create)("table", {
94
+ children: (0, utils_1.create)("tbody", {
95
+ children: [
96
+ createSecuritySchemeTypeRow(),
97
+ createOAuthFlowRows(),
98
+ ],
99
+ }),
100
+ }),
101
+ ],
102
+ });
103
+ default:
104
+ return "";
105
+ }
106
+ };
107
+ const formatTabLabel = (str) => {
108
+ const formattedLabel = str
109
+ .replace(/(_|-)/g, " ")
110
+ .trim()
111
+ .replace(/\w\S*/g, (str) => str.charAt(0).toUpperCase() + str.substr(1))
112
+ .replace(/([a-z])([A-Z])/g, "$1 $2")
113
+ .replace(/([A-Z])([A-Z][a-z])/g, "$1 $2");
114
+ const isOAuth = formattedLabel.toLowerCase().includes("oauth2");
115
+ const isApiKey = formattedLabel.toLowerCase().includes("api");
116
+ return isOAuth ? "OAuth 2.0" : isApiKey ? "API Key" : formattedLabel;
117
+ };
118
+ return (0, utils_1.create)("div", {
119
+ children: [
120
+ (0, utils_1.create)("h2", {
121
+ children: "Authentication",
122
+ id: "authentication",
123
+ style: { marginBottom: "1rem" },
124
+ }),
125
+ (0, utils_1.create)("Tabs", {
126
+ children: Object.entries(securitySchemes).map(([schemeType, schemeObj]) => (0, utils_1.create)("TabItem", {
127
+ label: formatTabLabel(schemeType),
128
+ value: `${schemeType}`,
129
+ children: [
130
+ (0, createDescription_1.createDescription)(schemeObj.description),
131
+ createAuthenticationTable(schemeObj),
132
+ ],
133
+ })),
134
+ }),
135
+ ],
136
+ style: { marginBottom: "2rem" },
137
+ });
138
+ }
139
+ exports.createAuthentication = createAuthentication;
@@ -0,0 +1,2 @@
1
+ import { ContactObject } from "../openapi/types";
2
+ export declare function createContactInfo(contact: ContactObject): string;
@@ -0,0 +1,49 @@
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.createContactInfo = void 0;
10
+ const utils_1 = require("./utils");
11
+ function createContactInfo(contact) {
12
+ if (!contact || !Object.keys(contact).length)
13
+ return "";
14
+ const { name, url, email } = contact;
15
+ return (0, utils_1.create)("div", {
16
+ style: {
17
+ display: "flex",
18
+ flexDirection: "column",
19
+ marginBottom: "var(--ifm-paragraph-margin-bottom)",
20
+ },
21
+ children: [
22
+ (0, utils_1.create)("h3", {
23
+ style: {
24
+ marginBottom: "0.25rem",
25
+ },
26
+ children: "Contact",
27
+ }),
28
+ (0, utils_1.create)("span", {
29
+ children: [
30
+ (0, utils_1.guard)(name, () => `${name}: `),
31
+ (0, utils_1.guard)(email, () => (0, utils_1.create)("a", {
32
+ href: `mailto:${email}`,
33
+ children: `${email}`,
34
+ })),
35
+ ],
36
+ }),
37
+ (0, utils_1.guard)(url, () => (0, utils_1.create)("span", {
38
+ children: [
39
+ "URL: ",
40
+ (0, utils_1.create)("a", {
41
+ href: `${url}`,
42
+ children: `${url}`,
43
+ }),
44
+ ],
45
+ })),
46
+ ],
47
+ });
48
+ }
49
+ exports.createContactInfo = createContactInfo;
@@ -0,0 +1,2 @@
1
+ import { LicenseObject } from "../openapi/types";
2
+ export declare function createLicense(license: LicenseObject): string;
@@ -0,0 +1,33 @@
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.createLicense = void 0;
10
+ const utils_1 = require("./utils");
11
+ function createLicense(license) {
12
+ if (!license || !Object.keys(license).length)
13
+ return "";
14
+ const { name, url } = license;
15
+ return (0, utils_1.create)("div", {
16
+ style: {
17
+ marginBottom: "var(--ifm-paragraph-margin-bottom)",
18
+ },
19
+ children: [
20
+ (0, utils_1.create)("h3", {
21
+ style: {
22
+ marginBottom: "0.25rem",
23
+ },
24
+ children: "License",
25
+ }),
26
+ (0, utils_1.guard)(url, () => (0, utils_1.create)("a", {
27
+ href: url,
28
+ children: name !== null && name !== void 0 ? name : url,
29
+ })),
30
+ ],
31
+ });
32
+ }
33
+ exports.createLicense = createLicense;
@@ -185,7 +185,10 @@ function createRowsRoot({ schema }) {
185
185
  });
186
186
  }
187
187
  function createSchemaDetails({ title, body, ...rest }) {
188
- if (body === undefined || body.content === undefined) {
188
+ if (body === undefined ||
189
+ body.content === undefined ||
190
+ Object.keys(body).length === 0 ||
191
+ Object.keys(body.content).length === 0) {
189
192
  return undefined;
190
193
  }
191
194
  // TODO:
@@ -20,7 +20,7 @@ function createStatusCodes({ responses }) {
20
20
  }
21
21
  return (0, utils_1.create)("div", {
22
22
  children: [
23
- (0, utils_1.create)("Tabs", {
23
+ (0, utils_1.create)("ApiTabs", {
24
24
  children: codes.map((code) => {
25
25
  return (0, utils_1.create)("TabItem", {
26
26
  label: code,
@@ -0,0 +1 @@
1
+ export declare function createTermsOfService(termsOfService: string | undefined): string;
@@ -0,0 +1,32 @@
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.createTermsOfService = void 0;
10
+ const utils_1 = require("./utils");
11
+ function createTermsOfService(termsOfService) {
12
+ if (!termsOfService)
13
+ return "";
14
+ return (0, utils_1.create)("div", {
15
+ style: {
16
+ marginBottom: "var(--ifm-paragraph-margin-bottom)",
17
+ },
18
+ children: [
19
+ (0, utils_1.create)("h3", {
20
+ style: {
21
+ marginBottom: "0.25rem",
22
+ },
23
+ children: "Terms of Service",
24
+ }),
25
+ (0, utils_1.create)("a", {
26
+ href: `${termsOfService}`,
27
+ children: termsOfService,
28
+ }),
29
+ ],
30
+ });
31
+ }
32
+ exports.createTermsOfService = createTermsOfService;
@@ -1,3 +1,4 @@
1
- import { ApiPageMetadata, InfoPageMetadata } from "../types";
1
+ import { ApiPageMetadata, InfoPageMetadata, TagPageMetadata } from "../types";
2
2
  export declare function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, parameters, requestBody, responses, }, }: ApiPageMetadata): string;
3
- export declare function createInfoPageMD({ info: { title, version, description }, }: InfoPageMetadata): string;
3
+ export declare function createInfoPageMD({ info: { title, version, description, contact, license, termsOfService }, securitySchemes, }: InfoPageMetadata): string;
4
+ export declare function createTagPageMD({ tag: { description } }: TagPageMetadata): string;
@@ -6,20 +6,24 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  * ========================================================================== */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.createInfoPageMD = exports.createApiPageMD = void 0;
9
+ exports.createTagPageMD = exports.createInfoPageMD = exports.createApiPageMD = void 0;
10
10
  const lodash_1 = require("lodash");
11
+ const createAuthentication_1 = require("./createAuthentication");
12
+ const createContactInfo_1 = require("./createContactInfo");
11
13
  const createDeprecationNotice_1 = require("./createDeprecationNotice");
12
14
  const createDescription_1 = require("./createDescription");
15
+ const createLicense_1 = require("./createLicense");
13
16
  const createParamsDetails_1 = require("./createParamsDetails");
14
17
  const createRequestBodyDetails_1 = require("./createRequestBodyDetails");
15
18
  const createStatusCodes_1 = require("./createStatusCodes");
19
+ const createTermsOfService_1 = require("./createTermsOfService");
16
20
  const createVersionBadge_1 = require("./createVersionBadge");
17
21
  const utils_1 = require("./utils");
18
22
  function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, parameters, requestBody, responses, }, }) {
19
23
  return (0, utils_1.render)([
20
24
  `import ParamsItem from "@theme/ParamsItem";\n`,
21
25
  `import SchemaItem from "@theme/SchemaItem"\n`,
22
- `import Tabs from "@theme/Tabs";\n`,
26
+ `import ApiTabs from "@theme/ApiTabs";\n`,
23
27
  `import TabItem from "@theme/TabItem";\n\n`,
24
28
  `## ${(0, lodash_1.escape)(title)}\n\n`,
25
29
  (0, createDeprecationNotice_1.createDeprecationNotice)({ deprecated, description: deprecatedDescription }),
@@ -33,11 +37,21 @@ function createApiPageMD({ title, api: { deprecated, "x-deprecated-description":
33
37
  ]);
34
38
  }
35
39
  exports.createApiPageMD = createApiPageMD;
36
- function createInfoPageMD({ info: { title, version, description }, }) {
40
+ function createInfoPageMD({ info: { title, version, description, contact, license, termsOfService }, securitySchemes, }) {
37
41
  return (0, utils_1.render)([
42
+ `import Tabs from "@theme/Tabs";\n`,
43
+ `import TabItem from "@theme/TabItem";\n`,
38
44
  (0, createVersionBadge_1.createVersionBadge)(version),
39
45
  `# ${(0, lodash_1.escape)(title)}\n\n`,
40
46
  (0, createDescription_1.createDescription)(description),
47
+ (0, createAuthentication_1.createAuthentication)(securitySchemes),
48
+ (0, createContactInfo_1.createContactInfo)(contact),
49
+ (0, createTermsOfService_1.createTermsOfService)(termsOfService),
50
+ (0, createLicense_1.createLicense)(license),
41
51
  ]);
42
52
  }
43
53
  exports.createInfoPageMD = createInfoPageMD;
54
+ function createTagPageMD({ tag: { description } }) {
55
+ return (0, utils_1.render)([(0, createDescription_1.createDescription)(description)]);
56
+ }
57
+ exports.createTagPageMD = createTagPageMD;