@camunda8/docusaurus-plugin-openapi-docs 4.5.1

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 (170) hide show
  1. package/README.md +386 -0
  2. package/lib/index.d.ts +9 -0
  3. package/lib/index.js +714 -0
  4. package/lib/markdown/createArrayBracket.d.ts +2 -0
  5. package/lib/markdown/createArrayBracket.js +36 -0
  6. package/lib/markdown/createAuthentication.d.ts +2 -0
  7. package/lib/markdown/createAuthentication.js +173 -0
  8. package/lib/markdown/createAuthorization.d.ts +1 -0
  9. package/lib/markdown/createAuthorization.js +15 -0
  10. package/lib/markdown/createCallbackMethodEndpoint.d.ts +1 -0
  11. package/lib/markdown/createCallbackMethodEndpoint.js +20 -0
  12. package/lib/markdown/createCallbacks.d.ts +6 -0
  13. package/lib/markdown/createCallbacks.js +77 -0
  14. package/lib/markdown/createContactInfo.d.ts +2 -0
  15. package/lib/markdown/createContactInfo.js +39 -0
  16. package/lib/markdown/createDeprecationNotice.d.ts +6 -0
  17. package/lib/markdown/createDeprecationNotice.js +20 -0
  18. package/lib/markdown/createDescription.d.ts +1 -0
  19. package/lib/markdown/createDescription.js +13 -0
  20. package/lib/markdown/createDetails.d.ts +2 -0
  21. package/lib/markdown/createDetails.js +17 -0
  22. package/lib/markdown/createDetailsSummary.d.ts +2 -0
  23. package/lib/markdown/createDetailsSummary.js +17 -0
  24. package/lib/markdown/createDownload.d.ts +1 -0
  25. package/lib/markdown/createDownload.js +16 -0
  26. package/lib/markdown/createHeading.d.ts +1 -0
  27. package/lib/markdown/createHeading.js +20 -0
  28. package/lib/markdown/createLicense.d.ts +2 -0
  29. package/lib/markdown/createLicense.js +32 -0
  30. package/lib/markdown/createLogo.d.ts +2 -0
  31. package/lib/markdown/createLogo.js +18 -0
  32. package/lib/markdown/createMethodEndpoint.d.ts +1 -0
  33. package/lib/markdown/createMethodEndpoint.js +20 -0
  34. package/lib/markdown/createParamsDetails.d.ts +6 -0
  35. package/lib/markdown/createParamsDetails.js +18 -0
  36. package/lib/markdown/createRequestBodyDetails.d.ts +13 -0
  37. package/lib/markdown/createRequestBodyDetails.js +13 -0
  38. package/lib/markdown/createRequestHeader.d.ts +1 -0
  39. package/lib/markdown/createRequestHeader.js +23 -0
  40. package/lib/markdown/createRequestSchema.d.ts +14 -0
  41. package/lib/markdown/createRequestSchema.js +20 -0
  42. package/lib/markdown/createResponseSchema.d.ts +14 -0
  43. package/lib/markdown/createResponseSchema.js +20 -0
  44. package/lib/markdown/createSchema.d.ts +9 -0
  45. package/lib/markdown/createSchema.js +668 -0
  46. package/lib/markdown/createSchema.test.d.ts +1 -0
  47. package/lib/markdown/createSchema.test.js +913 -0
  48. package/lib/markdown/createStatusCodes.d.ts +9 -0
  49. package/lib/markdown/createStatusCodes.js +63 -0
  50. package/lib/markdown/createTermsOfService.d.ts +1 -0
  51. package/lib/markdown/createTermsOfService.js +31 -0
  52. package/lib/markdown/createVendorExtensions.d.ts +1 -0
  53. package/lib/markdown/createVendorExtensions.js +24 -0
  54. package/lib/markdown/createVersionBadge.d.ts +1 -0
  55. package/lib/markdown/createVersionBadge.js +19 -0
  56. package/lib/markdown/index.d.ts +5 -0
  57. package/lib/markdown/index.js +93 -0
  58. package/lib/markdown/schema.d.ts +3 -0
  59. package/lib/markdown/schema.js +157 -0
  60. package/lib/markdown/schema.test.d.ts +1 -0
  61. package/lib/markdown/schema.test.js +181 -0
  62. package/lib/markdown/utils.d.ts +20 -0
  63. package/lib/markdown/utils.js +68 -0
  64. package/lib/openapi/createRequestExample.d.ts +2 -0
  65. package/lib/openapi/createRequestExample.js +14 -0
  66. package/lib/openapi/createResponseExample.d.ts +2 -0
  67. package/lib/openapi/createResponseExample.js +14 -0
  68. package/lib/openapi/createSchemaExample.d.ts +7 -0
  69. package/lib/openapi/createSchemaExample.js +231 -0
  70. package/lib/openapi/index.d.ts +1 -0
  71. package/lib/openapi/index.js +12 -0
  72. package/lib/openapi/openapi.d.ts +12 -0
  73. package/lib/openapi/openapi.js +634 -0
  74. package/lib/openapi/openapi.test.d.ts +1 -0
  75. package/lib/openapi/openapi.test.js +33 -0
  76. package/lib/openapi/sdkExamples.d.ts +39 -0
  77. package/lib/openapi/sdkExamples.js +141 -0
  78. package/lib/openapi/types.d.ts +352 -0
  79. package/lib/openapi/types.js +8 -0
  80. package/lib/openapi/utils/loadAndResolveSpec.d.ts +2 -0
  81. package/lib/openapi/utils/loadAndResolveSpec.js +153 -0
  82. package/lib/openapi/utils/services/OpenAPIParser.d.ts +52 -0
  83. package/lib/openapi/utils/services/OpenAPIParser.js +343 -0
  84. package/lib/openapi/utils/services/RedocNormalizedOptions.d.ts +100 -0
  85. package/lib/openapi/utils/services/RedocNormalizedOptions.js +170 -0
  86. package/lib/openapi/utils/types/index.d.ts +2 -0
  87. package/lib/openapi/utils/types/index.js +23 -0
  88. package/lib/openapi/utils/types/open-api.d.ts +305 -0
  89. package/lib/openapi/utils/types/open-api.js +8 -0
  90. package/lib/openapi/utils/types.d.ts +307 -0
  91. package/lib/openapi/utils/types.js +8 -0
  92. package/lib/openapi/utils/utils/JsonPointer.d.ts +51 -0
  93. package/lib/openapi/utils/utils/JsonPointer.js +95 -0
  94. package/lib/openapi/utils/utils/helpers.d.ts +43 -0
  95. package/lib/openapi/utils/utils/helpers.js +230 -0
  96. package/lib/openapi/utils/utils/index.d.ts +3 -0
  97. package/lib/openapi/utils/utils/index.js +25 -0
  98. package/lib/openapi/utils/utils/openapi.d.ts +40 -0
  99. package/lib/openapi/utils/utils/openapi.js +605 -0
  100. package/lib/openapi/webhooks.test.d.ts +1 -0
  101. package/lib/openapi/webhooks.test.js +23 -0
  102. package/lib/options.d.ts +2 -0
  103. package/lib/options.js +70 -0
  104. package/lib/sidebars/index.d.ts +4 -0
  105. package/lib/sidebars/index.js +226 -0
  106. package/lib/sidebars/utils.d.ts +2 -0
  107. package/lib/sidebars/utils.js +30 -0
  108. package/lib/types.d.ts +138 -0
  109. package/lib/types.js +8 -0
  110. package/package.json +68 -0
  111. package/src/index.ts +955 -0
  112. package/src/markdown/__snapshots__/createSchema.test.ts.snap +1605 -0
  113. package/src/markdown/createArrayBracket.ts +35 -0
  114. package/src/markdown/createAuthentication.ts +209 -0
  115. package/src/markdown/createAuthorization.ts +13 -0
  116. package/src/markdown/createCallbackMethodEndpoint.ts +19 -0
  117. package/src/markdown/createCallbacks.ts +101 -0
  118. package/src/markdown/createContactInfo.ts +41 -0
  119. package/src/markdown/createDeprecationNotice.ts +31 -0
  120. package/src/markdown/createDescription.ts +12 -0
  121. package/src/markdown/createDetails.ts +16 -0
  122. package/src/markdown/createDetailsSummary.ts +16 -0
  123. package/src/markdown/createDownload.ts +15 -0
  124. package/src/markdown/createHeading.ts +23 -0
  125. package/src/markdown/createLicense.ts +34 -0
  126. package/src/markdown/createLogo.ts +21 -0
  127. package/src/markdown/createMethodEndpoint.ts +19 -0
  128. package/src/markdown/createParamsDetails.ts +22 -0
  129. package/src/markdown/createRequestBodyDetails.ts +24 -0
  130. package/src/markdown/createRequestHeader.ts +22 -0
  131. package/src/markdown/createRequestSchema.ts +32 -0
  132. package/src/markdown/createResponseSchema.ts +32 -0
  133. package/src/markdown/createSchema.test.ts +1075 -0
  134. package/src/markdown/createSchema.ts +864 -0
  135. package/src/markdown/createStatusCodes.ts +63 -0
  136. package/src/markdown/createTermsOfService.ts +30 -0
  137. package/src/markdown/createVendorExtensions.ts +22 -0
  138. package/src/markdown/createVersionBadge.ts +22 -0
  139. package/src/markdown/index.ts +145 -0
  140. package/src/markdown/schema.test.ts +208 -0
  141. package/src/markdown/schema.ts +188 -0
  142. package/src/markdown/utils.ts +89 -0
  143. package/src/openapi/__fixtures__/examples/openapi.yaml +49 -0
  144. package/src/openapi/__fixtures__/webhook/openapi.yaml +17 -0
  145. package/src/openapi/createRequestExample.ts +13 -0
  146. package/src/openapi/createResponseExample.ts +13 -0
  147. package/src/openapi/createSchemaExample.ts +292 -0
  148. package/src/openapi/index.ts +8 -0
  149. package/src/openapi/openapi.test.ts +40 -0
  150. package/src/openapi/openapi.ts +772 -0
  151. package/src/openapi/sdkExamples.ts +195 -0
  152. package/src/openapi/types.ts +458 -0
  153. package/src/openapi/utils/loadAndResolveSpec.ts +171 -0
  154. package/src/openapi/utils/services/OpenAPIParser.ts +434 -0
  155. package/src/openapi/utils/services/RedocNormalizedOptions.ts +330 -0
  156. package/src/openapi/utils/types/index.ts +10 -0
  157. package/src/openapi/utils/types/open-api.ts +303 -0
  158. package/src/openapi/utils/types.ts +304 -0
  159. package/src/openapi/utils/utils/JsonPointer.ts +99 -0
  160. package/src/openapi/utils/utils/helpers.ts +239 -0
  161. package/src/openapi/utils/utils/index.ts +11 -0
  162. package/src/openapi/utils/utils/openapi.ts +771 -0
  163. package/src/openapi/webhooks.test.ts +30 -0
  164. package/src/openapi-to-postmanv2.d.ts +10 -0
  165. package/src/options.ts +78 -0
  166. package/src/plugin-openapi.d.ts +88 -0
  167. package/src/sidebars/index.ts +322 -0
  168. package/src/sidebars/utils.ts +29 -0
  169. package/src/types.ts +180 -0
  170. package/tsconfig.json +7 -0
