docusaurus-plugin-openapi-docs 0.0.0-1155 → 0.0.0-1156
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/lib/markdown/createSchema.js +2 -33
- package/lib/markdown/schema.d.ts +0 -1
- package/lib/markdown/schema.js +0 -105
- package/lib/markdown/utils.js +3 -1
- package/lib/openapi/utils/utils/openapi.d.ts +0 -2
- package/lib/openapi/utils/utils/openapi.js +0 -82
- package/package.json +2 -2
- package/src/markdown/__snapshots__/createSchema.test.ts.snap +0 -100
- package/src/markdown/createSchema.ts +3 -42
- package/src/markdown/schema.ts +0 -126
- package/src/markdown/utils.ts +3 -1
- package/src/openapi/utils/utils/openapi.ts +0 -110
- package/lib/markdown/schema.test.d.ts +0 -1
- package/lib/markdown/schema.test.js +0 -181
- package/src/markdown/schema.test.ts +0 -208
|
@@ -122,7 +122,6 @@ function createProperties(schema) {
|
|
|
122
122
|
name: "",
|
|
123
123
|
required: false,
|
|
124
124
|
schemaName: "object",
|
|
125
|
-
qualifierMessage: undefined,
|
|
126
125
|
schema: {},
|
|
127
126
|
});
|
|
128
127
|
}
|
|
@@ -151,7 +150,6 @@ function createAdditionalProperties(schema) {
|
|
|
151
150
|
name: "property name*",
|
|
152
151
|
required: false,
|
|
153
152
|
schemaName: "any",
|
|
154
|
-
qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
|
|
155
153
|
schema: schema,
|
|
156
154
|
collapsible: false,
|
|
157
155
|
discriminator: false,
|
|
@@ -179,7 +177,6 @@ function createAdditionalProperties(schema) {
|
|
|
179
177
|
name: "property name*",
|
|
180
178
|
required: false,
|
|
181
179
|
schemaName: schemaName,
|
|
182
|
-
qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
|
|
183
180
|
schema: additionalProperties,
|
|
184
181
|
collapsible: false,
|
|
185
182
|
discriminator: false,
|
|
@@ -336,10 +333,6 @@ function createDetailsNode(name, schemaName, schema, required, nullable) {
|
|
|
336
333
|
style: { marginTop: ".5rem", marginBottom: ".5rem" },
|
|
337
334
|
children: (0, createDescription_1.createDescription)(description),
|
|
338
335
|
})),
|
|
339
|
-
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema), (message) => (0, utils_1.create)("div", {
|
|
340
|
-
style: { marginTop: ".5rem", marginBottom: ".5rem" },
|
|
341
|
-
children: (0, createDescription_1.createDescription)(message),
|
|
342
|
-
})),
|
|
343
336
|
createNodes(schema, SCHEMA_TYPE),
|
|
344
337
|
],
|
|
345
338
|
}),
|
|
@@ -465,12 +458,6 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
465
458
|
},
|
|
466
459
|
children: (0, createDescription_1.createDescription)(description),
|
|
467
460
|
})),
|
|
468
|
-
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(discriminator), (message) => (0, utils_1.create)("div", {
|
|
469
|
-
style: {
|
|
470
|
-
paddingLeft: "1rem",
|
|
471
|
-
},
|
|
472
|
-
children: (0, createDescription_1.createDescription)(message),
|
|
473
|
-
})),
|
|
474
461
|
(0, utils_1.create)("DiscriminatorTabs", {
|
|
475
462
|
className: "openapi-tabs__discriminator",
|
|
476
463
|
children: Object.keys(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping).map((key, index) => {
|
|
@@ -554,7 +541,6 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
554
541
|
name,
|
|
555
542
|
required: Array.isArray(required) ? required.includes(name) : required,
|
|
556
543
|
schemaName: mergedSchemaName,
|
|
557
|
-
qualifierMessage: (0, schema_1.getQualifierMessage)(mergedSchemas),
|
|
558
544
|
schema: mergedSchemas,
|
|
559
545
|
});
|
|
560
546
|
}
|
|
@@ -564,7 +550,6 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
564
550
|
name,
|
|
565
551
|
required: Array.isArray(required) ? required.includes(name) : required,
|
|
566
552
|
schemaName: schemaName,
|
|
567
|
-
qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
|
|
568
553
|
schema: schema,
|
|
569
554
|
});
|
|
570
555
|
}
|
|
@@ -633,15 +618,7 @@ function createNodes(schema, schemaType) {
|
|
|
633
618
|
marginTop: ".5rem",
|
|
634
619
|
marginBottom: ".5rem",
|
|
635
620
|
},
|
|
636
|
-
children: [
|
|
637
|
-
(0, createDescription_1.createDescription)(schema.type),
|
|
638
|
-
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema), (message) => (0, utils_1.create)("div", {
|
|
639
|
-
style: {
|
|
640
|
-
paddingTop: "1rem",
|
|
641
|
-
},
|
|
642
|
-
children: (0, createDescription_1.createDescription)(message),
|
|
643
|
-
})),
|
|
644
|
-
],
|
|
621
|
+
children: [(0, createDescription_1.createDescription)(schema.type)],
|
|
645
622
|
});
|
|
646
623
|
}
|
|
647
624
|
// handle circular references
|
|
@@ -651,15 +628,7 @@ function createNodes(schema, schemaType) {
|
|
|
651
628
|
marginTop: ".5rem",
|
|
652
629
|
marginBottom: ".5rem",
|
|
653
630
|
},
|
|
654
|
-
children: [
|
|
655
|
-
(0, createDescription_1.createDescription)(schema),
|
|
656
|
-
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema), (message) => (0, utils_1.create)("div", {
|
|
657
|
-
style: {
|
|
658
|
-
paddingTop: "1rem",
|
|
659
|
-
},
|
|
660
|
-
children: (0, createDescription_1.createDescription)(message),
|
|
661
|
-
})),
|
|
662
|
-
],
|
|
631
|
+
children: [(0, createDescription_1.createDescription)(schema)],
|
|
663
632
|
});
|
|
664
633
|
}
|
|
665
634
|
// Unknown node/schema type should return undefined
|
package/lib/markdown/schema.d.ts
CHANGED
package/lib/markdown/schema.js
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* ========================================================================== */
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.getSchemaName = getSchemaName;
|
|
10
|
-
exports.getQualifierMessage = getQualifierMessage;
|
|
11
10
|
function prettyName(schema, circular) {
|
|
12
11
|
var _a, _b, _c, _d, _e;
|
|
13
12
|
// Handle enum-only schemas (valid in JSON Schema)
|
|
@@ -56,107 +55,3 @@ function getSchemaName(schema, circular) {
|
|
|
56
55
|
}
|
|
57
56
|
return (_a = prettyName(schema, circular)) !== null && _a !== void 0 ? _a : "";
|
|
58
57
|
}
|
|
59
|
-
function getQualifierMessage(schema) {
|
|
60
|
-
// TODO:
|
|
61
|
-
// - uniqueItems
|
|
62
|
-
// - maxProperties
|
|
63
|
-
// - minProperties
|
|
64
|
-
// - multipleOf
|
|
65
|
-
if (!schema) {
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
if (schema.items &&
|
|
69
|
-
schema.minItems === undefined &&
|
|
70
|
-
schema.maxItems === undefined) {
|
|
71
|
-
return getQualifierMessage(schema.items);
|
|
72
|
-
}
|
|
73
|
-
let message = "**Possible values:** ";
|
|
74
|
-
let qualifierGroups = [];
|
|
75
|
-
if (schema.items && schema.items.enum) {
|
|
76
|
-
if (schema.items.enum) {
|
|
77
|
-
qualifierGroups.push(`[${schema.items.enum.map((e) => `\`${e}\``).join(", ")}]`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (schema.minLength || schema.maxLength) {
|
|
81
|
-
let lengthQualifier = "";
|
|
82
|
-
let minLength;
|
|
83
|
-
let maxLength;
|
|
84
|
-
if (schema.minLength && schema.minLength > 1) {
|
|
85
|
-
minLength = `\`>= ${schema.minLength} characters\``;
|
|
86
|
-
}
|
|
87
|
-
if (schema.minLength && schema.minLength === 1) {
|
|
88
|
-
minLength = `\`non-empty\``;
|
|
89
|
-
}
|
|
90
|
-
if (schema.maxLength) {
|
|
91
|
-
maxLength = `\`<= ${schema.maxLength} characters\``;
|
|
92
|
-
}
|
|
93
|
-
if (minLength && !maxLength) {
|
|
94
|
-
lengthQualifier += minLength;
|
|
95
|
-
}
|
|
96
|
-
if (maxLength && !minLength) {
|
|
97
|
-
lengthQualifier += maxLength;
|
|
98
|
-
}
|
|
99
|
-
if (minLength && maxLength) {
|
|
100
|
-
lengthQualifier += `${minLength} and ${maxLength}`;
|
|
101
|
-
}
|
|
102
|
-
qualifierGroups.push(lengthQualifier);
|
|
103
|
-
}
|
|
104
|
-
if (schema.minimum != null ||
|
|
105
|
-
schema.maximum != null ||
|
|
106
|
-
typeof schema.exclusiveMinimum === "number" ||
|
|
107
|
-
typeof schema.exclusiveMaximum === "number") {
|
|
108
|
-
let minmaxQualifier = "";
|
|
109
|
-
let minimum;
|
|
110
|
-
let maximum;
|
|
111
|
-
if (typeof schema.exclusiveMinimum === "number") {
|
|
112
|
-
minimum = `\`> ${schema.exclusiveMinimum}\``;
|
|
113
|
-
}
|
|
114
|
-
else if (schema.minimum != null && !schema.exclusiveMinimum) {
|
|
115
|
-
minimum = `\`>= ${schema.minimum}\``;
|
|
116
|
-
}
|
|
117
|
-
else if (schema.minimum != null && schema.exclusiveMinimum === true) {
|
|
118
|
-
minimum = `\`> ${schema.minimum}\``;
|
|
119
|
-
}
|
|
120
|
-
if (typeof schema.exclusiveMaximum === "number") {
|
|
121
|
-
maximum = `\`< ${schema.exclusiveMaximum}\``;
|
|
122
|
-
}
|
|
123
|
-
else if (schema.maximum != null && !schema.exclusiveMaximum) {
|
|
124
|
-
maximum = `\`<= ${schema.maximum}\``;
|
|
125
|
-
}
|
|
126
|
-
else if (schema.maximum != null && schema.exclusiveMaximum === true) {
|
|
127
|
-
maximum = `\`< ${schema.maximum}\``;
|
|
128
|
-
}
|
|
129
|
-
if (minimum && !maximum) {
|
|
130
|
-
minmaxQualifier += minimum;
|
|
131
|
-
}
|
|
132
|
-
if (maximum && !minimum) {
|
|
133
|
-
minmaxQualifier += maximum;
|
|
134
|
-
}
|
|
135
|
-
if (minimum && maximum) {
|
|
136
|
-
minmaxQualifier += `${minimum} and ${maximum}`;
|
|
137
|
-
}
|
|
138
|
-
qualifierGroups.push(minmaxQualifier);
|
|
139
|
-
}
|
|
140
|
-
if (schema.pattern) {
|
|
141
|
-
qualifierGroups.push(`Value must match regular expression \`${schema.pattern}\``);
|
|
142
|
-
}
|
|
143
|
-
// Check if discriminator mapping
|
|
144
|
-
const discriminator = schema;
|
|
145
|
-
if (discriminator.mapping) {
|
|
146
|
-
const values = Object.keys(discriminator.mapping);
|
|
147
|
-
qualifierGroups.push(`[${values.map((e) => `\`${e}\``).join(", ")}]`);
|
|
148
|
-
}
|
|
149
|
-
if (schema.enum) {
|
|
150
|
-
qualifierGroups.push(`[${schema.enum.map((e) => `\`${e}\``).join(", ")}]`);
|
|
151
|
-
}
|
|
152
|
-
if (schema.minItems) {
|
|
153
|
-
qualifierGroups.push(`\`>= ${schema.minItems}\``);
|
|
154
|
-
}
|
|
155
|
-
if (schema.maxItems) {
|
|
156
|
-
qualifierGroups.push(`\`<= ${schema.maxItems}\``);
|
|
157
|
-
}
|
|
158
|
-
if (qualifierGroups.length === 0) {
|
|
159
|
-
return undefined;
|
|
160
|
-
}
|
|
161
|
-
return message + qualifierGroups.join(", ");
|
|
162
|
-
}
|
package/lib/markdown/utils.js
CHANGED
|
@@ -81,7 +81,9 @@ function create(tag, props, options = {}) {
|
|
|
81
81
|
else {
|
|
82
82
|
// Inline props as usual
|
|
83
83
|
for (const [key, value] of Object.entries(rest)) {
|
|
84
|
-
|
|
84
|
+
if (value !== undefined) {
|
|
85
|
+
propString += `\n ${key}={${JSON.stringify(value)}}`;
|
|
86
|
+
}
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
let indentedChildren = render(children).replace(/^/gm, " ");
|
|
@@ -19,8 +19,6 @@ export declare function getSerializedValue(field: any, example: any): any;
|
|
|
19
19
|
export declare function langFromMime(contentType: string): string;
|
|
20
20
|
export declare function isNamedDefinition(pointer?: string): boolean;
|
|
21
21
|
export declare function getDefinitionName(pointer?: string): string | undefined;
|
|
22
|
-
export declare function humanizeNumberRange(schema: OpenAPISchema): string | undefined;
|
|
23
|
-
export declare function humanizeConstraints(schema: OpenAPISchema): string[];
|
|
24
22
|
export declare function sortByRequired(fields: any[], order?: string[]): any[];
|
|
25
23
|
export declare function sortByField(fields: any[], param: "name" | "description" | "kind"): any[];
|
|
26
24
|
export declare function mergeParams(parser: OpenAPIParser, pathParams?: Array<Referenced<OpenAPIParameter>>, operationParams?: Array<Referenced<OpenAPIParameter>>): Array<Referenced<OpenAPIParameter>>;
|
|
@@ -22,8 +22,6 @@ exports.getSerializedValue = getSerializedValue;
|
|
|
22
22
|
exports.langFromMime = langFromMime;
|
|
23
23
|
exports.isNamedDefinition = isNamedDefinition;
|
|
24
24
|
exports.getDefinitionName = getDefinitionName;
|
|
25
|
-
exports.humanizeNumberRange = humanizeNumberRange;
|
|
26
|
-
exports.humanizeConstraints = humanizeConstraints;
|
|
27
25
|
exports.sortByRequired = sortByRequired;
|
|
28
26
|
exports.sortByField = sortByField;
|
|
29
27
|
exports.mergeParams = mergeParams;
|
|
@@ -366,86 +364,6 @@ function getDefinitionName(pointer) {
|
|
|
366
364
|
const [name] = ((_a = pointer === null || pointer === void 0 ? void 0 : pointer.match(DEFINITION_NAME_REGEX)) === null || _a === void 0 ? void 0 : _a.reverse()) || [];
|
|
367
365
|
return name;
|
|
368
366
|
}
|
|
369
|
-
function humanizeMultipleOfConstraint(multipleOf) {
|
|
370
|
-
if (multipleOf === undefined) {
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
const strigifiedMultipleOf = multipleOf.toString(10);
|
|
374
|
-
if (!/^0\.0*1$/.test(strigifiedMultipleOf)) {
|
|
375
|
-
return `multiple of ${strigifiedMultipleOf}`;
|
|
376
|
-
}
|
|
377
|
-
return `decimal places <= ${strigifiedMultipleOf.split(".")[1].length}`;
|
|
378
|
-
}
|
|
379
|
-
function humanizeRangeConstraint(description, min, max) {
|
|
380
|
-
let stringRange;
|
|
381
|
-
if (min !== undefined && max !== undefined) {
|
|
382
|
-
if (min === max) {
|
|
383
|
-
stringRange = `= ${min} ${description}`;
|
|
384
|
-
}
|
|
385
|
-
else {
|
|
386
|
-
stringRange = `[ ${min} .. ${max} ] ${description}`;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
else if (max !== undefined) {
|
|
390
|
-
stringRange = `<= ${max} ${description}`;
|
|
391
|
-
}
|
|
392
|
-
else if (min !== undefined) {
|
|
393
|
-
if (min === 1) {
|
|
394
|
-
stringRange = "non-empty";
|
|
395
|
-
}
|
|
396
|
-
else {
|
|
397
|
-
stringRange = `>= ${min} ${description}`;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
return stringRange;
|
|
401
|
-
}
|
|
402
|
-
function humanizeNumberRange(schema) {
|
|
403
|
-
var _a, _b;
|
|
404
|
-
const minimum = typeof schema.exclusiveMinimum === "number"
|
|
405
|
-
? Math.min(schema.exclusiveMinimum, (_a = schema.minimum) !== null && _a !== void 0 ? _a : Infinity)
|
|
406
|
-
: schema.minimum;
|
|
407
|
-
const maximum = typeof schema.exclusiveMaximum === "number"
|
|
408
|
-
? Math.max(schema.exclusiveMaximum, (_b = schema.maximum) !== null && _b !== void 0 ? _b : -Infinity)
|
|
409
|
-
: schema.maximum;
|
|
410
|
-
const exclusiveMinimum = typeof schema.exclusiveMinimum === "number" || schema.exclusiveMinimum;
|
|
411
|
-
const exclusiveMaximum = typeof schema.exclusiveMaximum === "number" || schema.exclusiveMaximum;
|
|
412
|
-
if (minimum !== undefined && maximum !== undefined) {
|
|
413
|
-
return `${exclusiveMinimum ? "( " : "[ "}${minimum} .. ${maximum}${exclusiveMaximum ? " )" : " ]"}`;
|
|
414
|
-
}
|
|
415
|
-
else if (maximum !== undefined) {
|
|
416
|
-
return `${exclusiveMaximum ? "< " : "<= "}${maximum}`;
|
|
417
|
-
}
|
|
418
|
-
else if (minimum !== undefined) {
|
|
419
|
-
return `${exclusiveMinimum ? "> " : ">= "}${minimum}`;
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
function humanizeConstraints(schema) {
|
|
423
|
-
const res = [];
|
|
424
|
-
const stringRange = humanizeRangeConstraint("characters", schema.minLength, schema.maxLength);
|
|
425
|
-
if (stringRange !== undefined) {
|
|
426
|
-
res.push(stringRange);
|
|
427
|
-
}
|
|
428
|
-
const arrayRange = humanizeRangeConstraint("items", schema.minItems, schema.maxItems);
|
|
429
|
-
if (arrayRange !== undefined) {
|
|
430
|
-
res.push(arrayRange);
|
|
431
|
-
}
|
|
432
|
-
const propertiesRange = humanizeRangeConstraint("properties", schema.minProperties, schema.maxProperties);
|
|
433
|
-
if (propertiesRange !== undefined) {
|
|
434
|
-
res.push(propertiesRange);
|
|
435
|
-
}
|
|
436
|
-
const multipleOfConstraint = humanizeMultipleOfConstraint(schema.multipleOf);
|
|
437
|
-
if (multipleOfConstraint !== undefined) {
|
|
438
|
-
res.push(multipleOfConstraint);
|
|
439
|
-
}
|
|
440
|
-
const numberRange = humanizeNumberRange(schema);
|
|
441
|
-
if (numberRange !== undefined) {
|
|
442
|
-
res.push(numberRange);
|
|
443
|
-
}
|
|
444
|
-
if (schema.uniqueItems) {
|
|
445
|
-
res.push("unique");
|
|
446
|
-
}
|
|
447
|
-
return res;
|
|
448
|
-
}
|
|
449
367
|
function sortByRequired(fields, order = []) {
|
|
450
368
|
const unrequiredFields = [];
|
|
451
369
|
const orderedFields = [];
|
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": "0.0.0-
|
|
4
|
+
"version": "0.0.0-1156",
|
|
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": "15f538e349ea6e12482cb5a53dea9c349fd9157e"
|
|
69
69
|
}
|