docusaurus-plugin-openapi-docs 1.1.2 → 1.1.3

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 CHANGED
@@ -246,7 +246,7 @@ yarn docusaurus gen-api-docs:version petstore:all
246
246
  Run the following to bootstrap a Docsaurus v2 site (classic theme) with `docusaurus-openapi-docs`:
247
247
 
248
248
  ```bash
249
- npx create-docusaurus@2.0.0-rc.1 my-website --package-manager yarn
249
+ npx create-docusaurus@2.0.1 my-website --package-manager yarn
250
250
  ```
251
251
 
252
252
  > When prompted to select a template choose `Git repository`.
@@ -0,0 +1,2 @@
1
+ import { LogoObject } from "../openapi/types";
2
+ export declare function createLogo(logo: LogoObject | undefined, darkLogo: LogoObject | undefined): string;
@@ -0,0 +1,19 @@
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.createLogo = void 0;
10
+ const utils_1 = require("./utils");
11
+ function createLogo(logo, darkLogo) {
12
+ return (0, utils_1.guard)(logo || darkLogo, () => [
13
+ (0, utils_1.create)("ApiLogo", {
14
+ logo: logo,
15
+ darkLogo: darkLogo,
16
+ }),
17
+ ]);
18
+ }
19
+ exports.createLogo = createLogo;
@@ -86,12 +86,14 @@ function createAnyOneOf(schema) {
86
86
  });
87
87
  }
88
88
  function createProperties(schema) {
89
+ const discriminator = schema.discriminator;
89
90
  return Object.entries(schema.properties).map(([key, val]) => createEdges({
90
91
  name: key,
91
92
  schema: val,
92
93
  required: Array.isArray(schema.required)
93
94
  ? schema.required.includes(key)
94
95
  : false,
96
+ discriminator,
95
97
  }));
96
98
  }
97
99
  function createAdditionalProperties(schema) {
@@ -228,6 +230,93 @@ function createItems(schema) {
228
230
  : false,
229
231
  }));
230
232
  }
