docusaurus-plugin-openapi-docs 4.3.7 → 4.5.0
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.
- package/README.md +32 -27
- package/lib/index.js +11 -6
- package/lib/markdown/createAuthentication.js +4 -2
- package/lib/markdown/schema.js +3 -0
- package/lib/openapi/createRequestExample.js +2 -179
- package/lib/openapi/createResponseExample.js +2 -180
- package/lib/openapi/createSchemaExample.d.ts +7 -0
- package/lib/openapi/createSchemaExample.js +231 -0
- package/lib/openapi/openapi.js +51 -2
- package/lib/openapi/types.d.ts +57 -59
- package/lib/openapi/utils/services/OpenAPIParser.d.ts +1 -1
- package/lib/openapi/utils/types.d.ts +1 -0
- package/lib/options.js +3 -0
- package/lib/types.d.ts +4 -1
- package/package.json +2 -2
- package/src/index.ts +13 -5
- package/src/markdown/createAuthentication.ts +12 -4
- package/src/markdown/schema.ts +3 -0
- package/src/openapi/createRequestExample.ts +2 -224
- package/src/openapi/createResponseExample.ts +2 -227
- package/src/openapi/createSchemaExample.ts +292 -0
- package/src/openapi/openapi.ts +19 -2
- package/src/openapi/types.ts +62 -59
- package/src/openapi/utils/types.ts +1 -0
- package/src/options.ts +3 -0
- package/src/plugin-openapi.d.ts +3 -2
- package/src/types.ts +5 -1
- package/src/postman-collection.d.ts +0 -10
|
@@ -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
|
+
}
|
package/lib/openapi/openapi.js
CHANGED
|
@@ -5,6 +5,39 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
8
41
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
42
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
43
|
};
|
|
@@ -22,7 +55,7 @@ const kebabCase_1 = __importDefault(require("lodash/kebabCase"));
|
|
|
22
55
|
const unionBy_1 = __importDefault(require("lodash/unionBy"));
|
|
23
56
|
const uniq_1 = __importDefault(require("lodash/uniq"));
|
|
24
57
|
const openapi_to_postmanv2_1 = __importDefault(require("openapi-to-postmanv2"));
|
|
25
|
-
const
|
|
58
|
+
const sdk = __importStar(require("postman-collection"));
|
|
26
59
|
const createRequestExample_1 = require("./createRequestExample");
|
|
27
60
|
const index_1 = require("../index");
|
|
28
61
|
const createResponseExample_1 = require("./createResponseExample");
|
|
@@ -38,7 +71,7 @@ function jsonToCollection(data) {
|
|
|
38
71
|
if (!conversionResult.result) {
|
|
39
72
|
return reject(conversionResult.reason);
|
|
40
73
|
}
|
|
41
|
-
return resolve(new
|
|
74
|
+
return resolve(new sdk.Collection(conversionResult.output[0].data));
|
|
42
75
|
});
|
|
43
76
|
});
|
|
44
77
|
}
|
|
@@ -211,6 +244,7 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
211
244
|
jsonRequestBodyExample,
|
|
212
245
|
info: openapiData.info,
|
|
213
246
|
},
|
|
247
|
+
position: operationObject["x-position"],
|
|
214
248
|
};
|
|
215
249
|
items.push(apiPage);
|
|
216
250
|
}
|
|
@@ -406,6 +440,21 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
406
440
|
items.push(tagPage);
|
|
407
441
|
});
|
|
408
442
|
}
|
|
443
|
+
items.sort((a, b) => {
|
|
444
|
+
// Items with position come first, sorted by position
|
|
445
|
+
if (a.position !== undefined && b.position !== undefined) {
|
|
446
|
+
return a.position - b.position;
|
|
447
|
+
}
|
|
448
|
+
// Items with position come before items without position
|
|
449
|
+
if (a.position !== undefined) {
|
|
450
|
+
return -1;
|
|
451
|
+
}
|
|
452
|
+
if (b.position !== undefined) {
|
|
453
|
+
return 1;
|
|
454
|
+
}
|
|
455
|
+
// If neither has position, maintain original order
|
|
456
|
+
return 0;
|
|
457
|
+
});
|
|
409
458
|
return items;
|
|
410
459
|
}
|
|
411
460
|
/**
|
package/lib/openapi/types.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type { JSONSchema4, JSONSchema6, JSONSchema7 } from "json-schema";
|
|
2
|
-
interface Map<T> {
|
|
3
|
-
[key: string]: T;
|
|
4
|
-
}
|
|
1
|
+
import type { JSONSchema4, JSONSchema6, JSONSchema7, JSONSchema7TypeName } from "json-schema";
|
|
5
2
|
export interface OpenApiObject {
|
|
6
3
|
openapi: string;
|
|
7
4
|
info: InfoObject;
|
|
@@ -54,7 +51,7 @@ export interface LicenseObject {
|
|
|
54
51
|
export interface ServerObject {
|
|
55
52
|
url: string;
|
|
56
53
|
description?: string;
|
|
57
|
-
variables?:
|
|
54
|
+
variables?: Record<string, ServerVariable>;
|
|
58
55
|
}
|
|
59
56
|
export interface ServerVariable {
|
|
60
57
|
enum?: string[];
|
|
@@ -62,29 +59,29 @@ export interface ServerVariable {
|
|
|
62
59
|
description?: string;
|
|
63
60
|
}
|
|
64
61
|
export interface ComponentsObject {
|
|
65
|
-
schemas?:
|
|
66
|
-
responses?:
|
|
67
|
-
parameters?:
|
|
68
|
-
examples?:
|
|
69
|
-
requestBodies?:
|
|
70
|
-
headers?:
|
|
71
|
-
securitySchemes?:
|
|
72
|
-
links?:
|
|
73
|
-
callbacks?:
|
|
62
|
+
schemas?: Record<string, SchemaObject>;
|
|
63
|
+
responses?: Record<string, ResponseObject>;
|
|
64
|
+
parameters?: Record<string, ParameterObject>;
|
|
65
|
+
examples?: Record<string, ExampleObject>;
|
|
66
|
+
requestBodies?: Record<string, RequestBodyObject>;
|
|
67
|
+
headers?: Record<string, HeaderObject>;
|
|
68
|
+
securitySchemes?: Record<string, SecuritySchemeObject>;
|
|
69
|
+
links?: Record<string, LinkObject>;
|
|
70
|
+
callbacks?: Record<string, CallbackObject>;
|
|
74
71
|
}
|
|
75
72
|
export interface ComponentsObjectWithRef {
|
|
76
|
-
schemas?:
|
|
77
|
-
responses?:
|
|
78
|
-
parameters?:
|
|
79
|
-
examples?:
|
|
80
|
-
requestBodies?:
|
|
81
|
-
headers?:
|
|
82
|
-
securitySchemes?:
|
|
83
|
-
links?:
|
|
84
|
-
callbacks?:
|
|
85
|
-
}
|
|
86
|
-
export type PathsObject =
|
|
87
|
-
export type PathsObjectWithRef =
|
|
73
|
+
schemas?: Record<string, SchemaObjectWithRef | ReferenceObject>;
|
|
74
|
+
responses?: Record<string, ResponseObjectWithRef | ReferenceObject>;
|
|
75
|
+
parameters?: Record<string, ParameterObjectWithRef | ReferenceObject>;
|
|
76
|
+
examples?: Record<string, ExampleObject | ReferenceObject>;
|
|
77
|
+
requestBodies?: Record<string, RequestBodyObjectWithRef | ReferenceObject>;
|
|
78
|
+
headers?: Record<string, HeaderObjectWithRef | ReferenceObject>;
|
|
79
|
+
securitySchemes?: Record<string, SecuritySchemeObject | ReferenceObject>;
|
|
80
|
+
links?: Record<string, LinkObject | ReferenceObject>;
|
|
81
|
+
callbacks?: Record<string, CallbackObjectWithRef | ReferenceObject>;
|
|
82
|
+
}
|
|
83
|
+
export type PathsObject = Record<string, PathItemObject>;
|
|
84
|
+
export type PathsObjectWithRef = Record<string, PathItemObjectWithRef>;
|
|
88
85
|
export interface PathItemObject {
|
|
89
86
|
$ref?: string;
|
|
90
87
|
summary?: string;
|
|
@@ -124,10 +121,11 @@ export interface OperationObject {
|
|
|
124
121
|
parameters?: ParameterObject[];
|
|
125
122
|
requestBody?: RequestBodyObject;
|
|
126
123
|
responses: ResponsesObject;
|
|
127
|
-
callbacks?:
|
|
124
|
+
callbacks?: Record<string, CallbackObject>;
|
|
128
125
|
deprecated?: boolean;
|
|
129
126
|
security?: SecurityRequirementObject[];
|
|
130
127
|
servers?: ServerObject[];
|
|
128
|
+
"x-position"?: number;
|
|
131
129
|
"x-deprecated-description"?: string;
|
|
132
130
|
}
|
|
133
131
|
export interface OperationObjectWithRef {
|
|
@@ -139,7 +137,7 @@ export interface OperationObjectWithRef {
|
|
|
139
137
|
parameters?: (ParameterObjectWithRef | ReferenceObject)[];
|
|
140
138
|
requestBody?: RequestBodyObjectWithRef | ReferenceObject;
|
|
141
139
|
responses: ResponsesObjectWithRef;
|
|
142
|
-
callbacks?:
|
|
140
|
+
callbacks?: Record<string, CallbackObjectWithRef | ReferenceObject>;
|
|
143
141
|
deprecated?: boolean;
|
|
144
142
|
security?: SecurityRequirementObject[];
|
|
145
143
|
servers?: ServerObject[];
|
|
@@ -161,8 +159,8 @@ export interface ParameterObject {
|
|
|
161
159
|
allowReserved?: boolean;
|
|
162
160
|
schema?: SchemaObject;
|
|
163
161
|
example?: any;
|
|
164
|
-
examples?:
|
|
165
|
-
content?:
|
|
162
|
+
examples?: Record<string, ExampleObject>;
|
|
163
|
+
content?: Record<string, MediaTypeObject>;
|
|
166
164
|
param?: Object;
|
|
167
165
|
"x-enumDescriptions"?: Record<string, string>;
|
|
168
166
|
}
|
|
@@ -178,62 +176,62 @@ export interface ParameterObjectWithRef {
|
|
|
178
176
|
allowReserved?: boolean;
|
|
179
177
|
schema?: SchemaObjectWithRef | ReferenceObject;
|
|
180
178
|
example?: any;
|
|
181
|
-
examples?:
|
|
182
|
-
content?:
|
|
179
|
+
examples?: Record<string, ExampleObject | ReferenceObject>;
|
|
180
|
+
content?: Record<string, MediaTypeObjectWithRef>;
|
|
183
181
|
}
|
|
184
182
|
export interface RequestBodyObject {
|
|
185
183
|
description?: string;
|
|
186
|
-
content:
|
|
184
|
+
content: Record<string, MediaTypeObject>;
|
|
187
185
|
required?: boolean;
|
|
188
186
|
}
|
|
189
187
|
export interface RequestBodyObjectWithRef {
|
|
190
188
|
description?: string;
|
|
191
|
-
content:
|
|
189
|
+
content: Record<string, MediaTypeObjectWithRef>;
|
|
192
190
|
required?: boolean;
|
|
193
191
|
}
|
|
194
192
|
export interface MediaTypeObject {
|
|
195
193
|
schema?: SchemaObject;
|
|
196
194
|
example?: any;
|
|
197
|
-
examples?:
|
|
198
|
-
encoding?:
|
|
195
|
+
examples?: Record<string, ExampleObject>;
|
|
196
|
+
encoding?: Record<string, EncodingObject>;
|
|
199
197
|
type?: any;
|
|
200
198
|
}
|
|
201
199
|
export interface MediaTypeObjectWithRef {
|
|
202
200
|
schema?: SchemaObjectWithRef | ReferenceObject;
|
|
203
201
|
example?: any;
|
|
204
|
-
examples?:
|
|
205
|
-
encoding?:
|
|
202
|
+
examples?: Record<string, ExampleObject | ReferenceObject>;
|
|
203
|
+
encoding?: Record<string, EncodingObjectWithRef>;
|
|
206
204
|
}
|
|
207
205
|
export interface EncodingObject {
|
|
208
206
|
contentType?: string;
|
|
209
|
-
headers?:
|
|
207
|
+
headers?: Record<string, HeaderObject>;
|
|
210
208
|
style?: string;
|
|
211
209
|
explode?: boolean;
|
|
212
210
|
allowReserved?: boolean;
|
|
213
211
|
}
|
|
214
212
|
export interface EncodingObjectWithRef {
|
|
215
213
|
contentType?: string;
|
|
216
|
-
headers?:
|
|
214
|
+
headers?: Record<string, HeaderObjectWithRef | ReferenceObject>;
|
|
217
215
|
style?: string;
|
|
218
216
|
explode?: boolean;
|
|
219
217
|
allowReserved?: boolean;
|
|
220
218
|
}
|
|
221
|
-
export type ResponsesObject =
|
|
222
|
-
export type ResponsesObjectWithRef =
|
|
219
|
+
export type ResponsesObject = Record<string, ResponseObject>;
|
|
220
|
+
export type ResponsesObjectWithRef = Record<string, ResponseObjectWithRef | ReferenceObject>;
|
|
223
221
|
export interface ResponseObject {
|
|
224
222
|
description: string;
|
|
225
|
-
headers?:
|
|
226
|
-
content?:
|
|
227
|
-
links?:
|
|
223
|
+
headers?: Record<string, HeaderObject>;
|
|
224
|
+
content?: Record<string, MediaTypeObject>;
|
|
225
|
+
links?: Record<string, LinkObject>;
|
|
228
226
|
}
|
|
229
227
|
export interface ResponseObjectWithRef {
|
|
230
228
|
description: string;
|
|
231
|
-
headers?:
|
|
232
|
-
content?:
|
|
233
|
-
links?:
|
|
229
|
+
headers?: Record<string, HeaderObjectWithRef | ReferenceObject>;
|
|
230
|
+
content?: Record<string, MediaTypeObjectWithRef>;
|
|
231
|
+
links?: Record<string, LinkObject | ReferenceObject>;
|
|
234
232
|
}
|
|
235
|
-
export type CallbackObject =
|
|
236
|
-
export type CallbackObjectWithRef =
|
|
233
|
+
export type CallbackObject = Record<string, PathItemObject>;
|
|
234
|
+
export type CallbackObjectWithRef = Record<string, PathItemObjectWithRef>;
|
|
237
235
|
export interface ExampleObject {
|
|
238
236
|
summary?: string;
|
|
239
237
|
description?: string;
|
|
@@ -243,7 +241,7 @@ export interface ExampleObject {
|
|
|
243
241
|
export interface LinkObject {
|
|
244
242
|
operationRef?: string;
|
|
245
243
|
operationId?: string;
|
|
246
|
-
parameters?:
|
|
244
|
+
parameters?: Record<string, any>;
|
|
247
245
|
requestBody?: any;
|
|
248
246
|
description?: string;
|
|
249
247
|
server?: ServerObject;
|
|
@@ -264,14 +262,15 @@ export interface ReferenceObject {
|
|
|
264
262
|
$ref: string;
|
|
265
263
|
}
|
|
266
264
|
export type JSONSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;
|
|
265
|
+
export type SchemaType = JSONSchema7TypeName;
|
|
267
266
|
export type SchemaObject = Omit<JSONSchema, "type" | "allOf" | "oneOf" | "anyOf" | "not" | "items" | "properties" | "additionalProperties"> & {
|
|
268
|
-
type?:
|
|
267
|
+
type?: SchemaType;
|
|
269
268
|
allOf?: SchemaObject[];
|
|
270
269
|
oneOf?: SchemaObject[];
|
|
271
270
|
anyOf?: SchemaObject[];
|
|
272
271
|
not?: SchemaObject;
|
|
273
272
|
items?: SchemaObject;
|
|
274
|
-
properties?:
|
|
273
|
+
properties?: Record<string, SchemaObject>;
|
|
275
274
|
additionalProperties?: boolean | SchemaObject;
|
|
276
275
|
nullable?: boolean;
|
|
277
276
|
discriminator?: DiscriminatorObject;
|
|
@@ -285,13 +284,13 @@ export type SchemaObject = Omit<JSONSchema, "type" | "allOf" | "oneOf" | "anyOf"
|
|
|
285
284
|
"x-enumDescriptions"?: Record<string, string>;
|
|
286
285
|
};
|
|
287
286
|
export type SchemaObjectWithRef = Omit<JSONSchema, "type" | "allOf" | "oneOf" | "anyOf" | "not" | "items" | "properties" | "additionalProperties"> & {
|
|
288
|
-
type?:
|
|
287
|
+
type?: SchemaType;
|
|
289
288
|
allOf?: (SchemaObject | ReferenceObject)[];
|
|
290
289
|
oneOf?: (SchemaObject | ReferenceObject)[];
|
|
291
290
|
anyOf?: (SchemaObject | ReferenceObject)[];
|
|
292
291
|
not?: SchemaObject | ReferenceObject;
|
|
293
292
|
items?: SchemaObject | ReferenceObject;
|
|
294
|
-
properties?:
|
|
293
|
+
properties?: Record<string, SchemaObject | ReferenceObject>;
|
|
295
294
|
additionalProperties?: boolean | SchemaObject | ReferenceObject;
|
|
296
295
|
nullable?: boolean;
|
|
297
296
|
discriminator?: DiscriminatorObject;
|
|
@@ -304,7 +303,7 @@ export type SchemaObjectWithRef = Omit<JSONSchema, "type" | "allOf" | "oneOf" |
|
|
|
304
303
|
};
|
|
305
304
|
export interface DiscriminatorObject {
|
|
306
305
|
propertyName: string;
|
|
307
|
-
mapping?:
|
|
306
|
+
mapping?: Record<string, string>;
|
|
308
307
|
}
|
|
309
308
|
export interface XMLObject {
|
|
310
309
|
name?: string;
|
|
@@ -348,7 +347,6 @@ export interface OAuthFlowObject {
|
|
|
348
347
|
authorizationUrl?: string;
|
|
349
348
|
tokenUrl?: string;
|
|
350
349
|
refreshUrl?: string;
|
|
351
|
-
scopes:
|
|
350
|
+
scopes: Record<string, string>;
|
|
352
351
|
}
|
|
353
|
-
export type SecurityRequirementObject =
|
|
354
|
-
export {};
|
|
352
|
+
export type SecurityRequirementObject = Record<string, string[]>;
|
|
@@ -16,7 +16,7 @@ export declare class OpenAPIParser {
|
|
|
16
16
|
/**
|
|
17
17
|
* get spec part by JsonPointer ($ref)
|
|
18
18
|
*/
|
|
19
|
-
byRef: <T extends
|
|
19
|
+
byRef: <T extends any = any>(ref: string) => T | undefined;
|
|
20
20
|
/**
|
|
21
21
|
* checks if the object is OpenAPI reference (contains $ref property)
|
|
22
22
|
*/
|
package/lib/options.js
CHANGED
|
@@ -35,6 +35,9 @@ exports.OptionsSchema = utils_validation_1.Joi.object({
|
|
|
35
35
|
proxy: utils_validation_1.Joi.string(),
|
|
36
36
|
outputDir: utils_validation_1.Joi.string().required(),
|
|
37
37
|
template: utils_validation_1.Joi.string(),
|
|
38
|
+
infoTemplate: utils_validation_1.Joi.string(),
|
|
39
|
+
tagTemplate: utils_validation_1.Joi.string(),
|
|
40
|
+
schemaTemplate: utils_validation_1.Joi.string(),
|
|
38
41
|
downloadUrl: utils_validation_1.Joi.string(),
|
|
39
42
|
hideSendButton: utils_validation_1.Joi.boolean(),
|
|
40
43
|
showExtensions: utils_validation_1.Joi.boolean(),
|
package/lib/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SidebarItemDoc } from "@docusaurus/plugin-content-docs/src/sidebars/types";
|
|
2
|
-
import type Request from "postman-collection";
|
|
3
2
|
import { InfoObject, OperationObject, SchemaObject, SecuritySchemeObject, TagObject } from "./openapi/types";
|
|
4
3
|
export type { PropSidebarItemCategory, SidebarItemLink, PropSidebar, PropSidebarItem, } from "@docusaurus/plugin-content-docs-types";
|
|
5
4
|
export interface PluginOptions {
|
|
@@ -14,6 +13,9 @@ export interface APIOptions {
|
|
|
14
13
|
specPath: string;
|
|
15
14
|
outputDir: string;
|
|
16
15
|
template?: string;
|
|
16
|
+
infoTemplate?: string;
|
|
17
|
+
tagTemplate?: string;
|
|
18
|
+
schemaTemplate?: string;
|
|
17
19
|
downloadUrl?: string;
|
|
18
20
|
hideSendButton?: boolean;
|
|
19
21
|
showExtensions?: boolean;
|
|
@@ -82,6 +84,7 @@ export interface ApiMetadataBase {
|
|
|
82
84
|
frontMatter: Record<string, unknown>;
|
|
83
85
|
method?: string;
|
|
84
86
|
path?: string;
|
|
87
|
+
position?: number;
|
|
85
88
|
}
|
|
86
89
|
export interface ApiPageMetadata extends ApiMetadataBase {
|
|
87
90
|
json?: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-plugin-openapi-docs",
|
|
3
3
|
"description": "OpenAPI plugin for Docusaurus.",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.5.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"engines": {
|
|
66
66
|
"node": ">=14"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "cb0ed6e02d7a963d51073e2bfd78d944fbb7ee34"
|
|
69
69
|
}
|