@@ -0,0 +1,68 @@
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.codeBlock = exports.curlyBrackets = exports.codeFence = exports.greaterThan = exports.lessThan = void 0;
10
+ exports.create = create;
11
+ exports.guard = guard;
12
+ exports.render = render;
13
+ exports.clean = clean;
14
+ function create(tag, props, options = {}) {
15
+ const { children, ...rest } = props;
16
+ let propString = "";
17
+ for (const [key, value] of Object.entries(rest)) {
18
+ propString += `\n ${key}={${JSON.stringify(value)}}`;
19
+ }
20
+ let indentedChildren = render(children).replace(/^/gm, " ");
21
+ if (options.inline) {
22
+ propString += `\n children={${JSON.stringify(children)}}`;
23
+ indentedChildren = "";
24
+ }
25
+ propString += propString ? "\n" : "";
26
+ indentedChildren += indentedChildren ? "\n" : "";
27
+ return `<${tag}${propString}>\n${indentedChildren}</${tag}>`;
28
+ }
29
+ function guard(value, cb) {
30
+ if (!!value || value === 0) {
31
+ const children = cb(value);
32
+ return render(children);
33
+ }
34
+ return "";
35
+ }
36
+ function render(children) {
37
+ if (Array.isArray(children)) {
38
+ const filteredChildren = children.filter((c) => c !== undefined);
39
+ return filteredChildren
40
+ .map((i) => (Array.isArray(i) ? i.join("") : i))
41
+ .join("");
42
+ }
43
+ return children !== null && children !== void 0 ? children : "";
44
+ }
45
+ // Regex to selectively URL-encode '>' and '<' chars
46
+ exports.lessThan = /<=?(?!(=|button|\s?\/button|code|\s?\/code|details|\s?\/details|summary|\s?\/summary|hr|\s?\/hr|br|\s?\/br|span|\s?\/span|strong|\s?\/strong|small|\s?\/small|table|\s?\/table|thead|\s?\/thead|tbody|\s?\/tbody|td|\s?\/td|tr|\s?\/tr|th|\s?\/th|h1|\s?\/h1|h2|\s?\/h2|h3|\s?\/h3|h4|\s?\/h4|h5|\s?\/h5|h6|\s?\/h6|title|\s?\/title|p|\s?\/p|em|\s?\/em|b|\s?\/b|i|\s?\/i|u|\s?\/u|strike|\s?\/strike|bold|\s?\/bold|a|\s?\/a|table|\s?\/table|li|\s?\/li|ol|\s?\/ol|ul|\s?\/ul|img|\s?\/img|svg|\s?\/svg|div|\s?\/div|center|\s?\/center))/gu;
47
+ exports.greaterThan = /(?<!(button|code|details|summary|hr|br|span|strong|small|table|thead|tbody|td|tr|th|h1|h2|h3|h4|h5|h6|title|p|em|b|i|u|strike|bold|a|li|ol|ul|img|svg|div|center|\/|\s|"|'))>/gu;
48
+ exports.codeFence = /`{1,3}[\s\S]*?`{1,3}/g;
49
+ exports.curlyBrackets = /([{}])/g;
50
+ exports.codeBlock = /(^```.*[\s\S]*?```$|`[^`].+?`)/gm;
51
+ function clean(value) {
52
+ if (!value) {
53
+ return "";
54
+ }
55
+ let sections = value.split(exports.codeBlock);
56
+ for (let sectionIndex in sections) {
57
+ if (!sections[sectionIndex].startsWith("`")) {
58
+ sections[sectionIndex] = sections[sectionIndex]
59
+ .replace(exports.lessThan, "&lt;")
60
+ .replace(exports.greaterThan, "&gt;")
61
+ .replace(exports.codeFence, function (match) {
62
+ return match.replace(/\\>/g, ">");
63
+ })
64
+ .replace(exports.curlyBrackets, "\\$1");
65
+ }
66
+ }
67
+ return sections.join("");
68
+ }
@@ -0,0 +1,2 @@
1
+ import { SchemaObject } from "./types";
2
+ export declare const sampleRequestFromSchema: (schema?: SchemaObject) => any;
@@ -0,0 +1,14 @@
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.sampleRequestFromSchema = void 0;
10
+ const createSchemaExample_1 = require("./createSchemaExample");
11
+ const sampleRequestFromSchema = (schema = {}) => {
12
+ return (0, createSchemaExample_1.sampleFromSchema)(schema, { type: "request" });
13
+ };
14
+ exports.sampleRequestFromSchema = sampleRequestFromSchema;
@@ -0,0 +1,2 @@
1
+ import { SchemaObject } from "./types";
2
+ export declare const sampleResponseFromSchema: (schema?: SchemaObject) => any;
@@ -0,0 +1,14 @@
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.sampleResponseFromSchema = void 0;
10
+ const createSchemaExample_1 = require("./createSchemaExample");
11
+ const sampleResponseFromSchema = (schema = {}) => {
12
+ return (0, createSchemaExample_1.sampleFromSchema)(schema, { type: "response" });
13
+ };
14
+ exports.sampleResponseFromSchema = sampleResponseFromSchema;
@@ -0,0 +1,7 @@
1
+ import { SchemaObject } from "./types";
2
+ type ExampleType = "request" | "response";
3
+ interface ExampleContext {
4
+ type: ExampleType;
5
+ }
6
+ export declare const sampleFromSchema: (schema: SchemaObject | undefined, context: ExampleContext) => any;
7
+ export {};
@@ -0,0 +1,231 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.sampleFromSchema = void 0;
13
+ const chalk_1 = __importDefault(require("chalk"));
14
+ const merge_1 = __importDefault(require("lodash/merge"));
15
+ const createSchema_1 = require("../markdown/createSchema");
16
+ const primitives = {
17
+ string: {
18
+ default: () => "string",
19
+ email: () => "user@example.com",
20
+ date: () => "2024-07-29",
21
+ "date-time": () => "2024-07-29T15:51:28.071Z",
22
+ uuid: () => "3fa85f64-5717-4562-b3fc-2c963f66afa6",
23
+ hostname: () => "example.com",
24
+ ipv4: () => "198.51.100.42",
25
+ ipv6: () => "2001:0db8:5b96:0000:0000:426f:8e17:642a",
26
+ },
27
+ number: {
28
+ default: () => 0,
29
+ float: () => 0.0,
30
+ },
31
+ integer: {
32
+ default: () => 0,
33
+ },
34
+ boolean: {
35
+ default: (schema) => typeof schema.default === "boolean" ? schema.default : true,
36
+ },
37
+ object: {},
38
+ array: {},
39
+ null: {
40
+ default: () => "null",
41
+ },
42
+ };
43
+ function shouldExcludeProperty(prop, context) {
44
+ if (prop.deprecated) {
45
+ return true;
46
+ }
47
+ if (context.type === "request") {
48
+ return prop.readOnly === true;
49
+ }
50
+ else {
51
+ return prop.writeOnly === true;
52
+ }
53
+ }
54
+ function sampleFromProp(name, prop, obj, context) {
55
+ // Handle resolved circular props
56
+ if (typeof prop === "object" && Object.keys(prop).length === 0) {
57
+ obj[name] = prop;
58
+ return obj;
59
+ }
60
+ // TODO: handle discriminators
61
+ if (prop.oneOf) {
62
+ obj[name] = (0, exports.sampleFromSchema)(prop.oneOf[0], context);
63
+ }
64
+ else if (prop.anyOf) {
65
+ obj[name] = (0, exports.sampleFromSchema)(prop.anyOf[0], context);
66
+ }
67
+ else if (prop.allOf) {
68
+ const mergedSchemas = (0, createSchema_1.mergeAllOf)(prop);
69
+ sampleFromProp(name, mergedSchemas, obj, context);
70
+ }
71
+ else {
72
+ obj[name] = (0, exports.sampleFromSchema)(prop, context);
73
+ }
74
+ return obj;
75
+ }
76
+ const sampleFromSchema = (schema = {}, context) => {
77
+ try {
78
+ // deep copy schema before processing
79
+ let schemaCopy = JSON.parse(JSON.stringify(schema));
80
+ let { type, example, allOf, properties, items, oneOf, anyOf } = schemaCopy;
81
+ if (example !== undefined) {
82
+ return example;
83
+ }
84
+ if (oneOf) {
85
+ if (properties) {
86
+ const combinedSchemas = (0, merge_1.default)(schemaCopy, oneOf[0]);
87
+ delete combinedSchemas.oneOf;
88
+ return (0, exports.sampleFromSchema)(combinedSchemas, context);
89
+ }
90
+ // Just go with first schema
91
+ return (0, exports.sampleFromSchema)(oneOf[0], context);
92
+ }
93
+ if (anyOf) {
94
+ if (properties) {
95
+ const combinedSchemas = (0, merge_1.default)(schemaCopy, anyOf[0]);
96
+ delete combinedSchemas.anyOf;
97
+ return (0, exports.sampleFromSchema)(combinedSchemas, context);
98
+ }
99
+ // Just go with first schema
100
+ return (0, exports.sampleFromSchema)(anyOf[0], context);
101
+ }
102
+ if (allOf) {
103
+ const mergedSchemas = (0, createSchema_1.mergeAllOf)(schemaCopy);
104
+ if (mergedSchemas.properties) {
105
+ for (const [key, value] of Object.entries(mergedSchemas.properties)) {
106
+ if (shouldExcludeProperty(value, context)) {
107
+ delete mergedSchemas.properties[key];
108
+ }
109
+ }
110
+ }
111
+ if (properties) {
112
+ const combinedSchemas = (0, merge_1.default)(schemaCopy, mergedSchemas);
113
+ delete combinedSchemas.allOf;
114
+ return (0, exports.sampleFromSchema)(combinedSchemas, context);
115
+ }
116
+ return (0, exports.sampleFromSchema)(mergedSchemas, context);
117
+ }
118
+ if (!type) {
119
+ if (properties) {
120
+ type = "object";
121
+ }
122
+ else if (items) {
123
+ type = "array";
124
+ }
125
+ else {
126
+ return;
127
+ }
128
+ }
129
+ if (type === "object") {
130
+ let obj = {};
131
+ for (let [name, prop] of Object.entries(properties !== null && properties !== void 0 ? properties : {})) {
132
+ if (prop.properties) {
133
+ for (const [key, value] of Object.entries(prop.properties)) {
134
+ if (shouldExcludeProperty(value, context)) {
135
+ delete prop.properties[key];
136
+ }
137
+ }
138
+ }
139
+ if (prop.items && prop.items.properties) {
140
+ for (const [key, value] of Object.entries(prop.items.properties)) {
141
+ if (shouldExcludeProperty(value, context)) {
142
+ delete prop.items.properties[key];
143
+ }
144
+ }
145
+ }
146
+ if (shouldExcludeProperty(prop, context)) {
147
+ continue;
148
+ }
149
+ // Resolve schema from prop recursively
150
+ obj = sampleFromProp(name, prop, obj, context);
151
+ }
152
+ return obj;
153
+ }
154
+ if (type === "array") {
155
+ if (Array.isArray(items === null || items === void 0 ? void 0 : items.anyOf)) {
156
+ return processArrayItems(items, "anyOf", context);
157
+ }
158
+ if (Array.isArray(items === null || items === void 0 ? void 0 : items.oneOf)) {
159
+ return processArrayItems(items, "oneOf", context);
160
+ }
161
+ return normalizeArray((0, exports.sampleFromSchema)(items, context));
162
+ }
163
+ if (schemaCopy.enum) {
164
+ if (schemaCopy.default) {
165
+ return schemaCopy.default;
166
+ }
167
+ return normalizeArray(schemaCopy.enum)[0];
168
+ }
169
+ if (shouldExcludeProperty(schemaCopy, context)) {
170
+ return undefined;
171
+ }
172
+ return primitive(schemaCopy);
173
+ }
174
+ catch (err) {
175
+ console.error(chalk_1.default.yellow("WARNING: failed to create example from schema object:", err));
176
+ return;
177
+ }
178
+ };
179
+ exports.sampleFromSchema = sampleFromSchema;
180
+ function primitive(schema = {}) {
181
+ let { type, format } = schema;
182
+ if (type === undefined) {
183
+ return;
184
+ }
185
+ // If type is an array, use the first type
186
+ if (Array.isArray(type)) {
187
+ type = type[0];
188
+ if (type === undefined) {
189
+ return;
190
+ }
191
+ }
192
+ // Use schema default if available, otherwise use type default
193
+ if (schema.default !== undefined) {
194
+ return schema.default;
195
+ }
196
+ const typeConfig = primitives[type];
197
+ if (typeConfig) {
198
+ if (format !== undefined && typeConfig[format] !== undefined) {
199
+ return typeConfig[format](schema);
200
+ }
201
+ if (typeConfig.default !== undefined) {
202
+ return typeConfig.default(schema);
203
+ }
204
+ }
205
+ return "Unknown Type: " + schema.type;
206
+ }
207
+ function normalizeArray(arr) {
208
+ if (Array.isArray(arr)) {
209
+ return arr;
210
+ }
211
+ return [arr];
212
+ }
213
+ function processArrayItems(items, schemaType, context) {
214
+ const itemsArray = items[schemaType];
215
+ return itemsArray.map((item) => {
216
+ // If items has properties, merge them with each item
217
+ if (items.properties) {
218
+ const combinedSchema = {
219
+ ...item,
220
+ properties: {
221
+ ...items.properties, // Common properties from parent
222
+ ...item.properties, // Specific properties from this anyOf/oneOf item
223
+ },
224
+ };
225
+ // Remove anyOf/oneOf to prevent infinite recursion when calling sampleFromSchema
226
+ delete combinedSchema[schemaType];
227
+ return (0, exports.sampleFromSchema)(combinedSchema, context);
228
+ }
229
+ return (0, exports.sampleFromSchema)(item, context);
230
+ });
231
+ }
@@ -0,0 +1 @@
1
+ export { readOpenapiFiles, processOpenapiFiles } from "./openapi";
@@ -0,0 +1,12 @@
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.processOpenapiFiles = exports.readOpenapiFiles = void 0;
10
+ var openapi_1 = require("./openapi");
11
+ Object.defineProperty(exports, "readOpenapiFiles", { enumerable: true, get: function () { return openapi_1.readOpenapiFiles; } });
12
+ Object.defineProperty(exports, "processOpenapiFiles", { enumerable: true, get: function () { return openapi_1.processOpenapiFiles; } });
@@ -0,0 +1,12 @@
1
+ import { OpenApiObject, TagGroupObject, TagObject } from "./types";
2
+ import { ApiMetadata, APIOptions, SidebarOptions } from "../types";
3
+ interface OpenApiFiles {
4
+ source: string;
5
+ sourceDirName: string;
6
+ data: OpenApiObject;
7
+ }
8
+ export declare function readOpenapiFiles(openapiPath: string): Promise<OpenApiFiles[]>;
9
+ export declare function processOpenapiFiles(files: OpenApiFiles[], options: APIOptions, sidebarOptions: SidebarOptions, siteDir?: string): Promise<[ApiMetadata[], TagObject[][], TagGroupObject[]]>;
10
+ export declare function processOpenapiFile(openapiData: OpenApiObject, options: APIOptions, sidebarOptions: SidebarOptions, siteDir?: string): Promise<[ApiMetadata[], TagObject[], TagGroupObject[]]>;
11
+ export declare function getTagDisplayName(tagName: string, tags: TagObject[]): string;
12
+ export {};