233
+ /**
234
+ * For handling discriminators that do not map to a same-level property
235
+ */
236
+ function createDiscriminator(schema) {
237
+ var _a;
238
+ const discriminator = schema.discriminator;
239
+ const propertyName = discriminator === null || discriminator === void 0 ? void 0 : discriminator.propertyName;
240
+ const propertyType = "string"; // should always be string
241
+ const mapping = discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping;
242
+ // Explicit mapping is required since we can't support implicit
243
+ if (mapping === undefined) {
244
+ return undefined;
245
+ }
246
+ // Attempt to get the property description we want to display
247
+ // TODO: how to make it predictable when handling allOf
248
+ let propertyDescription;
249
+ const firstMappingSchema = mapping[Object.keys(mapping)[0]];
250
+ if (firstMappingSchema.properties !== undefined) {
251
+ propertyDescription =
252
+ firstMappingSchema.properties[propertyName].description;
253
+ }
254
+ if (firstMappingSchema.allOf !== undefined) {
255
+ const { mergedSchemas } = mergeAllOf(firstMappingSchema.allOf);
256
+ if (mergedSchemas.properties !== undefined) {
257
+ propertyDescription =
258
+ (_a = mergedSchemas.properties[propertyName]) === null || _a === void 0 ? void 0 : _a.description;
259
+ }
260
+ }
261
+ if (propertyDescription === undefined) {
262
+ if (schema.properties !== undefined &&
263
+ schema.properties[propertyName] !== undefined) {
264
+ propertyDescription = schema.properties[propertyName].description;
265
+ }
266
+ }
267
+ return (0, utils_1.create)("div", {
268
+ className: "discriminatorItem",
269
+ children: (0, utils_1.create)("div", {
270
+ children: [
271
+ (0, utils_1.create)("strong", {
272
+ style: { paddingLeft: "1rem" },
273
+ children: propertyName,
274
+ }),
275
+ (0, utils_1.guard)(propertyType, (name) => (0, utils_1.create)("span", {
276
+ style: { opacity: "0.6" },
277
+ children: ` ${propertyType}`,
278
+ })),
279
+ (0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema.discriminator), (message) => (0, utils_1.create)("div", {
280
+ style: {
281
+ paddingLeft: "1rem",
282
+ },
283
+ children: (0, createDescription_1.createDescription)(message),
284
+ })),
285
+ (0, utils_1.guard)(propertyDescription, (description) => (0, utils_1.create)("div", {
286
+ style: {
287
+ paddingLeft: "1rem",
288
+ },
289
+ children: (0, createDescription_1.createDescription)(description),
290
+ })),
291
+ (0, utils_1.create)("DiscriminatorTabs", {
292
+ children: Object.keys(mapping).map((key, index) => {
293
+ if (mapping[key].allOf !== undefined) {
294
+ const { mergedSchemas } = mergeAllOf(mapping[key].allOf);
295
+ // Cleanup duplicate property from mapping schema
296
+ delete mergedSchemas.properties[propertyName];
297
+ mapping[key] = mergedSchemas;
298
+ }
299
+ if (mapping[key].properties !== undefined) {
300
+ // Cleanup duplicate property from mapping schema
301
+ delete mapping[key].properties[propertyName];
302
+ }
303
+ const label = key;
304
+ return (0, utils_1.create)("TabItem", {
305
+ label: label,
306
+ value: `${index}-item-discriminator`,
307
+ children: [
308
+ (0, utils_1.create)("div", {
309
+ style: { marginLeft: "-4px" },
310
+ children: createNodes(mapping[key]),
311
+ }),
312
+ ],
313
+ });
314
+ }),
315
+ }),
316
+ ],
317
+ }),
318
+ });
319
+ }
231
320
  function createDetailsNode(name, schemaName, schema, required) {
232
321
  return (0, utils_1.create)("SchemaItem", {
233
322
  collapsible: true,
@@ -272,12 +361,75 @@ function createDetailsNode(name, schemaName, schema, required) {
272
361
  ],
273
362
  });
274
363
  }
364
+ /**
365
+ * For handling discriminators that map to a same-level property (like 'petType').
366
+ * Note: These should only be encountered while iterating through properties.
367
+ */
368
+ function createPropertyDiscriminator(name, schemaName, schema, discriminator, required) {
369
+ if (schema === undefined) {
370
+ return undefined;
371
+ }
372
+ if (discriminator.mapping === undefined) {
373
+ return undefined;
374
+ }
375
+ return (0, utils_1.create)("div", {
376
+ className: "discriminatorItem",
377
+ children: (0, utils_1.create)("div", {
378
+ children: [
379
+ (0, utils_1.create)("strong", { style: { paddingLeft: "1rem" }, children: name }),
380
+ (0, utils_1.guard)(schemaName, (name) => (0, utils_1.create)("span", {
381
+ style: { opacity: "0.6" },
382
+ children: ` ${schemaName}`,
383
+ })),
384
+ (0, utils_1.guard)(required, () => [
385
+ (0, utils_1.create)("strong", {
386
+ style: {
387
+ fontSize: "var(--ifm-code-font-size)",
388
+ color: "var(--openapi-required)",
389
+ },
390
+ children: " required",
391
+ }),
392
+ ]),
393
+ (0, utils_1.guard)((0, schema_1.getQualifierMessage)(discriminator), (message) => (0, utils_1.create)("div", {
394
+ style: {
395
+ paddingLeft: "1rem",
396
+ },
397
+ children: (0, createDescription_1.createDescription)(message),
398
+ })),
399
+ (0, utils_1.guard)(schema.description, (description) => (0, utils_1.create)("div", {
400
+ style: {
401
+ paddingLeft: "1rem",
402
+ },
403
+ children: (0, createDescription_1.createDescription)(description),
404
+ })),
405
+ (0, utils_1.create)("DiscriminatorTabs", {
406
+ children: Object.keys(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping).map((key, index) => {
407
+ const label = key;
408
+ return (0, utils_1.create)("TabItem", {
409
+ label: label,
410
+ value: `${index}-item-discriminator`,
411
+ children: [
412
+ (0, utils_1.create)("div", {
413
+ style: { marginLeft: "-4px" },
414
+ children: createNodes(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping[key]),
415
+ }),
416
+ ],
417
+ });
418
+ }),
419
+ }),
420
+ ],
421
+ }),
422
+ });
423
+ }
275
424
  /**
276
425
  * Creates the edges or "leaves" of a schema tree. Edges can branch into sub-nodes with createDetails().
277
426
  */
