docusaurus-theme-openapi-docs 1.1.2 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/lib/markdown/schema.js +85 -20
  2. package/lib/theme/ApiDemoPanel/Body/index.js +1 -1
  3. package/lib/theme/ApiItem/Layout/styles.module.css +16 -0
  4. package/lib/theme/ApiLogo/index.js +29 -0
  5. package/lib/theme/DiscriminatorTabs/index.js +263 -0
  6. package/lib/theme/DiscriminatorTabs/styles.module.css +111 -0
  7. package/lib/theme/MimeTabs/index.js +260 -0
  8. package/lib/theme/MimeTabs/styles.module.css +125 -0
  9. package/lib/theme/ParamsItem/index.js +10 -0
  10. package/lib/theme/ResponseSamples/index.js +27 -0
  11. package/lib/theme/ResponseSamples/styles.module.css +7 -0
  12. package/lib/theme/SchemaItem/index.js +15 -3
  13. package/lib/theme/SchemaTabs/styles.module.css +0 -8
  14. package/lib-next/markdown/schema.js +88 -22
  15. package/lib-next/theme/ApiDemoPanel/Body/index.js +1 -1
  16. package/lib-next/theme/ApiItem/Layout/styles.module.css +16 -0
  17. package/lib-next/theme/ApiLogo/index.js +21 -0
  18. package/lib-next/theme/DiscriminatorTabs/index.js +263 -0
  19. package/lib-next/theme/DiscriminatorTabs/styles.module.css +111 -0
  20. package/lib-next/theme/MimeTabs/index.js +260 -0
  21. package/lib-next/theme/MimeTabs/styles.module.css +125 -0
  22. package/lib-next/theme/ParamsItem/index.js +10 -0
  23. package/lib-next/theme/ResponseSamples/index.js +27 -0
  24. package/lib-next/theme/ResponseSamples/styles.module.css +7 -0
  25. package/lib-next/theme/SchemaItem/index.js +15 -3
  26. package/lib-next/theme/SchemaTabs/styles.module.css +0 -8
  27. package/package.json +6 -6
  28. package/src/markdown/schema.ts +86 -20
  29. package/src/markdown/utils.ts +2 -2
  30. package/src/theme/ApiDemoPanel/Body/index.tsx +1 -1
  31. package/src/theme/ApiItem/Layout/styles.module.css +16 -0
  32. package/src/theme/ApiLogo/index.tsx +25 -0
  33. package/src/theme/DiscriminatorTabs/index.js +263 -0
  34. package/src/theme/DiscriminatorTabs/styles.module.css +111 -0
  35. package/src/theme/MimeTabs/index.js +260 -0
  36. package/src/theme/MimeTabs/styles.module.css +125 -0
  37. package/src/theme/ParamsItem/index.js +10 -0
  38. package/src/theme/ResponseSamples/index.js +27 -0
  39. package/src/theme/ResponseSamples/styles.module.css +7 -0
  40. package/src/theme/SchemaItem/index.js +15 -3
  41. package/src/theme/SchemaTabs/styles.module.css +0 -8
