docusaurus-plugin-openapi-docs 1.0.1 → 1.0.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 (66) hide show
  1. package/README.md +110 -21
  2. package/lib/index.d.ts +7 -1
  3. package/lib/index.js +257 -22
  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/createParamsDetails.js +2 -0
  11. package/lib/markdown/createSchemaDetails.js +6 -1
  12. package/lib/markdown/createStatusCodes.js +1 -1
  13. package/lib/markdown/createTermsOfService.d.ts +1 -0
  14. package/lib/markdown/createTermsOfService.js +32 -0
  15. package/lib/markdown/index.d.ts +3 -2
  16. package/lib/markdown/index.js +17 -3
  17. package/lib/openapi/createExample.js +59 -49
  18. package/lib/openapi/openapi.d.ts +5 -4
  19. package/lib/openapi/openapi.js +94 -50
  20. package/lib/openapi/openapi.test.js +0 -6
  21. package/lib/openapi/types.d.ts +5 -1
  22. package/lib/openapi/utils/loadAndBundleSpec.d.ts +3 -0
  23. package/lib/openapi/utils/loadAndBundleSpec.js +44 -0
  24. package/lib/openapi/utils/types.d.ts +306 -0
  25. package/lib/{markdown/createRequestBodyTable.js → openapi/utils/types.js} +0 -6
  26. package/lib/options.d.ts +0 -2
  27. package/lib/options.js +36 -7
  28. package/lib/sidebars/index.d.ts +2 -1
  29. package/lib/sidebars/index.js +91 -35
  30. package/lib/sidebars/utils.d.ts +2 -0
  31. package/lib/sidebars/utils.js +31 -0
  32. package/lib/types.d.ts +35 -11
  33. package/package.json +10 -9
  34. package/src/index.ts +332 -25
  35. package/src/markdown/createAuthentication.ts +160 -0
  36. package/src/markdown/createContactInfo.ts +52 -0
  37. package/src/markdown/createLicense.ts +34 -0
  38. package/src/markdown/createParamsDetails.ts +2 -0
  39. package/src/markdown/createSchemaDetails.ts +8 -2
  40. package/src/markdown/createStatusCodes.ts +1 -1
  41. package/src/markdown/createTermsOfService.ts +30 -0
  42. package/src/markdown/index.ts +23 -3
  43. package/src/openapi/createExample.ts +59 -50
  44. package/src/openapi/openapi.test.ts +0 -6
  45. package/src/openapi/openapi.ts +115 -53
  46. package/src/openapi/types.ts +5 -1
  47. package/src/openapi/utils/loadAndBundleSpec.ts +62 -0
  48. package/src/openapi/utils/types.ts +303 -0
  49. package/src/options.ts +41 -8
  50. package/src/{markdown/createRequestBodyTable.ts → postman-collection.d.ts} +2 -9
  51. package/src/sidebars/index.ts +116 -36
  52. package/src/sidebars/utils.ts +29 -0
  53. package/src/types.ts +36 -10
  54. package/lib/markdown/createFullWidthTable.d.ts +0 -2
  55. package/lib/markdown/createFullWidthTable.js +0 -18
  56. package/lib/markdown/createParamsTable.d.ts +0 -7
  57. package/lib/markdown/createParamsTable.js +0 -80
  58. package/lib/markdown/createRequestBodyTable.d.ts +0 -6
  59. package/lib/markdown/createSchemaTable.d.ts +0 -14
  60. package/lib/markdown/createSchemaTable.js +0 -217
  61. package/src/markdown/createFullWidthTable.ts +0 -16
  62. package/src/markdown/createParamsTable.ts +0 -102
  63. package/src/markdown/createSchemaTable.ts +0 -275
  64. package/src/openapi/__fixtures__/examples/yogurtstore/_category_.json +0 -4
  65. package/src/openapi/__fixtures__/examples/yogurtstore/froyo.yaml +0 -13
  66. package/src/openapi/__fixtures__/examples/yogurtstore/nested/nested.yaml +0 -13
@@ -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;
@@ -19,6 +19,8 @@ function createParamsDetails({ parameters, type }) {
19
19
  return undefined;
20
20
  }
