docusaurus-plugin-openapi-docs 0.0.0-346 → 0.0.0-348

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 (54) hide show
  1. package/package.json +2 -2
  2. package/lib/index.d.ts +0 -3
  3. package/lib/index.js +0 -194
  4. package/lib/markdown/createDeprecationNotice.d.ts +0 -6
  5. package/lib/markdown/createDeprecationNotice.js +0 -19
  6. package/lib/markdown/createDescription.d.ts +0 -1
  7. package/lib/markdown/createDescription.js +0 -16
  8. package/lib/markdown/createDetails.d.ts +0 -2
  9. package/lib/markdown/createDetails.js +0 -18
  10. package/lib/markdown/createDetailsSummary.d.ts +0 -2
  11. package/lib/markdown/createDetailsSummary.js +0 -18
  12. package/lib/markdown/createFullWidthTable.d.ts +0 -2
  13. package/lib/markdown/createFullWidthTable.js +0 -18
  14. package/lib/markdown/createParamsDetails.d.ts +0 -7
  15. package/lib/markdown/createParamsDetails.js +0 -44
  16. package/lib/markdown/createParamsTable.d.ts +0 -7
  17. package/lib/markdown/createParamsTable.js +0 -80
  18. package/lib/markdown/createRequestBodyDetails.d.ts +0 -6
  19. package/lib/markdown/createRequestBodyDetails.js +0 -14
  20. package/lib/markdown/createRequestBodyTable.d.ts +0 -6
  21. package/lib/markdown/createRequestBodyTable.js +0 -14
  22. package/lib/markdown/createSchemaDetails.d.ts +0 -14
  23. package/lib/markdown/createSchemaDetails.js +0 -241
  24. package/lib/markdown/createSchemaTable.d.ts +0 -14
  25. package/lib/markdown/createSchemaTable.js +0 -217
  26. package/lib/markdown/createStatusCodes.d.ts +0 -6
  27. package/lib/markdown/createStatusCodes.js +0 -47
  28. package/lib/markdown/createVersionBadge.d.ts +0 -1
  29. package/lib/markdown/createVersionBadge.js +0 -20
  30. package/lib/markdown/index.d.ts +0 -3
  31. package/lib/markdown/index.js +0 -43
  32. package/lib/markdown/schema.d.ts +0 -3
  33. package/lib/markdown/schema.js +0 -100
  34. package/lib/markdown/schema.test.d.ts +0 -1
  35. package/lib/markdown/schema.test.js +0 -171
  36. package/lib/markdown/utils.d.ts +0 -7
  37. package/lib/markdown/utils.js +0 -33
  38. package/lib/openapi/createExample.d.ts +0 -2
  39. package/lib/openapi/createExample.js +0 -113
  40. package/lib/openapi/index.d.ts +0 -1
  41. package/lib/openapi/index.js +0 -12
  42. package/lib/openapi/openapi.d.ts +0 -11
  43. package/lib/openapi/openapi.js +0 -231
  44. package/lib/openapi/openapi.test.d.ts +0 -1
  45. package/lib/openapi/openapi.test.js +0 -33
  46. package/lib/openapi/types.d.ts +0 -332
  47. package/lib/openapi/types.js +0 -8
  48. package/lib/options.d.ts +0 -4
  49. package/lib/options.js +0 -18
  50. package/lib/sidebars/index.d.ts +0 -3
  51. package/lib/sidebars/index.js +0 -89
  52. package/lib/types.d.ts +0 -68
  53. package/lib/types.js +0 -8
  54. package/yarn-error.log +0 -15179