@@ -0,0 +1,260 @@
1
+ /* ============================================================================
2
+ * Copyright (c) Palo Alto Networks
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ * ========================================================================== */
7
+
8
+ import React, {
9
+ Children,
10
+ cloneElement,
11
+ isValidElement,
12
+ useEffect,
13
+ useRef,
14
+ useState,
15
+ } from "react";
16
+
17
+ import { duplicates } from "@docusaurus/theme-common";
18
+ import useIsBrowser from "@docusaurus/useIsBrowser";
19
+ import clsx from "clsx";
20
+
21
+ import styles from "./styles.module.css"; // A very rough duck type, but good enough to guard against mistakes while
22
+
23
+ const {
24
+ useScrollPositionBlocker,
25
+ useTabGroupChoice,
26
+ } = require("@docusaurus/theme-common/internal");
27
+
28
+ // allowing customization
29
+
30
+ function isTabItem(comp) {
31
+ return typeof comp.props.value !== "undefined";
32
+ }
33
+
34
+ function MimeTabsComponent(props) {
35
+ const {
36
+ lazy,
37
+ block,
38
+ defaultValue: defaultValueProp,
39
+ values: valuesProp,
40
+ groupId,
41
+ className,
42
+ } = props;
43
+ const children = Children.map(props.children, (child) => {
44
+ if (isValidElement(child) && isTabItem(child)) {
45
+ return child;
46
+ } // child.type.name will give non-sensical values in prod because of
47
+ // minification, but we assume it won't throw in prod.
48
+
49
+ throw new Error(
50
+ `Docusaurus error: Bad <Tabs> child <${
51
+ // @ts-expect-error: guarding against unexpected cases
52
+ typeof child.type === "string" ? child.type : child.type.name
53
+ }>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`
54
+ );
55
+ });
56
+ const values =
57
+ valuesProp ?? // We only pick keys that we recognize. MDX would inject some keys by default
58
+ children.map(({ props: { value, label, attributes } }) => ({
59
+ value,
60
+ label,
61
+ attributes,
62
+ }));
63
+ const dup = duplicates(values, (a, b) => a.value === b.value);
64
+
65
+ if (dup.length > 0) {
66
+ throw new Error(
67
+ `Docusaurus error: Duplicate values "${dup
68
+ .map((a) => a.value)
69
+ .join(", ")}" found in <Tabs>. Every value needs to be unique.`
70
+ );
71
+ } // When defaultValueProp is null, don't show a default tab
72
+
73
+ const defaultValue =
74
+ defaultValueProp === null
75
+ ? defaultValueProp
76
+ : defaultValueProp ??
77
+ children.find((child) => child.props.default)?.props.value ??
78
+ children[0]?.props.value;
79
+
80
+ if (defaultValue !== null && !values.some((a) => a.value === defaultValue)) {
81
+ throw new Error(
82
+ `Docusaurus error: The <Tabs> has a defaultValue "${defaultValue}" but none of its children has the corresponding value. Available values are: ${values
83
+ .map((a) => a.value)
84
+ .join(
85
+ ", "
86
+ )}. If you intend to show no default tab, use defaultValue={null} instead.`
87
+ );
88
+ }
89
+
90
+ const { tabGroupChoices, setTabGroupChoices } = useTabGroupChoice();
91
+ const [selectedValue, setSelectedValue] = useState(defaultValue);
92
+ const tabRefs = [];
93
+ const { blockElementScrollPositionUntilNextRender } =
94
+ useScrollPositionBlocker();
95
+
96
+ if (groupId != null) {
97
+ const relevantTabGroupChoice = tabGroupChoices[groupId];
98
+
99
+ if (
100
+ relevantTabGroupChoice != null &&
101
+ relevantTabGroupChoice !== selectedValue &&
102
+ values.some((value) => value.value === relevantTabGroupChoice)
103
+ ) {
104
+ setSelectedValue(relevantTabGroupChoice);
105
+ }
106
+ }
107
+
108
+ const handleTabChange = (event) => {
109
+ const newTab = event.currentTarget;
110
+ const newTabIndex = tabRefs.indexOf(newTab);
111
+ const newTabValue = values[newTabIndex].value;
112
+
113
+ if (newTabValue !== selectedValue) {
114
+ blockElementScrollPositionUntilNextRender(newTab);
115
+ setSelectedValue(newTabValue);
116
+
117
+ if (groupId != null) {
118
+ setTabGroupChoices(groupId, newTabValue);
119
+ }
120
+ }
121
+ };
122
+
123
+ const handleKeydown = (event) => {
124
+ let focusElement = null;
125
+
126
+ switch (event.key) {
127
+ case "ArrowRight": {
128
+ const nextTab = tabRefs.indexOf(event.currentTarget) + 1;
129
+ focusElement = tabRefs[nextTab] || tabRefs[0];
130
+ break;
131
+ }
132
+
133
+ case "ArrowLeft": {
134
+ const prevTab = tabRefs.indexOf(event.currentTarget) - 1;
135
+ focusElement = tabRefs[prevTab] || tabRefs[tabRefs.length - 1];
136
+ break;
137
+ }
138
+
139
+ default:
140
+ break;
141
+ }
142
+
143
+ focusElement?.focus();
144
+ };
145
+
146
+ const tabItemListContainerRef = useRef(null);
147
+ const [showTabArrows, setShowTabArrows] = useState(false);
148
+
149
+ useEffect(() => {
150
+ const tabOffsetWidth = tabItemListContainerRef.current.offsetWidth;
151
+ const tabScrollWidth = tabItemListContainerRef.current.scrollWidth;
152
+
153
+ if (tabOffsetWidth < tabScrollWidth) {
154
+ setShowTabArrows(true);
155
+ }
156
+ }, []);
157
+
158
+ const handleRightClick = () => {
159
+ tabItemListContainerRef.current.scrollLeft += 90;
160
+ };
161
+
162
+ const handleLeftClick = () => {
163
+ tabItemListContainerRef.current.scrollLeft -= 90;
164
+ };
165
+
166
+ return (
167
+ <div className="tabs__container">
168
+ <div className={styles.mimeTabsTopSection}>
169
+ {/* <strong>MIME Type</strong> */}
170
+ <div className={styles.mimeTabsContainer}>
171
+ {showTabArrows && (
172
+ <button
173
+ className={clsx(styles.tabArrow, styles.tabArrowLeft)}
174
+ onClick={handleLeftClick}
175
+ />
176
+ )}
177
+ <ul
178
+ ref={tabItemListContainerRef}
179
+ role="tablist"
180
+ aria-orientation="horizontal"
181
+ className={clsx(
182
+ styles.mimeTabsListContainer,
183
+ "tabs",
184
+ {
185
+ "tabs--block": block,
186
+ },
187
+ className
188
+ )}
189
+ >
190
+ {values.map(({ value, label, attributes }) => {
191
+ return (
192
+ <li
193
+ role="tab"
194
+ tabIndex={selectedValue === value ? 0 : -1}
195
+ aria-selected={selectedValue === value}
196
+ key={value}
197
+ ref={(tabControl) => tabRefs.push(tabControl)}
198
+ onKeyDown={handleKeydown}
199
+ onFocus={handleTabChange}
200
+ onClick={handleTabChange}
201
+ {...attributes}
202
+ className={clsx(
203
+ "tabs__item",
204
+ styles.tabItem,
205
+ attributes?.className,
206
+ {
207
+ [styles.mimeTabActive]: selectedValue === value,
208
+ }
209
+ )}
210
+ >
211
+ {/* <div
212
+ className={clsx(styles.mimeTabDot, mimeTabDotStyle)}
213
+ /> */}
214
+ {label ?? value}
215
+ </li>
216
+ );
217
+ })}
218
+ </ul>
219
+ {showTabArrows && (
220
+ <button
221
+ className={clsx(styles.tabArrow, styles.tabArrowRight)}
222
+ onClick={handleRightClick}
223
+ />
224
+ )}
225
+ </div>
226
+ </div>
227
+ {/* <hr /> */}
228
+ {lazy ? (
229
+ cloneElement(
230
+ children.filter(
231
+ (tabItem) => tabItem.props.value === selectedValue
232
+ )[0],
233
+ {
234
+ className: clsx("margin-vert--md", styles.mimeSchemaContainer),
235
+ }
236
+ )
237
+ ) : (
238
+ <div className={clsx("margin-vert--md", styles.mimeSchemaContainer)}>
239
+ {children.map((tabItem, i) =>
240
+ cloneElement(tabItem, {
241
+ key: i,
242
+ hidden: tabItem.props.value !== selectedValue,
243
+ })
244
+ )}
245
+ </div>
246
+ )}
247
+ </div>
248
+ );
249
+ }
250
+
251
+ export default function MimeTabs(props) {
252
+ const isBrowser = useIsBrowser();
253
+ return (
254
+ <MimeTabsComponent // Remount tabs after hydration
255
+ // Temporary fix for https://github.com/facebook/docusaurus/issues/5653
256
+ key={String(isBrowser)}
257
+ {...props}
258
+ />
259
+ );
260
+ }
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ .tabItem {
9
+ display: flex;
10
+ align-items: center;
11
+ justify-content: center;
12
+ height: 2rem;
13
+ margin-top: 0 !important;
14
+ margin-right: 0.5rem;
15
+ /* border: 1px solid var(--openapi-code-dim-dark);
16
+ border-radius: 0; */
17
+ font-weight: var(--ifm-font-weight-normal);
18
+ /* color: var(--openapi-code-dim-dark); */
19
+ font-size: 12px;
20
+ }
21
+
22
+ .tabItem:active {
23
+ background-color: var(--ifm-color-emphasis-100);
24
+ }
25
+
26
+ /* .tabItem:hover {
27
+ color: var(--ifm-color-emphasis-500) !important;
28
+ } */
29
+
30
+ .tabItem:last-child {
31
+ margin-right: 0 !important;
32
+ }
33
+
34
+ /* Open API Response Code Tabs */
35
+ .mimeTabsTopSection {
36
+ display: flex;
37
+ justify-content: space-between;
38
+ align-items: center;
39
+ }
40
+
41
+ .mimeTabsContainer {
42
+ display: flex;
43
+ align-items: center;
44
+ max-width: 390px;
45
+ /* padding-left: 1rem; */
46
+ overflow: hidden;
47
+ }
48
+
49
+ .mimeTabsListContainer {
50
+ overflow-y: hidden;
51
+ overflow-x: scroll;
52
+ scroll-behavior: smooth;
53
+ }
54
+
55
+ .mimeTabsListContainer::-webkit-scrollbar {
56
+ display: none;
57
+ }
58
+
59
+ /* Response Code Tabs - Colored Dots */
60
+ .mimeTabDot {
61
+ width: 12.5px;
62
+ height: 12.5px;
63
+ margin-right: 5px;
64
+ border-radius: 50%;
65
+ }
66
+
67
+ .mimeTabDotSuccess {
68
+ background-color: var(--ifm-color-success);
69
+ }
70
+
71
+ .mimeTabDotDanger {
72
+ background-color: var(--ifm-color-danger);
73
+ }
74
+
75
+ .mimeTabDotInfo {
76
+ background-color: var(--ifm-color-info);
77
+ }
78
+
79
+ .mimeTabActive {
80
+ border-bottom-color: var(--ifm-tabs-color-active-border);
81
+ border-bottom-left-radius: 0;
82
+ border-bottom-right-radius: 0;
83
+ color: var(--ifm-tabs-color-active);
84
+ background-color: var(--ifm-color-emphasis-100);
85
+ }
86
+
87
+ .mimeSchemaContainer {
88
+ max-width: 600px;
89
+ }
90
+
91
+ /* Tab Arrows */
92
+ .tabArrow {
93
+ content: "";
94
+ height: 1.25rem;
95
+ width: 1.25rem;
96
+ border: none;
97
+ min-width: 1.25rem;
98
+ background: var(--ifm-menu-link-sublist-icon) 50% / 2rem 2rem;
99
+ filter: var(--ifm-menu-link-sublist-icon-filter);
100
+ }
101
+
102
+ .tabArrow:hover {
103
+ cursor: pointer;
104
+ }
105
+
106
+ .tabArrowLeft {
107
+ transform: rotate(270deg);
108
+ }
109
+
110
+ .tabArrowRight {
111
+ transform: rotate(90deg);
112
+ }
113
+
114
+ @media screen and (max-width: 500px) {
115
+ .mimeTabsTopSection {
116
+ flex-direction: column;
117
+ align-items: flex-start;
118
+ }
119
+
120
+ .mimeTabsContainer {
121
+ width: 100%;
122
+ margin-top: var(--ifm-spacing-vertical);
123
+ padding: 0;
124
+ }
125
+ }
@@ -37,6 +37,15 @@ function ParamsItem({
37
37
  </div>
38
38
  ));