21
21
  return (0, createDetails_1.createDetails)({
22
+ "data-collapsed": false,
23
+ open: true,
22
24
  style: { marginBottom: "1rem" },
23
25
  children: [
24
26
  (0, createDetailsSummary_1.createDetailsSummary)({
@@ -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:
@@ -203,6 +206,8 @@ function createSchemaDetails({ title, body, ...rest }) {
203
206
  }
204
207
  }
205
208
  return (0, createDetails_1.createDetails)({
209
+ "data-collapsed": false,
210
+ open: true,
206
211
  ...rest,
207
212
  children: [
208
213
  (0, createDetailsSummary_1.createDetailsSummary)({
@@ -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\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;
@@ -5,8 +5,12 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  * ========================================================================== */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  exports.sampleFromSchema = void 0;
13
+ const chalk_1 = __importDefault(require("chalk"));
10
14
  const primitives = {
11
15
  string: {
12
16
  default: () => "string",
@@ -31,64 +35,70 @@ const primitives = {
31
35
  array: {},
32
36
  };
33
37
  const sampleFromSchema = (schema = {}) => {
34
- let { type, example, allOf, properties, items } = schema;
35
- if (example !== undefined) {
36
- return example;
37
- }
38
- if (allOf) {
39
- // TODO: We are just assuming it will always be an object for now
40
- let obj = {
41
- type: "object",
42
- properties: {},
43
- required: [], // NOTE: We shouldn't need to worry about required
44
- };
45
- for (let item of allOf) {
46
- if (item.properties) {
47
- obj.properties = {
48
- ...obj.properties,
49
- ...item.properties,
50
- };
51
- }
52
- }
53
- return (0, exports.sampleFromSchema)(obj);
54
- }
55
- if (!type) {
56
- if (properties) {
57
- type = "object";
38
+ try {
39
+ let { type, example, allOf, properties, items } = schema;
40
+ if (example !== undefined) {
41
+ return example;
58
42
  }
59
- else if (items) {
60
- type = "array";
43
+ if (allOf) {
44
+ // TODO: We are just assuming it will always be an object for now
45
+ let obj = {
46
+ type: "object",
47
+ properties: {},
48
+ required: [], // NOTE: We shouldn't need to worry about required
49
+ };
50
+ for (let item of allOf) {
51
+ if (item.properties) {
52
+ obj.properties = {
53
+ ...obj.properties,
54
+ ...item.properties,
55
+ };
56
+ }
57
+ }
58
+ return (0, exports.sampleFromSchema)(obj);
61
59
  }
62
- else {
63
- return;
60
+ if (!type) {
61
+ if (properties) {
62
+ type = "object";
63
+ }
64
+ else if (items) {
65
+ type = "array";
66
+ }
67
+ else {
68
+ return;
69
+ }
64
70
  }
65
- }
66
- if (type === "object") {
67
- let obj = {};
68
- for (let [name, prop] of Object.entries(properties !== null && properties !== void 0 ? properties : {})) {
69
- if (prop.deprecated) {
70
- continue;
71
+ if (type === "object") {
72
+ let obj = {};
73
+ for (let [name, prop] of Object.entries(properties !== null && properties !== void 0 ? properties : {})) {
74
+ if (prop.deprecated) {
75
+ continue;
76
+ }
77
+ obj[name] = (0, exports.sampleFromSchema)(prop);
71
78
  }
72
- obj[name] = (0, exports.sampleFromSchema)(prop);
79
+ return obj;
73
80
  }
74
- return obj;
75
- }
76
- if (type === "array") {
77
- if (Array.isArray(items === null || items === void 0 ? void 0 : items.anyOf)) {
78
- return items === null || items === void 0 ? void 0 : items.anyOf.map((item) => (0, exports.sampleFromSchema)(item));
81
+ if (type === "array") {
82
+ if (Array.isArray(items === null || items === void 0 ? void 0 : items.anyOf)) {
83
+ return items === null || items === void 0 ? void 0 : items.anyOf.map((item) => (0, exports.sampleFromSchema)(item));
84
+ }
85
+ if (Array.isArray(items === null || items === void 0 ? void 0 : items.oneOf)) {
86
+ return items === null || items === void 0 ? void 0 : items.oneOf.map((item) => (0, exports.sampleFromSchema)(item));
87
+ }
88
+ return [(0, exports.sampleFromSchema)(items)];
79
89
  }
80
- if (Array.isArray(items === null || items === void 0 ? void 0 : items.oneOf)) {
81
- return items === null || items === void 0 ? void 0 : items.oneOf.map((item) => (0, exports.sampleFromSchema)(item));
90
+ if (schema.enum) {
91
+ if (schema.default) {
92
+ return schema.default;
93
+ }
94
+ return normalizeArray(schema.enum)[0];
82
95
  }
83
- return [(0, exports.sampleFromSchema)(items)];
96
+ return primitive(schema);
84
97
  }
85
- if (schema.enum) {
86
- if (schema.default) {
87
- return schema.default;
88
- }
89
- return normalizeArray(schema.enum)[0];
98
+ catch (err) {
99
+ console.error(chalk_1.default.yellow("WARNING: failed to create example from schema object:", err));
100
+ return;
90
101
  }
91
- return primitive(schema);
92
102
  };
93
103
  exports.sampleFromSchema = sampleFromSchema;
94
104
  function primitive(schema = {}) {
@@ -1,11 +1,12 @@
1
- import { ApiMetadata } from "../types";
2
- import { OpenApiObjectWithRef } from "./types";
1
+ import { ApiMetadata, SidebarOptions } from "../types";
2
+ import { OpenApiObjectWithRef, TagObject } from "./types";
3
3
  interface OpenApiFiles {
4
4
  source: string;
5
5
  sourceDirName: string;
6
6
  data: OpenApiObjectWithRef;
7
7
  }
8
8
  export declare function readOpenapiFiles(openapiPath: string, _options: {}): Promise<OpenApiFiles[]>;
9
- export declare function processOpenapiFiles(files: OpenApiFiles[]): Promise<ApiMetadata[]>;
10
- export declare function processOpenapiFile(openapiDataWithRefs: OpenApiObjectWithRef): Promise<ApiMetadata[]>;
9
+ export declare function processOpenapiFiles(files: OpenApiFiles[], sidebarOptions: SidebarOptions): Promise<[ApiMetadata[], TagObject[]]>;
10
+ export declare function processOpenapiFile(openapiDataWithRefs: OpenApiObjectWithRef, sidebarOptions: SidebarOptions): Promise<[ApiMetadata[], TagObject[]]>;
11
+ export declare function getTagDisplayName(tagName: string, tags: TagObject[]): string;
11
12
  export {};