@@ -1,100 +0,0 @@
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.getQualifierMessage = exports.getSchemaName = void 0;
10
- function prettyName(schema, circular) {
11
- var _a, _b, _c;
12
- if (schema.$ref) {
13
- return schema.$ref.replace("#/components/schemas/", "") + circular
14
- ? " (circular)"
15
- : "";
16
- }
17
- if (schema.format) {
18
- return schema.format;
19
- }
20
- if (schema.allOf) {
21
- return "object";
22
- }
23
- if (schema.type === "object") {
24
- return (_b = (_a = schema.xml) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : schema.type;
25
- }
26
- return (_c = schema.title) !== null && _c !== void 0 ? _c : schema.type;
27
- }
28
- function getSchemaName(schema, circular) {
29
- var _a;
30
- if (schema.items) {
31
- return prettyName(schema.items, circular) + "[]";
32
- }
33
- return (_a = prettyName(schema, circular)) !== null && _a !== void 0 ? _a : "";
34
- }
35
- exports.getSchemaName = getSchemaName;
36
- function getQualifierMessage(schema) {
37
- // TODO:
38
- // - maxItems
39
- // - minItems
40
- // - uniqueItems
41
- // - maxProperties
42
- // - minProperties
43
- // - multipleOf
44
- if (!schema) {
45
- return undefined;
46
- }
47
- if (schema.items) {
48
- return getQualifierMessage(schema.items);
49
- }
50
- let message = "**Possible values:** ";
51
- let qualifierGroups = [];
52
- if (schema.minLength || schema.maxLength) {
53
- let lengthQualifier = "";
54
- if (schema.minLength) {
55
- lengthQualifier += `${schema.minLength} ≤ `;
56
- }
57
- lengthQualifier += "length";
58
- if (schema.maxLength) {
59
- lengthQualifier += ` ≤ ${schema.maxLength}`;
60
- }
61
- qualifierGroups.push(lengthQualifier);
62
- }
63
- if (schema.minimum ||
64
- schema.maximum ||
65
- typeof schema.exclusiveMinimum === "number" ||
66
- typeof schema.exclusiveMaximum === "number") {
67
- let minmaxQualifier = "";
68
- if (typeof schema.exclusiveMinimum === "number") {
69
- minmaxQualifier += `${schema.exclusiveMinimum} < `;
70
- }
71
- else if (schema.minimum && !schema.exclusiveMinimum) {
72
- minmaxQualifier += `${schema.minimum} ≤ `;
73
- }
74
- else if (schema.minimum && schema.exclusiveMinimum === true) {
75
- minmaxQualifier += `${schema.minimum} < `;
76
- }
77
- minmaxQualifier += "value";
78
- if (typeof schema.exclusiveMaximum === "number") {
79
- minmaxQualifier += ` < ${schema.exclusiveMaximum}`;
80
- }
81
- else if (schema.maximum && !schema.exclusiveMaximum) {
82
- minmaxQualifier += ` ≤ ${schema.maximum}`;
83
- }
84
- else if (schema.maximum && schema.exclusiveMaximum === true) {
85
- minmaxQualifier += ` < ${schema.maximum}`;
86
- }
87
- qualifierGroups.push(minmaxQualifier);
88
- }
89
- if (schema.pattern) {
90
- qualifierGroups.push(`Value must match regular expression \`${schema.pattern}\``);
91
- }
92
- if (schema.enum) {
93
- qualifierGroups.push(`[${schema.enum.map((e) => `\`${e}\``).join(", ")}]`);
94
- }
95
- if (qualifierGroups.length === 0) {
96
- return undefined;
97
- }
98
- return message + qualifierGroups.join(", ");
99
- }
100
- exports.getQualifierMessage = getQualifierMessage;
@@ -1 +0,0 @@
1
- export {};
@@ -1,171 +0,0 @@
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
- const schema_1 = require("./schema");
10
- describe("getQualifierMessage", () => {
11
- it("should render nothing", () => {
12
- const actual = (0, schema_1.getQualifierMessage)({});
13
- expect(actual).toBeUndefined();
14
- });
15
- //
16
- // minLength + maxLength
17
- //
18
- it("should render minLength", () => {
19
- const expected = "**Possible values:** 1 ≤ length";
20
- const actual = (0, schema_1.getQualifierMessage)({ minLength: 1 });
21
- expect(actual).toBe(expected);
22
- });
23
- it("should render maxLength", () => {
24
- const expected = "**Possible values:** length ≤ 40";
25
- const actual = (0, schema_1.getQualifierMessage)({ maxLength: 40 });
26
- expect(actual).toBe(expected);
27
- });
28
- it("should render minLength and maxLength", () => {
29
- const expected = "**Possible values:** 1 ≤ length ≤ 40";
30
- const actual = (0, schema_1.getQualifierMessage)({ minLength: 1, maxLength: 40 });
31
- expect(actual).toBe(expected);
32
- });
33
- //
34
- // pattern
35
- //
36
- it("should render pattern", () => {
37
- const expected = "**Possible values:** Value must match regular expression `^[a-zA-Z0-9_-]*$`";
38
- const actual = (0, schema_1.getQualifierMessage)({ pattern: "^[a-zA-Z0-9_-]*$" });
39
- expect(actual).toBe(expected);
40
- });
41
- it("should render multiple string qualifiers", () => {
42
- const expected = "**Possible values:** 1 ≤ length ≤ 40, Value must match regular expression `^[a-zA-Z0-9_-]*$`";
43
- const actual = (0, schema_1.getQualifierMessage)({
44
- minLength: 1,
45
- maxLength: 40,
46
- pattern: "^[a-zA-Z0-9_-]*$",
47
- });
48
- expect(actual).toBe(expected);
49
- });
50
- //
51
- // enum
52
- //
53
- it("should render enum", () => {
54
- const expected = "**Possible values:** [`cat`, `dog`, `mouse`]";
55
- const actual = (0, schema_1.getQualifierMessage)({ enum: ["cat", "dog", "mouse"] });
56
- expect(actual).toBe(expected);
57
- });
58
- //
59
- // minimum + maximum + exclusiveMinimum + exclusiveMaximum
60
- //
61
- it("should render minimum", () => {
62
- const expected = "**Possible values:** 1 ≤ value";
63
- const actual = (0, schema_1.getQualifierMessage)({ minimum: 1 });
64
- expect(actual).toBe(expected);
65
- });
66
- it("should render maximum", () => {
67
- const expected = "**Possible values:** value ≤ 40";
68
- const actual = (0, schema_1.getQualifierMessage)({ maximum: 40 });
69
- expect(actual).toBe(expected);
70
- });
71
- it("should render numeric exclusiveMinimum", () => {
72
- const expected = "**Possible values:** 1 < value";
73
- const actual = (0, schema_1.getQualifierMessage)({ exclusiveMinimum: 1 });
74
- expect(actual).toBe(expected);
75
- });
76
- it("should render numeric exclusiveMaximum", () => {
77
- const expected = "**Possible values:** value < 40";
78
- const actual = (0, schema_1.getQualifierMessage)({ exclusiveMaximum: 40 });
79
- expect(actual).toBe(expected);
80
- });
81
- it("should render boolean exclusiveMinimum", () => {
82
- const expected = "**Possible values:** 1 < value";
83
- const actual = (0, schema_1.getQualifierMessage)({ minimum: 1, exclusiveMinimum: true });
84
- expect(actual).toBe(expected);
85
- });
86
- it("should render boolean exclusiveMaximum", () => {
87
- const expected = "**Possible values:** value < 40";
88
- const actual = (0, schema_1.getQualifierMessage)({ maximum: 40, exclusiveMaximum: true });
89
- expect(actual).toBe(expected);
90
- });
91
- it("should render minimum when exclusiveMinimum is false", () => {
92
- const expected = "**Possible values:** 1 ≤ value";
93
- const actual = (0, schema_1.getQualifierMessage)({ minimum: 1, exclusiveMinimum: false });
94
- expect(actual).toBe(expected);
95
- });
96
- it("should render maximum when exclusiveMaximum is false", () => {
97
- const expected = "**Possible values:** value ≤ 40";
98
- const actual = (0, schema_1.getQualifierMessage)({
99
- maximum: 40,
100
- exclusiveMaximum: false,
101
- });
102
- expect(actual).toBe(expected);
103
- });
104
- it("should render minimum and maximum", () => {
105
- const expected = "**Possible values:** 1 ≤ value ≤ 40";
106
- const actual = (0, schema_1.getQualifierMessage)({ minimum: 1, maximum: 40 });
107
- expect(actual).toBe(expected);
108
- });
109
- it("should render boolean exclusiveMinimum and maximum", () => {
110
- const expected = "**Possible values:** 1 < value ≤ 40";
111
- const actual = (0, schema_1.getQualifierMessage)({
112
- minimum: 1,
113
- maximum: 40,
114
- exclusiveMinimum: true,
115
- });
116
- expect(actual).toBe(expected);
117
- });
118
- it("should render minimum and boolean exclusiveMaximum", () => {
119
- const expected = "**Possible values:** 1 ≤ value < 40";
120
- const actual = (0, schema_1.getQualifierMessage)({
121
- minimum: 1,
122
- maximum: 40,
123
- exclusiveMaximum: true,
124
- });
125
- expect(actual).toBe(expected);
126
- });
127
- it("should render numeric exclusiveMinimum and maximum", () => {
128
- const expected = "**Possible values:** 1 < value ≤ 40";
129
- const actual = (0, schema_1.getQualifierMessage)({
130
- exclusiveMinimum: 1,
131
- maximum: 40,
132
- });
133
- expect(actual).toBe(expected);
134
- });
135
- it("should render minimum and numeric exclusiveMaximum", () => {
136
- const expected = "**Possible values:** 1 ≤ value < 40";
137
- const actual = (0, schema_1.getQualifierMessage)({
138
- minimum: 1,
139
- exclusiveMaximum: 40,
140
- });
141
- expect(actual).toBe(expected);
142
- });
143
- it("should render numeric exclusiveMinimum and boolean exclusiveMaximum", () => {
144
- const expected = "**Possible values:** 1 < value < 40";
145
- const actual = (0, schema_1.getQualifierMessage)({
146
- exclusiveMinimum: 1,
147
- maximum: 40,
148
- exclusiveMaximum: true,
149
- });
150
- expect(actual).toBe(expected);
151
- });
152
- it("should render nothing with empty boolean exclusiveMinimum", () => {
153
- const actual = (0, schema_1.getQualifierMessage)({
154
- exclusiveMinimum: true,
155
- });
156
- expect(actual).toBeUndefined();
157
- });
158
- it("should render nothing with empty boolean exclusiveMaximum", () => {
159
- const actual = (0, schema_1.getQualifierMessage)({
160
- exclusiveMaximum: true,
161
- });
162
- expect(actual).toBeUndefined();
163
- });
164
- it("should render nothing with empty boolean exclusiveMinimum and exclusiveMaximum", () => {
165
- const actual = (0, schema_1.getQualifierMessage)({
166
- exclusiveMinimum: true,
167
- exclusiveMaximum: true,
168
- });
169
- expect(actual).toBeUndefined();
170
- });
171
- });
@@ -1,7 +0,0 @@
1
- export declare type Children = string | undefined | (string | undefined)[];
2
- export declare type Props = Record<string, any> & {
3
- children?: Children;
4
- };
5
- export declare function create(tag: string, props: Props): string;
6
- export declare function guard<T>(value: T | undefined, cb: (value: T) => Children): string;
7
- export declare function render(children: Children): string;
@@ -1,33 +0,0 @@
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.render = exports.guard = exports.create = void 0;
10
- function create(tag, props) {
11
- const { children, ...rest } = props;
12
- let propString = "";
13
- for (const [key, value] of Object.entries(rest)) {
14
- propString += ` ${key}={${JSON.stringify(value)}}`;
15
- }
16
- return `<${tag}${propString}>${render(children)}</${tag}>`;
17
- }
18
- exports.create = create;
19
- function guard(value, cb) {
20
- if (value) {
21
- const children = cb(value);
22
- return render(children);
23
- }
24
- return "";
25
- }
26
- exports.guard = guard;
27
- function render(children) {
28
- if (Array.isArray(children)) {
29
- return children.filter((c) => c !== undefined).join("");
30
- }
31
- return children !== null && children !== void 0 ? children : "";
32
- }
33
- exports.render = render;
@@ -1,2 +0,0 @@
1
- import { SchemaObject } from "./types";
2
- export declare const sampleFromSchema: (schema?: SchemaObject) => any;
@@ -1,113 +0,0 @@
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.sampleFromSchema = void 0;
10
- const primitives = {
11
- string: {
12
- default: () => "string",
13
- email: () => "user@example.com",
14
- date: () => new Date().toISOString().substring(0, 10),
15
- uuid: () => "3fa85f64-5717-4562-b3fc-2c963f66afa6",
16
- hostname: () => "example.com",
17
- ipv4: () => "198.51.100.42",
18
- ipv6: () => "2001:0db8:5b96:0000:0000:426f:8e17:642a",
19
- },
20
- number: {
21
- default: () => 0,
22
- float: () => 0.0,
23
- },
24
- integer: {
25
- default: () => 0,
26
- },
27
- boolean: {
28
- default: (schema) => typeof schema.default === "boolean" ? schema.default : true,
29
- },
30
- object: {},
31
- array: {},
32
- };
33
- 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";
58
- }
59
- else if (items) {
60
- type = "array";
61
- }
62
- else {
63
- return;
64
- }
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
- }
72
- obj[name] = (0, exports.sampleFromSchema)(prop);
73
- }
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));
79
- }
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));
82
- }
83
- return [(0, exports.sampleFromSchema)(items)];
84
- }
85
- if (schema.enum) {
86
- if (schema.default) {
87
- return schema.default;
88
- }
89
- return normalizeArray(schema.enum)[0];
90
- }
91
- return primitive(schema);
92
- };
93
- exports.sampleFromSchema = sampleFromSchema;
94
- function primitive(schema = {}) {
95
- let { type, format } = schema;
96
- if (type === undefined) {
97
- return;
98
- }
99
- let fn = primitives[type].default;
100
- if (format !== undefined) {
101
- fn = primitives[type][format] || fn;
102
- }
103
- if (fn) {
104
- return fn(schema);
105
- }
106
- return "Unknown Type: " + schema.type;
107
- }
108
- function normalizeArray(arr) {
109
- if (Array.isArray(arr)) {
110
- return arr;
111
- }
112
- return [arr];
113
- }
@@ -1 +0,0 @@
1
- export { readOpenapiFiles, processOpenapiFiles } from "./openapi";
@@ -1,12 +0,0 @@
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; } });
@@ -1,11 +0,0 @@
1
- import { ApiMetadata } from "../types";
2
- import { OpenApiObjectWithRef } from "./types";
3
- interface OpenApiFiles {
4
- source: string;
5
- sourceDirName: string;
6
- data: OpenApiObjectWithRef;
7
- }
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[]>;
11
- export {};