docusaurus-theme-openapi-docs 0.0.0-413 → 0.0.0-414
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/schema.js +85 -20
- package/lib-next/markdown/schema.js +88 -22
- package/package.json +3 -3
- package/src/markdown/schema.ts +86 -20
package/lib/markdown/schema.js
CHANGED
|
@@ -15,22 +15,39 @@ exports.getSchemaName = getSchemaName;
|
|
|
15
15
|
function prettyName(schema, circular) {
|
|
16
16
|
var _schema$title;
|
|
17
17
|
|
|
18
|
-
if (schema.$ref) {
|
|
19
|
-
return schema.$ref.replace("#/components/schemas/", "") + circular ? " (circular)" : "";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
18
|
if (schema.format) {
|
|
23
19
|
return schema.format;
|
|
24
20
|
}
|
|
25
21
|
|
|
26
22
|
if (schema.allOf) {
|
|
23
|
+
if (typeof schema.allOf[0] === "string") {
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
if (schema.allOf[0].includes("circular")) {
|
|
26
|
+
return schema.allOf[0];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return "object";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (schema.oneOf) {
|
|
34
|
+
return "object";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (schema.anyOf) {
|
|
27
38
|
return "object";
|
|
28
39
|
}
|
|
29
40
|
|
|
30
41
|
if (schema.type === "object") {
|
|
31
42
|
var _schema$xml$name, _schema$xml;
|
|
32
43
|
|
|
33
|
-
return (_schema$xml$name = (_schema$xml = schema.xml) === null || _schema$xml === void 0 ? void 0 : _schema$xml.name) !== null && _schema$xml$name !== void 0 ? _schema$xml$name : schema.type;
|
|
44
|
+
return (_schema$xml$name = (_schema$xml = schema.xml) === null || _schema$xml === void 0 ? void 0 : _schema$xml.name) !== null && _schema$xml$name !== void 0 ? _schema$xml$name : schema.type; // return schema.type;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (schema.type === "array") {
|
|
48
|
+
var _schema$xml$name2, _schema$xml2;
|
|
49
|
+
|
|
50
|
+
return (_schema$xml$name2 = (_schema$xml2 = schema.xml) === null || _schema$xml2 === void 0 ? void 0 : _schema$xml2.name) !== null && _schema$xml$name2 !== void 0 ? _schema$xml$name2 : schema.type; // return schema.type;
|
|
34
51
|
}
|
|
35
52
|
|
|
36
53
|
return (_schema$title = schema.title) !== null && _schema$title !== void 0 ? _schema$title : schema.type;
|
|
@@ -48,8 +65,6 @@ function getSchemaName(schema, circular) {
|
|
|
48
65
|
|
|
49
66
|
function getQualifierMessage(schema) {
|
|
50
67
|
// TODO:
|
|
51
|
-
// - maxItems
|
|
52
|
-
// - minItems
|
|
53
68
|
// - uniqueItems
|
|
54
69
|
// - maxProperties
|
|
55
70
|
// - minProperties
|
|
@@ -58,24 +73,46 @@ function getQualifierMessage(schema) {
|
|
|
58
73
|
return undefined;
|
|
59
74
|
}
|
|
60
75
|
|
|
61
|
-
if (schema.items) {
|
|
76
|
+
if (schema.items && schema.minItems === undefined && schema.maxItems === undefined) {
|
|
62
77
|
return getQualifierMessage(schema.items);
|
|
63
78
|
}
|
|
64
79
|
|
|
65
80
|
let message = "**Possible values:** ";
|
|
66
81
|
let qualifierGroups = [];
|
|
67
82
|
|
|
83
|
+
if (schema.items && schema.items.enum) {
|
|
84
|
+
if (schema.items.enum) {
|
|
85
|
+
qualifierGroups.push(`[${schema.items.enum.map(e => `\`${e}\``).join(", ")}]`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
68
89
|
if (schema.minLength || schema.maxLength) {
|
|
69
90
|
let lengthQualifier = "";
|
|
91
|
+
let minLength;
|
|
92
|
+
let maxLength;
|
|
70
93
|
|
|
71
|
-
if (schema.minLength) {
|
|
72
|
-
|
|
94
|
+
if (schema.minLength && schema.minLength > 1) {
|
|
95
|
+
minLength = `\`>= ${schema.minLength} characters\``;
|
|
73
96
|
}
|
|
74
97
|
|
|
75
|
-
|
|
98
|
+
if (schema.minLength && schema.minLength === 1) {
|
|
99
|
+
minLength = `\`non-empty\``;
|
|
100
|
+
}
|
|
76
101
|
|
|
77
102
|
if (schema.maxLength) {
|
|
78
|
-
|
|
103
|
+
maxLength = `\`<= ${schema.maxLength} characters\``;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (minLength && !maxLength) {
|
|
107
|
+
lengthQualifier += minLength;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (maxLength && !minLength) {
|
|
111
|
+
lengthQualifier += maxLength;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (minLength && maxLength) {
|
|
115
|
+
lengthQualifier += `${minLength} and ${maxLength}`;
|
|
79
116
|
}
|
|
80
117
|
|
|
81
118
|
qualifierGroups.push(lengthQualifier);
|
|
@@ -83,23 +120,35 @@ function getQualifierMessage(schema) {
|
|
|
83
120
|
|
|
84
121
|
if (schema.minimum || schema.maximum || typeof schema.exclusiveMinimum === "number" || typeof schema.exclusiveMaximum === "number") {
|
|
85
122
|
let minmaxQualifier = "";
|
|
123
|
+
let minimum;
|
|
124
|
+
let maximum;
|
|
86
125
|
|
|
87
126
|
if (typeof schema.exclusiveMinimum === "number") {
|
|
88
|
-
|
|
127
|
+
minimum = `\`> ${schema.exclusiveMinimum}\``;
|
|
89
128
|
} else if (schema.minimum && !schema.exclusiveMinimum) {
|
|
90
|
-
|
|
129
|
+
minimum = `\`>= ${schema.minimum}\``;
|
|
91
130
|
} else if (schema.minimum && schema.exclusiveMinimum === true) {
|
|
92
|
-
|
|
131
|
+
minimum = `\`> ${schema.minimum}\``;
|
|
93
132
|
}
|
|
94
133
|
|
|
95
|
-
minmaxQualifier += "value";
|
|
96
|
-
|
|
97
134
|
if (typeof schema.exclusiveMaximum === "number") {
|
|
98
|
-
|
|
135
|
+
maximum = `\`< ${schema.exclusiveMaximum}\``;
|
|
99
136
|
} else if (schema.maximum && !schema.exclusiveMaximum) {
|
|
100
|
-
|
|
137
|
+
maximum = `\`<= ${schema.maximum}\``;
|
|
101
138
|
} else if (schema.maximum && schema.exclusiveMaximum === true) {
|
|
102
|
-
|
|
139
|
+
maximum = `\`< ${schema.maximum}\``;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (minimum && !maximum) {
|
|
143
|
+
minmaxQualifier += minimum;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (maximum && !minimum) {
|
|
147
|
+
minmaxQualifier += maximum;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (minimum && maximum) {
|
|
151
|
+
minmaxQualifier += `${minimum} and ${maximum}`;
|
|
103
152
|
}
|
|
104
153
|
|
|
105
154
|
qualifierGroups.push(minmaxQualifier);
|
|
@@ -107,12 +156,28 @@ function getQualifierMessage(schema) {
|
|
|
107
156
|
|
|
108
157
|
if (schema.pattern) {
|
|
109
158
|
qualifierGroups.push(`Value must match regular expression \`${schema.pattern}\``);
|
|
159
|
+
} // Check if discriminator mapping
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
const discriminator = schema;
|
|
163
|
+
|
|
164
|
+
if (discriminator.mapping) {
|
|
165
|
+
const values = Object.keys(discriminator.mapping);
|
|
166
|
+
qualifierGroups.push(`[${values.map(e => `\`${e}\``).join(", ")}]`);
|
|
110
167
|
}
|
|
111
168
|
|
|
112
169
|
if (schema.enum) {
|
|
113
170
|
qualifierGroups.push(`[${schema.enum.map(e => `\`${e}\``).join(", ")}]`);
|
|
114
171
|
}
|
|
115
172
|
|
|
173
|
+
if (schema.minItems) {
|
|
174
|
+
qualifierGroups.push(`\`>= ${schema.minItems}\``);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (schema.maxItems) {
|
|
178
|
+
qualifierGroups.push(`\`<= ${schema.maxItems}\``);
|
|
179
|
+
}
|
|
180
|
+
|
|
116
181
|
if (qualifierGroups.length === 0) {
|
|
117
182
|
return undefined;
|
|
118
183
|
}
|
|
@@ -5,22 +5,35 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
function prettyName(schema, circular) {
|
|
8
|
-
if (schema.$ref) {
|
|
9
|
-
return schema.$ref.replace("#/components/schemas/", "") + circular
|
|
10
|
-
? " (circular)"
|
|
11
|
-
: "";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
8
|
if (schema.format) {
|
|
15
9
|
return schema.format;
|
|
16
10
|
}
|
|
17
11
|
|
|
18
12
|
if (schema.allOf) {
|
|
13
|
+
if (typeof schema.allOf[0] === "string") {
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
if (schema.allOf[0].includes("circular")) {
|
|
16
|
+
return schema.allOf[0];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return "object";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (schema.oneOf) {
|
|
24
|
+
return "object";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (schema.anyOf) {
|
|
19
28
|
return "object";
|
|
20
29
|
}
|
|
21
30
|
|
|
22
31
|
if (schema.type === "object") {
|
|
23
|
-
return schema.xml?.name ?? schema.type;
|
|
32
|
+
return schema.xml?.name ?? schema.type; // return schema.type;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (schema.type === "array") {
|
|
36
|
+
return schema.xml?.name ?? schema.type; // return schema.type;
|
|
24
37
|
}
|
|
25
38
|
|
|
26
39
|
return schema.title ?? schema.type;
|
|
@@ -35,8 +48,6 @@ export function getSchemaName(schema, circular) {
|
|
|
35
48
|
}
|
|
36
49
|
export function getQualifierMessage(schema) {
|
|
37
50
|
// TODO:
|
|
38
|
-
// - maxItems
|
|
39
|
-
// - minItems
|
|
40
51
|
// - uniqueItems
|
|
41
52
|
// - maxProperties
|
|
42
53
|
// - minProperties
|
|
@@ -45,24 +56,52 @@ export function getQualifierMessage(schema) {
|
|
|
45
56
|
return undefined;
|
|
46
57
|
}
|
|
47
58
|
|
|
48
|
-
if (
|
|
59
|
+
if (
|
|
60
|
+
schema.items &&
|
|
61
|
+
schema.minItems === undefined &&
|
|
62
|
+
schema.maxItems === undefined
|
|
63
|
+
) {
|
|
49
64
|
return getQualifierMessage(schema.items);
|
|
50
65
|
}
|
|
51
66
|
|
|
52
67
|
let message = "**Possible values:** ";
|
|
53
68
|
let qualifierGroups = [];
|
|
54
69
|
|
|
70
|
+
if (schema.items && schema.items.enum) {
|
|
71
|
+
if (schema.items.enum) {
|
|
72
|
+
qualifierGroups.push(
|
|
73
|
+
`[${schema.items.enum.map((e) => `\`${e}\``).join(", ")}]`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
55
78
|
if (schema.minLength || schema.maxLength) {
|
|
56
79
|
let lengthQualifier = "";
|
|
80
|
+
let minLength;
|
|
81
|
+
let maxLength;
|
|
57
82
|
|
|
58
|
-
if (schema.minLength) {
|
|
59
|
-
|
|
83
|
+
if (schema.minLength && schema.minLength > 1) {
|
|
84
|
+
minLength = `\`>= ${schema.minLength} characters\``;
|
|
60
85
|
}
|
|
61
86
|
|
|
62
|
-
|
|
87
|
+
if (schema.minLength && schema.minLength === 1) {
|
|
88
|
+
minLength = `\`non-empty\``;
|
|
89
|
+
}
|
|
63
90
|
|
|
64
91
|
if (schema.maxLength) {
|
|
65
|
-
|
|
92
|
+
maxLength = `\`<= ${schema.maxLength} characters\``;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (minLength && !maxLength) {
|
|
96
|
+
lengthQualifier += minLength;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (maxLength && !minLength) {
|
|
100
|
+
lengthQualifier += maxLength;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (minLength && maxLength) {
|
|
104
|
+
lengthQualifier += `${minLength} and ${maxLength}`;
|
|
66
105
|
}
|
|
67
106
|
|
|
68
107
|
qualifierGroups.push(lengthQualifier);
|
|
@@ -75,23 +114,35 @@ export function getQualifierMessage(schema) {
|
|
|
75
114
|
typeof schema.exclusiveMaximum === "number"
|
|
76
115
|
) {
|
|
77
116
|
let minmaxQualifier = "";
|
|
117
|
+
let minimum;
|
|
118
|
+
let maximum;
|
|
78
119
|
|
|
79
120
|
if (typeof schema.exclusiveMinimum === "number") {
|
|
80
|
-
|
|
121
|
+
minimum = `\`> ${schema.exclusiveMinimum}\``;
|
|
81
122
|
} else if (schema.minimum && !schema.exclusiveMinimum) {
|
|
82
|
-
|
|
123
|
+
minimum = `\`>= ${schema.minimum}\``;
|
|
83
124
|
} else if (schema.minimum && schema.exclusiveMinimum === true) {
|
|
84
|
-
|
|
125
|
+
minimum = `\`> ${schema.minimum}\``;
|
|
85
126
|
}
|
|
86
127
|
|
|
87
|
-
minmaxQualifier += "value";
|
|
88
|
-
|
|
89
128
|
if (typeof schema.exclusiveMaximum === "number") {
|
|
90
|
-
|
|
129
|
+
maximum = `\`< ${schema.exclusiveMaximum}\``;
|
|
91
130
|
} else if (schema.maximum && !schema.exclusiveMaximum) {
|
|
92
|
-
|
|
131
|
+
maximum = `\`<= ${schema.maximum}\``;
|
|
93
132
|
} else if (schema.maximum && schema.exclusiveMaximum === true) {
|
|
94
|
-
|
|
133
|
+
maximum = `\`< ${schema.maximum}\``;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (minimum && !maximum) {
|
|
137
|
+
minmaxQualifier += minimum;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (maximum && !minimum) {
|
|
141
|
+
minmaxQualifier += maximum;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (minimum && maximum) {
|
|
145
|
+
minmaxQualifier += `${minimum} and ${maximum}`;
|
|
95
146
|
}
|
|
96
147
|
|
|
97
148
|
qualifierGroups.push(minmaxQualifier);
|
|
@@ -101,12 +152,27 @@ export function getQualifierMessage(schema) {
|
|
|
101
152
|
qualifierGroups.push(
|
|
102
153
|
`Value must match regular expression \`${schema.pattern}\``
|
|
103
154
|
);
|
|
155
|
+
} // Check if discriminator mapping
|
|
156
|
+
|
|
157
|
+
const discriminator = schema;
|
|
158
|
+
|
|
159
|
+
if (discriminator.mapping) {
|
|
160
|
+
const values = Object.keys(discriminator.mapping);
|
|
161
|
+
qualifierGroups.push(`[${values.map((e) => `\`${e}\``).join(", ")}]`);
|
|
104
162
|
}
|
|
105
163
|
|
|
106
164
|
if (schema.enum) {
|
|
107
165
|
qualifierGroups.push(`[${schema.enum.map((e) => `\`${e}\``).join(", ")}]`);
|
|
108
166
|
}
|
|
109
167
|
|
|
168
|
+
if (schema.minItems) {
|
|
169
|
+
qualifierGroups.push(`\`>= ${schema.minItems}\``);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (schema.maxItems) {
|
|
173
|
+
qualifierGroups.push(`\`<= ${schema.maxItems}\``);
|
|
174
|
+
}
|
|
175
|
+
|
|
110
176
|
if (qualifierGroups.length === 0) {
|
|
111
177
|
return undefined;
|
|
112
178
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-theme-openapi-docs",
|
|
3
3
|
"description": "OpenAPI theme for Docusaurus.",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-414",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"buffer": "^6.0.3",
|
|
51
51
|
"clsx": "^1.1.1",
|
|
52
52
|
"crypto-js": "^4.1.1",
|
|
53
|
-
"docusaurus-plugin-openapi-docs": "0.0.0-
|
|
53
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-414",
|
|
54
54
|
"immer": "^9.0.7",
|
|
55
55
|
"lodash": "^4.17.20",
|
|
56
56
|
"process": "^0.11.10",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"engines": {
|
|
69
69
|
"node": ">=14"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "8fdb1f50296e3026908f23bae76981102753b649"
|
|
72
72
|
}
|
package/src/markdown/schema.ts
CHANGED
|
@@ -8,22 +8,36 @@
|
|
|
8
8
|
import { SchemaObject } from "../types";
|
|
9
9
|
|
|
10
10
|
function prettyName(schema: SchemaObject, circular?: boolean) {
|
|
11
|
-
if (schema.$ref) {
|
|
12
|
-
return schema.$ref.replace("#/components/schemas/", "") + circular
|
|
13
|
-
? " (circular)"
|
|
14
|
-
: "";
|
|
15
|
-
}
|
|
16
|
-
|
|
17
11
|
if (schema.format) {
|
|
18
12
|
return schema.format;
|
|
19
13
|
}
|
|
20
14
|
|
|
21
15
|
if (schema.allOf) {
|
|
16
|
+
if (typeof schema.allOf[0] === "string") {
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
if (schema.allOf[0].includes("circular")) {
|
|
19
|
+
return schema.allOf[0];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return "object";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (schema.oneOf) {
|
|
26
|
+
return "object";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (schema.anyOf) {
|
|
22
30
|
return "object";
|
|
23
31
|
}
|
|
24
32
|
|
|
25
33
|
if (schema.type === "object") {
|
|
26
34
|
return schema.xml?.name ?? schema.type;
|
|
35
|
+
// return schema.type;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (schema.type === "array") {
|
|
39
|
+
return schema.xml?.name ?? schema.type;
|
|
40
|
+
// return schema.type;
|
|
27
41
|
}
|
|
28
42
|
|
|
29
43
|
return schema.title ?? schema.type;
|
|
@@ -42,8 +56,6 @@ export function getSchemaName(
|
|
|
42
56
|
|
|
43
57
|
export function getQualifierMessage(schema?: SchemaObject): string | undefined {
|
|
44
58
|
// TODO:
|
|
45
|
-
// - maxItems
|
|
46
|
-
// - minItems
|
|
47
59
|
// - uniqueItems
|
|
48
60
|
// - maxProperties
|
|
49
61
|
// - minProperties
|
|
@@ -52,7 +64,11 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
|
|
|
52
64
|
return undefined;
|
|
53
65
|
}
|
|
54
66
|
|
|
55
|
-
if (
|
|
67
|
+
if (
|
|
68
|
+
schema.items &&
|
|
69
|
+
schema.minItems === undefined &&
|
|
70
|
+
schema.maxItems === undefined
|
|
71
|
+
) {
|
|
56
72
|
return getQualifierMessage(schema.items);
|
|
57
73
|
}
|
|
58
74
|
|
|
@@ -60,15 +76,38 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
|
|
|
60
76
|
|
|
61
77
|
let qualifierGroups = [];
|
|
62
78
|
|
|
79
|
+
if (schema.items && schema.items.enum) {
|
|
80
|
+
if (schema.items.enum) {
|
|
81
|
+
qualifierGroups.push(
|
|
82
|
+
`[${schema.items.enum.map((e) => `\`${e}\``).join(", ")}]`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
63
87
|
if (schema.minLength || schema.maxLength) {
|
|
64
88
|
let lengthQualifier = "";
|
|
65
|
-
|
|
66
|
-
|
|
89
|
+
let minLength;
|
|
90
|
+
let maxLength;
|
|
91
|
+
if (schema.minLength && schema.minLength > 1) {
|
|
92
|
+
minLength = `\`>= ${schema.minLength} characters\``;
|
|
93
|
+
}
|
|
94
|
+
if (schema.minLength && schema.minLength === 1) {
|
|
95
|
+
minLength = `\`non-empty\``;
|
|
67
96
|
}
|
|
68
|
-
lengthQualifier += "length";
|
|
69
97
|
if (schema.maxLength) {
|
|
70
|
-
|
|
98
|
+
maxLength = `\`<= ${schema.maxLength} characters\``;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (minLength && !maxLength) {
|
|
102
|
+
lengthQualifier += minLength;
|
|
103
|
+
}
|
|
104
|
+
if (maxLength && !minLength) {
|
|
105
|
+
lengthQualifier += maxLength;
|
|
106
|
+
}
|
|
107
|
+
if (minLength && maxLength) {
|
|
108
|
+
lengthQualifier += `${minLength} and ${maxLength}`;
|
|
71
109
|
}
|
|
110
|
+
|
|
72
111
|
qualifierGroups.push(lengthQualifier);
|
|
73
112
|
}
|
|
74
113
|
|
|
@@ -79,21 +118,33 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
|
|
|
79
118
|
typeof schema.exclusiveMaximum === "number"
|
|
80
119
|
) {
|
|
81
120
|
let minmaxQualifier = "";
|
|
121
|
+
let minimum;
|
|
122
|
+
let maximum;
|
|
82
123
|
if (typeof schema.exclusiveMinimum === "number") {
|
|
83
|
-
|
|
124
|
+
minimum = `\`> ${schema.exclusiveMinimum}\``;
|
|
84
125
|
} else if (schema.minimum && !schema.exclusiveMinimum) {
|
|
85
|
-
|
|
126
|
+
minimum = `\`>= ${schema.minimum}\``;
|
|
86
127
|
} else if (schema.minimum && schema.exclusiveMinimum === true) {
|
|
87
|
-
|
|
128
|
+
minimum = `\`> ${schema.minimum}\``;
|
|
88
129
|
}
|
|
89
|
-
minmaxQualifier += "value";
|
|
90
130
|
if (typeof schema.exclusiveMaximum === "number") {
|
|
91
|
-
|
|
131
|
+
maximum = `\`< ${schema.exclusiveMaximum}\``;
|
|
92
132
|
} else if (schema.maximum && !schema.exclusiveMaximum) {
|
|
93
|
-
|
|
133
|
+
maximum = `\`<= ${schema.maximum}\``;
|
|
94
134
|
} else if (schema.maximum && schema.exclusiveMaximum === true) {
|
|
95
|
-
|
|
135
|
+
maximum = `\`< ${schema.maximum}\``;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (minimum && !maximum) {
|
|
139
|
+
minmaxQualifier += minimum;
|
|
140
|
+
}
|
|
141
|
+
if (maximum && !minimum) {
|
|
142
|
+
minmaxQualifier += maximum;
|
|
96
143
|
}
|
|
144
|
+
if (minimum && maximum) {
|
|
145
|
+
minmaxQualifier += `${minimum} and ${maximum}`;
|
|
146
|
+
}
|
|
147
|
+
|
|
97
148
|
qualifierGroups.push(minmaxQualifier);
|
|
98
149
|
}
|
|
99
150
|
|
|
@@ -103,10 +154,25 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
|
|
|
103
154
|
);
|
|
104
155
|
}
|
|
105
156
|
|
|
157
|
+
// Check if discriminator mapping
|
|
158
|
+
const discriminator = schema as any;
|
|
159
|
+
if (discriminator.mapping) {
|
|
160
|
+
const values = Object.keys(discriminator.mapping);
|
|
161
|
+
qualifierGroups.push(`[${values.map((e) => `\`${e}\``).join(", ")}]`);
|
|
162
|
+
}
|
|
163
|
+
|
|
106
164
|
if (schema.enum) {
|
|
107
165
|
qualifierGroups.push(`[${schema.enum.map((e) => `\`${e}\``).join(", ")}]`);
|
|
108
166
|
}
|
|
109
167
|
|
|
168
|
+
if (schema.minItems) {
|
|
169
|
+
qualifierGroups.push(`\`>= ${schema.minItems}\``);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (schema.maxItems) {
|
|
173
|
+
qualifierGroups.push(`\`<= ${schema.maxItems}\``);
|
|
174
|
+
}
|
|
175
|
+
|
|
110
176
|
if (qualifierGroups.length === 0) {
|
|
111
177
|
return undefined;
|
|
112
178
|
}
|