278
- function createEdges({ name, schema, required }) {
427
+ function createEdges({ name, schema, required, discriminator, }) {
279
428
  var _a;
280
429
  const schemaName = (0, schema_1.getSchemaName)(schema);
430
+ if (discriminator !== undefined && discriminator.propertyName === name) {
431
+ return createPropertyDiscriminator(name, "string", schema, discriminator, required);
432
+ }
281
433
  if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
282
434
  return createDetailsNode(name, schemaName, schema, required);
283
435
  }
@@ -327,6 +479,9 @@ function createEdges({ name, schema, required }) {
327
479
  * Creates a hierarchical level of a schema tree. Nodes produce edges that can branch into sub-nodes with edges, recursively.
328
480
  */
329
481
  function createNodes(schema) {
482
+ if (schema.discriminator !== undefined) {
483
+ return createDiscriminator(schema);
484
+ }
330
485
  if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
331
486
  return createAnyOneOf(schema);
332
487
  }
@@ -8,8 +8,66 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.createStatusCodes = void 0;
10
10
  const createDescription_1 = require("./createDescription");
11
+ const createDetails_1 = require("./createDetails");
12
+ const createDetailsSummary_1 = require("./createDetailsSummary");
11
13
  const createSchemaDetails_1 = require("./createSchemaDetails");
12
14
  const utils_1 = require("./utils");
15
+ const utils_2 = require("./utils");
16
+ function createResponseHeaders(responseHeaders) {
17
+ return (0, utils_2.guard)(responseHeaders, () => (0, utils_1.create)("ul", {
18
+ style: { marginLeft: "1rem" },
19
+ children: [
20
+ Object.entries(responseHeaders).map(([headerName, headerObj]) => {
21
+ const { description, schema: { type }, example, } = headerObj;
22
+ return (0, utils_1.create)("li", {
23
+ class: "schemaItem",
24
+ children: [
25
+ (0, createDetailsSummary_1.createDetailsSummary)({
26
+ children: [
27
+ (0, utils_1.create)("strong", { children: headerName }),
28
+ (0, utils_2.guard)(type, () => [
29
+ (0, utils_1.create)("span", {
30
+ style: { opacity: "0.6" },
31
+ children: ` ${type}`,
32
+ }),
33
+ ]),
34
+ ],
35
+ }),
36
+ (0, utils_1.create)("div", {
37
+ children: [
38
+ (0, utils_2.guard)(description, (description) => (0, utils_1.create)("div", {
39
+ style: {
40
+ marginTop: ".5rem",
41
+ marginBottom: ".5rem",
42
+ },
43
+ children: [
44
+ (0, utils_2.guard)(example, () => `Example: ${example}`),
45
+ (0, createDescription_1.createDescription)(description),
46
+ ],
47
+ })),
48
+ ],
49
+ }),
50
+ ],
51
+ });
52
+ }),
53
+ ],
54
+ }));
55
+ }
56
+ function createResponseExamples(responseExamples) {
57
+ return Object.entries(responseExamples).map(([exampleName, exampleValue]) => {
58
+ const camelToSpaceName = exampleName.replace(/([A-Z])/g, " $1");
59
+ let finalFormattedName = camelToSpaceName.charAt(0).toUpperCase() + camelToSpaceName.slice(1);
60
+ return (0, utils_1.create)("TabItem", {
61
+ label: `${finalFormattedName}`,
62
+ value: `${finalFormattedName}`,
63
+ children: [
64
+ (0, utils_1.create)("ResponseSamples", {
65
+ responseExample: JSON.stringify(exampleValue.value, null, 2),
66
+ }),
67
+ ],
68
+ });
69
+ });
70
+ }
13
71
  function createStatusCodes({ responses }) {
14
72
  if (responses === undefined) {
15
73
  return undefined;
@@ -22,6 +80,10 @@ function createStatusCodes({ responses }) {
22
80
  children: [
23
81
  (0, utils_1.create)("ApiTabs", {
24
82
  children: codes.map((code) => {
83
+ const responseHeaders = responses[code].headers;
84
+ const responseContent = responses[code].content;
85
+ const responseContentKey = responseContent && Object.keys(responseContent)[0];
86
+ const responseExamples = responseContentKey && responseContent[responseContentKey].examples;
25
87
  return (0, utils_1.create)("TabItem", {
26
88
  label: code,
27
89
  value: code,
@@ -29,14 +91,62 @@ function createStatusCodes({ responses }) {
29
91
  (0, utils_1.create)("div", {
30
92
  children: (0, createDescription_1.createDescription)(responses[code].description),
31
93
  }),
32
- (0, utils_1.create)("div", {
94
+ (0, utils_2.guard)(responseExamples, () => (0, utils_1.create)("SchemaTabs", {
95
+ children: [
96
+ (0, utils_1.create)("TabTtem", {
97
+ label: "Schema",
98
+ value: "Schema",
99
+ children: [
100
+ responseHeaders &&
101
+ (0, createDetails_1.createDetails)({
102
+ "data-collaposed": false,
103
+ open: true,
104
+ style: { textAlign: "left" },
105
+ children: [
106
+ (0, createDetailsSummary_1.createDetailsSummary)({
107
+ children: [
108
+ (0, utils_1.create)("strong", {
109
+ children: "Response Headers",
110
+ }),
111
+ ],
112
+ }),
113
+ createResponseHeaders(responseHeaders),
114
+ ],
115
+ }),
116
+ (0, utils_1.create)("div", {
117
+ children: (0, createSchemaDetails_1.createSchemaDetails)({
118
+ title: "Schema",
119
+ body: {
120
+ content: responses[code].content,
121
+ },
122
+ }),
123
+ }),
124
+ ],
125
+ }),
126
+ createResponseExamples(responseExamples),
127
+ ],
128
+ })),
129
+ (0, utils_2.guard)(responseHeaders, () => (0, createDetails_1.createDetails)({
130
+ "data-collaposed": false,
131
+ open: true,
132
+ style: { textAlign: "left" },
133
+ children: [
134
+ (0, createDetailsSummary_1.createDetailsSummary)({
135
+ children: [
136
+ (0, utils_1.create)("strong", { children: "Response Headers" }),
137
+ ],
138
+ }),
139
+ createResponseHeaders(responseHeaders),
140
+ ],
141
+ })),
142
+ (0, utils_2.guard)(!responseExamples, () => (0, utils_1.create)("div", {
33
143
  children: (0, createSchemaDetails_1.createSchemaDetails)({
34
144
  title: "Schema",
35
145
  body: {
36
146
  content: responses[code].content,
37
147
  },
38
148
  }),
39
- }),
149
+ })),
40
150
  ],
41
151
  });
42
152
  }),
@@ -1,4 +1,4 @@
1
1
  import { ApiPageMetadata, InfoPageMetadata, TagPageMetadata } from "../types";
2
2
  export declare function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, parameters, requestBody, responses, }, }: ApiPageMetadata): string;
3
- export declare function createInfoPageMD({ info: { title, version, description, contact, license, termsOfService }, securitySchemes, }: InfoPageMetadata): string;
3
+ export declare function createInfoPageMD({ info: { title, version, description, contact, license, termsOfService, logo, darkLogo, }, securitySchemes, }: InfoPageMetadata): string;
4
4
  export declare function createTagPageMD({ tag: { description } }: TagPageMetadata): string;
@@ -13,6 +13,7 @@ const createContactInfo_1 = require("./createContactInfo");
13
13
  const createDeprecationNotice_1 = require("./createDeprecationNotice");
14
14
  const createDescription_1 = require("./createDescription");
15
15
  const createLicense_1 = require("./createLicense");
16
+ const createLogo_1 = require("./createLogo");
16
17
  const createParamsDetails_1 = require("./createParamsDetails");
17
18
  const createRequestBodyDetails_1 = require("./createRequestBodyDetails");
18
19
  const createStatusCodes_1 = require("./createStatusCodes");
@@ -21,10 +22,12 @@ const createVersionBadge_1 = require("./createVersionBadge");
21
22
  const utils_1 = require("./utils");
22
23
  function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, parameters, requestBody, responses, }, }) {
23
24
  return (0, utils_1.render)([
25
+ `import ApiTabs from "@theme/ApiTabs";\n`,
24
26
  `import ParamsItem from "@theme/ParamsItem";\n`,
27
+ `import ResponseSamples from "@theme/ResponseSamples";\n`,
25
28
  `import SchemaItem from "@theme/SchemaItem"\n`,
26
- `import ApiTabs from "@theme/ApiTabs";\n`,
27
29
  `import SchemaTabs from "@theme/SchemaTabs";\n`,
30
+ `import DiscriminatorTabs from "@theme/DiscriminatorTabs";\n`,
28
31
  `import TabItem from "@theme/TabItem";\n\n`,
29
32
  `## ${(0, lodash_1.escape)(title)}\n\n`,
30
33
  (0, createDeprecationNotice_1.createDeprecationNotice)({ deprecated, description: deprecatedDescription }),
@@ -38,12 +41,14 @@ function createApiPageMD({ title, api: { deprecated, "x-deprecated-description":
38
41
  ]);
39
42
  }
40
43
  exports.createApiPageMD = createApiPageMD;
41
- function createInfoPageMD({ info: { title, version, description, contact, license, termsOfService }, securitySchemes, }) {
44
+ function createInfoPageMD({ info: { title, version, description, contact, license, termsOfService, logo, darkLogo, }, securitySchemes, }) {
42
45
  return (0, utils_1.render)([
46
+ `import ApiLogo from "@theme/ApiLogo";\n`,
43
47
  `import Tabs from "@theme/Tabs";\n`,
44
48
  `import TabItem from "@theme/TabItem";\n\n`,
45
49
  (0, createVersionBadge_1.createVersionBadge)(version),
46
50
  `# ${(0, lodash_1.escape)(title)}\n\n`,
51
+ (0, createLogo_1.createLogo)(logo, darkLogo),
47
52
  (0, createDescription_1.createDescription)(description),
48
53
  (0, createAuthentication_1.createAuthentication)(securitySchemes),
49
54
  (0, createContactInfo_1.createContactInfo)(contact),
@@ -54,19 +54,39 @@ function getQualifierMessage(schema) {
54
54
  if (!schema) {
55
55
  return undefined;
56
56
  }
57
- if (schema.items) {
57
+ if (schema.items &&
58
+ schema.minItems === undefined &&
59
+ schema.maxItems === undefined) {
58
60
  return getQualifierMessage(schema.items);
59
61
  }
60
62
  let message = "**Possible values:** ";
61
63
  let qualifierGroups = [];
64
+ if (schema.items && schema.items.enum) {
65
+ if (schema.items.enum) {
66
+ qualifierGroups.push(`[${schema.items.enum.map((e) => `\`${e}\``).join(", ")}]`);
67
+ }
68
+ }
62
69
  if (schema.minLength || schema.maxLength) {
63
70
  let lengthQualifier = "";
64
- if (schema.minLength) {
65
- lengthQualifier += `${schema.minLength} ≤ `;
71
+ let minLength;
72
+ let maxLength;
73
+ if (schema.minLength && schema.minLength > 1) {
74
+ minLength = `\`>= ${schema.minLength} characters\``;
75
+ }
76
+ if (schema.minLength && schema.minLength === 1) {
77
+ minLength = `\`non-empty\``;
66
78
  }
67
- lengthQualifier += "length";
68
79
  if (schema.maxLength) {
69
- lengthQualifier += ` ${schema.maxLength}`;
80
+ maxLength = `\`<= ${schema.maxLength} characters\``;
81
+ }
82
+ if (minLength && !maxLength) {
83
+ lengthQualifier += minLength;
84
+ }
85
+ if (maxLength && !minLength) {
86
+ lengthQualifier += maxLength;
87
+ }
88
+ if (minLength && maxLength) {
89
+ lengthQualifier += `${minLength} and ${maxLength}`;
70
90
  }
71
91
  qualifierGroups.push(lengthQualifier);
72
92
  }
@@ -75,38 +95,54 @@ function getQualifierMessage(schema) {
75
95
  typeof schema.exclusiveMinimum === "number" ||
76
96
  typeof schema.exclusiveMaximum === "number") {
77
97
  let minmaxQualifier = "";
98
+ let minimum;
99
+ let maximum;
78
100
  if (typeof schema.exclusiveMinimum === "number") {
79
- minmaxQualifier += `${schema.exclusiveMinimum} < `;
101
+ minimum = `\`> ${schema.exclusiveMinimum}\``;
80
102
  }
81
103
  else if (schema.minimum && !schema.exclusiveMinimum) {
82
- minmaxQualifier += `${schema.minimum} ≤ `;
104
+ minimum = `\`>= ${schema.minimum}\``;
83
105
  }
84
106
  else if (schema.minimum && schema.exclusiveMinimum === true) {
85
- minmaxQualifier += `${schema.minimum} < `;
107
+ minimum = `\`> ${schema.minimum}\``;
86
108
  }
87
- minmaxQualifier += "value";
88
109
  if (typeof schema.exclusiveMaximum === "number") {
89
- minmaxQualifier += ` < ${schema.exclusiveMaximum}`;
110
+ maximum = `\`< ${schema.exclusiveMaximum}\``;
90
111
  }
91
112
  else if (schema.maximum && !schema.exclusiveMaximum) {
92
- minmaxQualifier += ` ${schema.maximum}`;
113
+ maximum = `\`<= ${schema.maximum}\``;
93
114
  }
94
115
  else if (schema.maximum && schema.exclusiveMaximum === true) {
95
- minmaxQualifier += ` < ${schema.maximum}`;
116
+ maximum = `\`< ${schema.maximum}\``;
117
+ }
118
+ if (minimum && !maximum) {
119
+ minmaxQualifier += minimum;
120
+ }
121
+ if (maximum && !minimum) {
122
+ minmaxQualifier += maximum;
123
+ }
124
+ if (minimum && maximum) {
125
+ minmaxQualifier += `${minimum} and ${maximum}`;
96
126
  }
97
127
  qualifierGroups.push(minmaxQualifier);
98
128
  }
99
129
  if (schema.pattern) {
100
130
  qualifierGroups.push(`Value must match regular expression \`${schema.pattern}\``);
101
131
  }
132
+ // Check if discriminator mapping
133
+ const discriminator = schema;
134
+ if (discriminator.mapping) {
135
+ const values = Object.keys(discriminator.mapping);
136
+ qualifierGroups.push(`[${values.map((e) => `\`${e}\``).join(", ")}]`);
137
+ }
102
138
  if (schema.enum) {
103
139
  qualifierGroups.push(`[${schema.enum.map((e) => `\`${e}\``).join(", ")}]`);
104
140
  }
105
141
  if (schema.minItems) {
106
- qualifierGroups.push(`items >= ${schema.minItems}`);
142
+ qualifierGroups.push(`\`>= ${schema.minItems}\``);
107
143
  }
108
144
  if (schema.maxItems) {
109
- qualifierGroups.push(`items <= ${schema.maxItems}`);
145
+ qualifierGroups.push(`\`<= ${schema.maxItems}\``);
110
146
  }
111
147
  if (qualifierGroups.length === 0) {
112
148
  return undefined;
@@ -16,17 +16,17 @@ describe("getQualifierMessage", () => {
16
16
  // minLength + maxLength
17
17
  //
18
18
  it("should render minLength", () => {
19
- const expected = "**Possible values:** 1 ≤ length";
19
+ const expected = "**Possible values:** `non-empty`";
20
20
  const actual = (0, schema_1.getQualifierMessage)({ minLength: 1 });
21
21
  expect(actual).toBe(expected);
22
22
  });
23
23
  it("should render maxLength", () => {
24
- const expected = "**Possible values:** length 40";
24
+ const expected = "**Possible values:** `<= 40 characters`";
25
25
  const actual = (0, schema_1.getQualifierMessage)({ maxLength: 40 });
26
26
  expect(actual).toBe(expected);
27
27
  });
28
28
  it("should render minLength and maxLength", () => {
29
- const expected = "**Possible values:** 1 length 40";
29
+ const expected = "**Possible values:** `non-empty` and `<= 40 characters`";
30
30
  const actual = (0, schema_1.getQualifierMessage)({ minLength: 1, maxLength: 40 });
31
31
  expect(actual).toBe(expected);
32
32
  });
@@ -39,7 +39,7 @@ describe("getQualifierMessage", () => {
39
39
  expect(actual).toBe(expected);
40
40
  });
41
41
  it("should render multiple string qualifiers", () => {
42
- const expected = "**Possible values:** 1 length 40, Value must match regular expression `^[a-zA-Z0-9_-]*$`";
42
+ const expected = "**Possible values:** `non-empty` and `<= 40 characters`, Value must match regular expression `^[a-zA-Z0-9_-]*$`";
43
43
  const actual = (0, schema_1.getQualifierMessage)({
44
44
  minLength: 1,
45
45
  maxLength: 40,
@@ -59,42 +59,42 @@ describe("getQualifierMessage", () => {
59
59
  // minimum + maximum + exclusiveMinimum + exclusiveMaximum
60
60
  //
61
61
  it("should render minimum", () => {
62
- const expected = "**Possible values:** 1 ≤ value";
62
+ const expected = "**Possible values:** `>= 1`";
63
63
  const actual = (0, schema_1.getQualifierMessage)({ minimum: 1 });
64
64
  expect(actual).toBe(expected);
65
65
  });
66
66
  it("should render maximum", () => {
67
- const expected = "**Possible values:** value 40";
67
+ const expected = "**Possible values:** `<= 40`";
68
68
  const actual = (0, schema_1.getQualifierMessage)({ maximum: 40 });
69
69
  expect(actual).toBe(expected);
70
70
  });
71
71
  it("should render numeric exclusiveMinimum", () => {
72
- const expected = "**Possible values:** 1 < value";
72
+ const expected = "**Possible values:** `> 1`";
73
73
  const actual = (0, schema_1.getQualifierMessage)({ exclusiveMinimum: 1 });
74
74
  expect(actual).toBe(expected);
75
75
  });
76
76
  it("should render numeric exclusiveMaximum", () => {
77
- const expected = "**Possible values:** value < 40";
77
+ const expected = "**Possible values:** `< 40`";
78
78
  const actual = (0, schema_1.getQualifierMessage)({ exclusiveMaximum: 40 });
79
79
  expect(actual).toBe(expected);
80
80
  });
81
81
  it("should render boolean exclusiveMinimum", () => {
82
- const expected = "**Possible values:** 1 < value";
82
+ const expected = "**Possible values:** `> 1`";
83
83
  const actual = (0, schema_1.getQualifierMessage)({ minimum: 1, exclusiveMinimum: true });
84
84
  expect(actual).toBe(expected);
85
85
  });
86
86
  it("should render boolean exclusiveMaximum", () => {
87
- const expected = "**Possible values:** value < 40";
87
+ const expected = "**Possible values:** `< 40`";
88
88
  const actual = (0, schema_1.getQualifierMessage)({ maximum: 40, exclusiveMaximum: true });
89
89
  expect(actual).toBe(expected);
90
90
  });
91
91
  it("should render minimum when exclusiveMinimum is false", () => {
92
- const expected = "**Possible values:** 1 ≤ value";
92
+ const expected = "**Possible values:** `>= 1`";
93
93
  const actual = (0, schema_1.getQualifierMessage)({ minimum: 1, exclusiveMinimum: false });
94
94
  expect(actual).toBe(expected);
95
95
  });
96
96
  it("should render maximum when exclusiveMaximum is false", () => {
97
- const expected = "**Possible values:** value 40";
97
+ const expected = "**Possible values:** `<= 40`";
98
98
  const actual = (0, schema_1.getQualifierMessage)({
99
99
  maximum: 40,
100
100
  exclusiveMaximum: false,
@@ -102,12 +102,12 @@ describe("getQualifierMessage", () => {
102
102
  expect(actual).toBe(expected);
103
103
  });
104
104
  it("should render minimum and maximum", () => {
105
- const expected = "**Possible values:** 1 value 40";
105
+ const expected = "**Possible values:** `>= 1` and `<= 40`";
106
106
  const actual = (0, schema_1.getQualifierMessage)({ minimum: 1, maximum: 40 });
107
107
  expect(actual).toBe(expected);
108
108
  });
109
109
  it("should render boolean exclusiveMinimum and maximum", () => {
110
- const expected = "**Possible values:** 1 < value 40";
110
+ const expected = "**Possible values:** `> 1` and `<= 40`";
111
111
  const actual = (0, schema_1.getQualifierMessage)({
112
112
  minimum: 1,
113
113
  maximum: 40,
@@ -116,7 +116,7 @@ describe("getQualifierMessage", () => {
116
116
  expect(actual).toBe(expected);
117
117
  });
118
118
  it("should render minimum and boolean exclusiveMaximum", () => {
119
- const expected = "**Possible values:** 1 value < 40";
119
+ const expected = "**Possible values:** `>= 1` and `< 40`";
120
120
  const actual = (0, schema_1.getQualifierMessage)({
121
121
  minimum: 1,
122
122
  maximum: 40,
@@ -125,7 +125,7 @@ describe("getQualifierMessage", () => {
125
125
  expect(actual).toBe(expected);
126
126
  });
127
127
  it("should render numeric exclusiveMinimum and maximum", () => {
128
- const expected = "**Possible values:** 1 < value 40";
128
+ const expected = "**Possible values:** `> 1` and `<= 40`";
129
129
  const actual = (0, schema_1.getQualifierMessage)({
130
130
  exclusiveMinimum: 1,
131
131
  maximum: 40,
@@ -133,7 +133,7 @@ describe("getQualifierMessage", () => {
133
133
  expect(actual).toBe(expected);
134
134
  });
135
135
  it("should render minimum and numeric exclusiveMaximum", () => {
136
- const expected = "**Possible values:** 1 value < 40";
136
+ const expected = "**Possible values:** `>= 1` and `< 40`";
137
137
  const actual = (0, schema_1.getQualifierMessage)({
138
138
  minimum: 1,
139
139
  exclusiveMaximum: 40,
@@ -141,7 +141,7 @@ describe("getQualifierMessage", () => {
141
141
  expect(actual).toBe(expected);
142
142
  });
143
143
  it("should render numeric exclusiveMinimum and boolean exclusiveMaximum", () => {
144
- const expected = "**Possible values:** 1 < value < 40";
144
+ const expected = "**Possible values:** `> 1` and `< 40`";
145
145
  const actual = (0, schema_1.getQualifierMessage)({
146
146
  exclusiveMinimum: 1,
147
147
  maximum: 40,