39
39
 
40
+ const renderDefaultValue = guard(
41
+ schema.items ? schema.items.default : schema.default,
42
+ (value) => (
43
+ <div>
44
+ <ReactMarkdown children={`**Default value:** \`${value}\``} />
45
+ </div>
46
+ )
47
+ );
48
+
40
49
  const renderExample = guard(example, (example) => (
41
50
  <div>{`Example: ${example}`}</div>
42
51
  ));
@@ -58,6 +67,7 @@ function ParamsItem({
58
67
  {renderSchemaName}
59
68
  {renderSchemaRequired}
60
69
  {renderSchema}
70
+ {renderDefaultValue}
61
71
  {renderDescription}
62
72
  {renderExample}
63
73
  {renderExamples}
@@ -0,0 +1,27 @@
1
+ /* ============================================================================
2
+ * Copyright (c) Palo Alto Networks
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ * ========================================================================== */
7
+
8
+ import React from "react";
9
+
10
+ import CodeBlock from "@theme/CodeBlock";
11
+
12
+ import styles from "./styles.module.css";
13
+
14
+ function ResponseSamples({ responseExample }) {
15
+ return (
16
+ <div className={styles.responseSamplesContainer}>
17
+ <CodeBlock
18
+ language="javascript"
19
+ className={styles.responseSamplesCodeBlock}
20
+ >
21
+ {responseExample}
22
+ </CodeBlock>
23
+ </div>
24
+ );
25
+ }
26
+
27
+ export default ResponseSamples;
@@ -0,0 +1,7 @@
1
+ .responseSamplesContainer {
2
+ margin-top: 2rem;
3
+ }
4
+
5
+ .responseSamplesTabItem {
6
+ width: 100%;
7
+ }
@@ -21,10 +21,12 @@ function SchemaItem({
21
21
  required,
22
22
  schemaDescription,
23
23
  schemaName,
24
+ defaultValue,
24
25
  }) {
25
- const renderRequired = guard(required, () => (
26
- <strong className={styles.required}> required</strong>
27
- ));
26
+ const renderRequired = guard(
27
+ Array.isArray(required) ? required.includes(name) : required,
28
+ () => <strong className={styles.required}> required</strong>
29
+ );
28
30
 
29
31
  const renderSchemaDescription = guard(schemaDescription, (description) => (
30
32
  <div className={styles.schemaDescription}>
@@ -38,12 +40,22 @@ function SchemaItem({
38
40
  </div>
39
41
  ));
40
42
 
43
+ const renderDefaultValue = guard(
44
+ typeof defaultValue === "boolean" ? defaultValue.toString() : defaultValue,
45
+ (value) => (
46
+ <div className={styles.schemaQualifierMessage}>
47
+ <ReactMarkdown children={`**Default value:** \`${value}\``} />
48
+ </div>
49
+ )
50
+ );
51
+
41
52
  const schemaContent = (
42
53
  <div>
43
54
  <strong>{name}</strong>
44
55
  <span className={styles.schemaName}> {schemaName}</span>
45
56
  {renderRequired}
46
57
  {renderQualifierMessage}
58
+ {renderDefaultValue}
47
59
  {renderSchemaDescription}
48
60
  </div>
49
61
  );
@@ -38,14 +38,6 @@
38
38
  display: none;
39
39
  }
40
40
 
41
- .schemaTabsContainer {
42
- display: flex;
43
- align-items: center;
44
- max-width: 390px;
45
- padding-left: 3px;
46
- overflow: hidden;
47
- }
48
-
49
41
  .schemaTabsListContainer {
50
42
  padding: 0 0.25rem;
51
43
  overflow-y: hidden;
@@ -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 (schema.items) {
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
- lengthQualifier += `${schema.minLength} ≤ `;
83
+ if (schema.minLength && schema.minLength > 1) {
84
+ minLength = `\`>= ${schema.minLength} characters\``;
60
85
  }
61
86
 
62
- lengthQualifier += "length";
87
+ if (schema.minLength && schema.minLength === 1) {
88
+ minLength = `\`non-empty\``;
89
+ }
63
90
 
64
91
  if (schema.maxLength) {
65
- lengthQualifier += ` ${schema.maxLength}`;
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
- minmaxQualifier += `${schema.exclusiveMinimum} < `;
121
+ minimum = `\`> ${schema.exclusiveMinimum}\``;
81
122
  } else if (schema.minimum && !schema.exclusiveMinimum) {
82
- minmaxQualifier += `${schema.minimum} ≤ `;
123
+ minimum = `\`>= ${schema.minimum}\``;
83
124
  } else if (schema.minimum && schema.exclusiveMinimum === true) {
84
- minmaxQualifier += `${schema.minimum} < `;
125
+ minimum = `\`> ${schema.minimum}\``;
85
126
  }
86
127
 
87
- minmaxQualifier += "value";
88
-
89
128
  if (typeof schema.exclusiveMaximum === "number") {
90
- minmaxQualifier += ` < ${schema.exclusiveMaximum}`;
129
+ maximum = `\`< ${schema.exclusiveMaximum}\``;
91
130
  } else if (schema.maximum && !schema.exclusiveMaximum) {
92
- minmaxQualifier += ` ${schema.maximum}`;
131
+ maximum = `\`<= ${schema.maximum}\``;
93
132
  } else if (schema.maximum && schema.exclusiveMaximum === true) {
94
- minmaxQualifier += ` < ${schema.maximum}`;
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
  }
@@ -178,7 +178,7 @@ function Body({ requestBodyMetadata, jsonRequestBodyExample }) {
178
178
  let language = "plaintext";
179
179
  let exampleBodyString = ""; //"body content";
180
180
 
181
- if (contentType === "application/json") {
181
+ if (contentType === "application/json" || contentType.endsWith("+json")) {
182
182
  if (jsonRequestBodyExample) {
183
183
  exampleBodyString = JSON.stringify(jsonRequestBodyExample, null, 2);
184
184
  }