@gitbook/react-openapi 1.5.5 → 1.5.6

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 (50) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/InteractiveSection.js +52 -30
  3. package/dist/Markdown.js +5 -1
  4. package/dist/OpenAPICodeSample.js +45 -9
  5. package/dist/OpenAPICodeSampleInteractive.js +41 -15
  6. package/dist/OpenAPICodeSampleSelector.js +34 -14
  7. package/dist/OpenAPICopyButton.js +21 -15
  8. package/dist/OpenAPIDisclosure.js +18 -10
  9. package/dist/OpenAPIDisclosureGroup.js +56 -30
  10. package/dist/OpenAPIExample.js +6 -4
  11. package/dist/OpenAPIMediaType.js +38 -17
  12. package/dist/OpenAPIOperation.d.ts +2 -2
  13. package/dist/OpenAPIOperation.js +26 -12
  14. package/dist/OpenAPIOperationContext.d.ts +2 -2
  15. package/dist/OpenAPIOperationContext.js +5 -3
  16. package/dist/OpenAPIPath.js +14 -5
  17. package/dist/OpenAPIPathItem.js +26 -12
  18. package/dist/OpenAPIPathMultipleServers.js +29 -12
  19. package/dist/OpenAPIPrefillContextProvider.d.ts +2 -1
  20. package/dist/OpenAPIPrefillContextProvider.js +5 -3
  21. package/dist/OpenAPIRequestBody.js +20 -10
  22. package/dist/OpenAPIRequestBodyHeaderType.js +5 -3
  23. package/dist/OpenAPIRequiredScopes.js +41 -26
  24. package/dist/OpenAPIResponse.js +34 -19
  25. package/dist/OpenAPIResponseExample.js +25 -8
  26. package/dist/OpenAPIResponseExampleContent.js +39 -18
  27. package/dist/OpenAPIResponses.js +40 -17
  28. package/dist/OpenAPISchema.js +212 -88
  29. package/dist/OpenAPISchemaName.js +44 -24
  30. package/dist/OpenAPISchemaServer.js +10 -2
  31. package/dist/OpenAPISecurities.js +125 -57
  32. package/dist/OpenAPISelect.js +27 -18
  33. package/dist/OpenAPISpec.js +27 -12
  34. package/dist/OpenAPITooltip.js +14 -6
  35. package/dist/OpenAPIWebhook.d.ts +2 -2
  36. package/dist/OpenAPIWebhook.js +23 -11
  37. package/dist/OpenAPIWebhookExample.js +18 -8
  38. package/dist/ScalarApiButton.js +50 -29
  39. package/dist/StaticSection.js +49 -15
  40. package/dist/common/OpenAPIColumnSpec.js +21 -9
  41. package/dist/common/OpenAPIOperationDescription.js +12 -6
  42. package/dist/common/OpenAPIStability.js +6 -3
  43. package/dist/common/OpenAPISummary.js +23 -12
  44. package/dist/formatPath.js +7 -4
  45. package/dist/schemas/OpenAPISchemaItem.js +18 -11
  46. package/dist/schemas/OpenAPISchemas.d.ts +2 -2
  47. package/dist/schemas/OpenAPISchemas.js +55 -31
  48. package/dist/translate.js +4 -6
  49. package/dist/util/example.js +6 -1
  50. package/package.json +2 -2
@@ -5,6 +5,7 @@ import { getOpenAPIClientContext } from "./context.js";
5
5
  import { getExampleFromReference, getExamples } from "./util/example.js";
6
6
  import { OpenAPIMediaTypeContent } from "./OpenAPIMediaType.js";
7
7
  import { OpenAPIResponseExampleContent } from "./OpenAPIResponseExampleContent.js";
8
+ import { Fragment, jsx } from "react/jsx-runtime";
8
9
 
9
10
  //#region src/OpenAPIResponseExample.tsx
10
11
  /**
@@ -23,28 +24,39 @@ function OpenAPIResponseExample(props) {
23
24
  });
24
25
  const tabs = responses.filter(([_, responseObject]) => responseObject && typeof responseObject === "object" && !responseObject["x-hideSample"]).map(([key, responseObject]) => {
25
26
  const description = resolveDescription(responseObject);
26
- const label = description ? <Markdown key={`response-description-${key}`} source={description} /> : getStatusCodeDefaultLabel(key, context);
27
+ const label = description ? /* @__PURE__ */ jsx(Markdown, { source: description }, `response-description-${key}`) : getStatusCodeDefaultLabel(key, context);
27
28
  if (checkIsReference(responseObject)) return {
28
29
  key,
29
30
  label,
30
31
  statusCode: key,
31
- body: <OpenAPIExample example={getExampleFromReference(responseObject, context)} context={context} syntax="json" />
32
+ body: /* @__PURE__ */ jsx(OpenAPIExample, {
33
+ example: getExampleFromReference(responseObject, context),
34
+ context,
35
+ syntax: "json"
36
+ })
32
37
  };
33
38
  if (!responseObject.content || Object.keys(responseObject.content).length === 0) return {
34
39
  key,
35
40
  label,
36
41
  statusCode: key,
37
- body: <OpenAPIEmptyExample context={context} />
42
+ body: /* @__PURE__ */ jsx(OpenAPIEmptyExample, { context })
38
43
  };
39
44
  return {
40
45
  key,
41
46
  label,
42
47
  statusCode: key,
43
- body: <OpenAPIResponse context={context} content={responseObject.content} />
48
+ body: /* @__PURE__ */ jsx(OpenAPIResponse, {
49
+ context,
50
+ content: responseObject.content
51
+ })
44
52
  };
45
53
  });
46
54
  if (tabs.length === 0) return null;
47
- return <OpenAPIResponseExampleContent selectIcon={context.icons.chevronDown} blockKey={context.blockKey} items={tabs} />;
55
+ return /* @__PURE__ */ jsx(OpenAPIResponseExampleContent, {
56
+ selectIcon: context.icons.chevronDown,
57
+ blockKey: context.blockKey,
58
+ items: tabs
59
+ });
48
60
  }
49
61
  function OpenAPIResponse(props) {
50
62
  const { context, content } = props;
@@ -55,12 +67,12 @@ function OpenAPIResponse(props) {
55
67
  if (!mediaTypeObject) return {
56
68
  key: mediaType,
57
69
  label: mediaType,
58
- body: <OpenAPIEmptyExample context={context} />
70
+ body: /* @__PURE__ */ jsx(OpenAPIEmptyExample, { context })
59
71
  };
60
72
  return {
61
73
  key: mediaType,
62
74
  label: mediaType,
63
- body: <></>,
75
+ body: /* @__PURE__ */ jsx(Fragment, {}),
64
76
  examples: getExamples({
65
77
  mediaTypeObject,
66
78
  mediaType,
@@ -68,7 +80,12 @@ function OpenAPIResponse(props) {
68
80
  })
69
81
  };
70
82
  });
71
- return <OpenAPIMediaTypeContent selectIcon={context.icons.chevronDown} stateKey={createStateKey("response-media-types", context.blockKey)} items={tabs} context={getOpenAPIClientContext(context)} />;
83
+ return /* @__PURE__ */ jsx(OpenAPIMediaTypeContent, {
84
+ selectIcon: context.icons.chevronDown,
85
+ stateKey: createStateKey("response-media-types", context.blockKey),
86
+ items: tabs,
87
+ context: getOpenAPIClientContext(context)
88
+ });
72
89
  }
73
90
 
74
91
  //#endregion
@@ -5,6 +5,7 @@ import { createStateKey, getStatusCodeClassName } from "./utils.js";
5
5
  import { StaticSection } from "./StaticSection.js";
6
6
  import { OpenAPISelect, OpenAPISelectItem, useSelectState } from "./OpenAPISelect.js";
7
7
  import clsx from "classnames";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
9
 
9
10
  //#region src/OpenAPIResponseExampleContent.tsx
10
11
  /**
@@ -15,40 +16,60 @@ function useResponseExamplesState(blockKey, initialKey = "default") {
15
16
  }
16
17
  function OpenAPIResponseExampleContent(props) {
17
18
  const { blockKey, items, selectIcon } = props;
18
- return <StaticSection header={<OpenAPIResponseExampleHeader selectIcon={selectIcon} blockKey={blockKey} items={items} />} className="openapi-response-examples">
19
- <OpenAPIResponseExampleBody blockKey={blockKey} items={items} />
20
- </StaticSection>;
19
+ return /* @__PURE__ */ jsx(StaticSection, {
20
+ header: /* @__PURE__ */ jsx(OpenAPIResponseExampleHeader, {
21
+ selectIcon,
22
+ blockKey,
23
+ items
24
+ }),
25
+ className: "openapi-response-examples",
26
+ children: /* @__PURE__ */ jsx(OpenAPIResponseExampleBody, {
27
+ blockKey,
28
+ items
29
+ })
30
+ });
21
31
  }
22
32
  function OpenAPIResponseExampleHeader(props) {
23
33
  const { items, blockKey, selectIcon } = props;
24
34
  if (items.length === 1) {
25
35
  const item = items[0];
26
36
  if (!item) return null;
27
- return <span className="openapi-response-examples-statuscode-title">
28
- <OpenAPIResponseExampleItem item={item} />
29
- </span>;
37
+ return /* @__PURE__ */ jsx("span", {
38
+ className: "openapi-response-examples-statuscode-title",
39
+ children: /* @__PURE__ */ jsx(OpenAPIResponseExampleItem, { item })
40
+ });
30
41
  }
31
- return <OpenAPISelect items={items} icon={selectIcon} stateKey={getResponseExampleStateKey(blockKey)} placement="bottom start">
32
- {items.map((item) => <OpenAPISelectItem key={item.key} id={item.key} value={item}>
33
- <OpenAPIResponseExampleItem item={item} />
34
- </OpenAPISelectItem>)}
35
- </OpenAPISelect>;
42
+ return /* @__PURE__ */ jsx(OpenAPISelect, {
43
+ items,
44
+ icon: selectIcon,
45
+ stateKey: getResponseExampleStateKey(blockKey),
46
+ placement: "bottom start",
47
+ children: items.map((item) => /* @__PURE__ */ jsx(OpenAPISelectItem, {
48
+ id: item.key,
49
+ value: item,
50
+ children: /* @__PURE__ */ jsx(OpenAPIResponseExampleItem, { item })
51
+ }, item.key))
52
+ });
36
53
  }
37
54
  function OpenAPIResponseExampleItem(props) {
38
55
  const { item } = props;
39
- return <>
40
- <span className={clsx("openapi-statuscode", `openapi-statuscode-${getStatusCodeClassName(item.statusCode)}`, "openapi-response-examples-statuscode")}>
41
- {item.statusCode}
42
- </span>
43
- <span className="openapi-response-examples-statuscode-label">{item.label}</span>
44
- </>;
56
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
57
+ className: clsx("openapi-statuscode", `openapi-statuscode-${getStatusCodeClassName(item.statusCode)}`, "openapi-response-examples-statuscode"),
58
+ children: item.statusCode
59
+ }), /* @__PURE__ */ jsx("span", {
60
+ className: "openapi-response-examples-statuscode-label",
61
+ children: item.label
62
+ })] });
45
63
  }
46
64
  function OpenAPIResponseExampleBody(props) {
47
65
  const { blockKey, items } = props;
48
66
  const state = useResponseExamplesState(blockKey, items[0]?.key);
49
67
  const selectedItem = items.find((item) => item.key === state.key) ?? items[0];
50
68
  if (!selectedItem) return null;
51
- return <div className="openapi-response-examples-panel">{selectedItem.body}</div>;
69
+ return /* @__PURE__ */ jsx("div", {
70
+ className: "openapi-response-examples-panel",
71
+ children: selectedItem.body
72
+ });
52
73
  }
53
74
  /**
54
75
  * Return the state key for the response examples.
@@ -9,6 +9,7 @@ import { useResponseExamplesState } from "./OpenAPIResponseExampleContent.js";
9
9
  import { OpenAPIDisclosureGroup } from "./OpenAPIDisclosureGroup.js";
10
10
  import { OpenAPIResponse } from "./OpenAPIResponse.js";
11
11
  import clsx from "classnames";
12
+ import { jsx, jsxs } from "react/jsx-runtime";
12
13
 
13
14
  //#region src/OpenAPIResponses.tsx
14
15
  /**
@@ -21,40 +22,62 @@ function OpenAPIResponses(props) {
21
22
  if ((!response.content || !Object.keys(response.content).length) && response.headers && Object.keys(response.headers).length) return [{
22
23
  key: "default",
23
24
  label: "",
24
- body: <OpenAPIResponse response={response} mediaType={{}} context={context} />
25
+ body: /* @__PURE__ */ jsx(OpenAPIResponse, {
26
+ response,
27
+ mediaType: {},
28
+ context
29
+ })
25
30
  }];
26
31
  if (!response.content) return [{
27
32
  key: "default",
28
33
  label: "",
29
- body: <pre className="openapi-example-empty">
30
- <p>{t(context.translation, "no_content")}</p>
31
- </pre>
34
+ body: /* @__PURE__ */ jsx("pre", {
35
+ className: "openapi-example-empty",
36
+ children: /* @__PURE__ */ jsx("p", { children: t(context.translation, "no_content") })
37
+ })
32
38
  }];
33
39
  return Object.entries(response.content ?? {}).map(([contentType, mediaType]) => ({
34
40
  key: contentType,
35
41
  label: contentType,
36
- body: <OpenAPIResponse response={response} mediaType={mediaType} context={context} />
42
+ body: /* @__PURE__ */ jsx(OpenAPIResponse, {
43
+ response,
44
+ mediaType,
45
+ context
46
+ })
37
47
  }));
38
48
  })();
39
49
  const description = resolveDescription(response);
40
50
  return {
41
51
  key: statusCode,
42
- label: <div className="openapi-response-tab-content">
43
- <span className={clsx("openapi-statuscode", `openapi-statuscode-${getStatusCodeClassName(statusCode)}`)}>
44
- {statusCode}
45
- </span>
46
- {description ? <Markdown source={description} className="openapi-response-description" /> : getStatusCodeDefaultLabel(statusCode, context)}
47
- </div>,
52
+ label: /* @__PURE__ */ jsxs("div", {
53
+ className: "openapi-response-tab-content",
54
+ children: [/* @__PURE__ */ jsx("span", {
55
+ className: clsx("openapi-statuscode", `openapi-statuscode-${getStatusCodeClassName(statusCode)}`),
56
+ children: statusCode
57
+ }), description ? /* @__PURE__ */ jsx(Markdown, {
58
+ source: description,
59
+ className: "openapi-response-description"
60
+ }) : getStatusCodeDefaultLabel(statusCode, context)]
61
+ }),
48
62
  tabs
49
63
  };
50
64
  });
51
65
  const state = useResponseExamplesState(context.blockKey, groups[0]?.key);
52
- return <StaticSection header={t(context.translation, "responses")} className="openapi-responses">
53
- <OpenAPIDisclosureGroup icon={context.icons.chevronRight} expandedKeys={state.key ? new Set([state.key]) : /* @__PURE__ */ new Set()} onExpandedChange={(keys) => {
54
- const key = keys.values().next().value ?? null;
55
- state.setKey(key);
56
- }} groups={groups} selectIcon={context.icons.chevronDown} selectStateKey={createStateKey("response-media-types", context.blockKey)} />
57
- </StaticSection>;
66
+ return /* @__PURE__ */ jsx(StaticSection, {
67
+ header: t(context.translation, "responses"),
68
+ className: "openapi-responses",
69
+ children: /* @__PURE__ */ jsx(OpenAPIDisclosureGroup, {
70
+ icon: context.icons.chevronRight,
71
+ expandedKeys: state.key ? new Set([state.key]) : /* @__PURE__ */ new Set(),
72
+ onExpandedChange: (keys) => {
73
+ const key = keys.values().next().value ?? null;
74
+ state.setKey(key);
75
+ },
76
+ groups,
77
+ selectIcon: context.icons.chevronDown,
78
+ selectStateKey: createStateKey("response-media-types", context.blockKey)
79
+ })
80
+ });
58
81
  }
59
82
 
60
83
  //#endregion
@@ -12,6 +12,7 @@ import { getDisclosureLabel } from "./getDisclosureLabel.js";
12
12
  import { checkIsReference, getSchemaTitle, resolveDescription, resolveFirstExample } from "./utils.js";
13
13
  import clsx from "classnames";
14
14
  import { useId } from "react";
15
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
15
16
 
16
17
  //#region src/OpenAPISchema.tsx
17
18
  /**
@@ -22,42 +23,77 @@ function OpenAPISchemaProperty(props) {
22
23
  const { schema } = property;
23
24
  const id = useId();
24
25
  const circularRefId = parentCircularRefs.get(schema);
25
- if (circularRefId) return <OpenAPISchemaPresentation context={context} property={property} circularRefId={circularRefId} />;
26
+ if (circularRefId) return /* @__PURE__ */ jsx(OpenAPISchemaPresentation, {
27
+ context,
28
+ property,
29
+ circularRefId
30
+ });
26
31
  const circularRefs = new Map(parentCircularRefs);
27
32
  circularRefs.set(schema, id);
28
33
  const properties = getSchemaProperties(schema, discriminator, discriminatorValue);
29
34
  const alternatives = getSchemaAlternatives(schema, new Set(circularRefs.keys()));
30
- const header = <OpenAPISchemaPresentation id={id} context={context} property={property} />;
35
+ const header = /* @__PURE__ */ jsx(OpenAPISchemaPresentation, {
36
+ id,
37
+ context,
38
+ property
39
+ });
31
40
  const content = (() => {
32
- if (alternatives?.schemas) return <OpenAPISchemaAlternatives alternatives={alternatives} schema={schema} circularRefs={circularRefs} context={context} parentDiscriminator={discriminator} parentDiscriminatorValue={discriminatorValue} />;
33
- if (properties?.length) return <OpenAPISchemaProperties properties={properties} circularRefs={circularRefs} context={context} />;
41
+ if (alternatives?.schemas) return /* @__PURE__ */ jsx(OpenAPISchemaAlternatives, {
42
+ alternatives,
43
+ schema,
44
+ circularRefs,
45
+ context,
46
+ parentDiscriminator: discriminator,
47
+ parentDiscriminatorValue: discriminatorValue
48
+ });
49
+ if (properties?.length) return /* @__PURE__ */ jsx(OpenAPISchemaProperties, {
50
+ properties,
51
+ circularRefs,
52
+ context
53
+ });
34
54
  return null;
35
55
  })();
36
- if (properties?.length) return <OpenAPIDisclosure icon={context.icons.plus} header={header} label={(isExpanded) => getDisclosureLabel({
37
- schema,
38
- isExpanded,
39
- context
40
- })}>
41
- {content}
42
- </OpenAPIDisclosure>;
43
- return <div id={id} {...rest} className={clsx("openapi-schema", className)}>
44
- {header}
45
- {content}
46
- </div>;
56
+ if (properties?.length) return /* @__PURE__ */ jsx(OpenAPIDisclosure, {
57
+ icon: context.icons.plus,
58
+ header,
59
+ label: (isExpanded) => getDisclosureLabel({
60
+ schema,
61
+ isExpanded,
62
+ context
63
+ }),
64
+ children: content
65
+ });
66
+ return /* @__PURE__ */ jsxs("div", {
67
+ id,
68
+ ...rest,
69
+ className: clsx("openapi-schema", className),
70
+ children: [header, content]
71
+ });
47
72
  }
48
73
  /**
49
74
  * Render a set of properties of an OpenAPI schema.
50
75
  */
51
76
  function OpenAPISchemaProperties(props) {
52
77
  const { id, properties, circularRefs = /* @__PURE__ */ new Map(), context } = props;
53
- return <div id={id} className="openapi-schema-properties">
54
- {properties.map((property, index) => {
55
- return <OpenAPISchemaProperty key={index} circularRefs={circularRefs} property={property} context={context} style={{ animationDelay: `${index * .02}s` }} />;
56
- })}
57
- </div>;
78
+ return /* @__PURE__ */ jsx("div", {
79
+ id,
80
+ className: "openapi-schema-properties",
81
+ children: properties.map((property, index) => {
82
+ return /* @__PURE__ */ jsx(OpenAPISchemaProperty, {
83
+ circularRefs,
84
+ property,
85
+ context,
86
+ style: { animationDelay: `${index * .02}s` }
87
+ }, index);
88
+ })
89
+ });
58
90
  }
59
91
  function OpenAPISchemaPropertiesFromServer(props) {
60
- return <OpenAPISchemaProperties id={props.id} properties={JSON.parse(props.properties, retrocycle())} context={props.context} />;
92
+ return /* @__PURE__ */ jsx(OpenAPISchemaProperties, {
93
+ id: props.id,
94
+ properties: JSON.parse(props.properties, retrocycle()),
95
+ context: props.context
96
+ });
61
97
  }
62
98
  /**
63
99
  * Render a root schema (such as the request body or response body).
@@ -70,18 +106,35 @@ function OpenAPIRootSchema(props) {
70
106
  const alternatives = getSchemaAlternatives(schema, new Set(parentCircularRefs.keys()));
71
107
  const circularRefs = new Map(parentCircularRefs);
72
108
  circularRefs.set(schema, id);
73
- if (alternatives?.schemas) return <>
74
- {description ? <Markdown source={description} className="openapi-schema-root-description" /> : null}
75
- <OpenAPISchemaAlternatives alternatives={alternatives} schema={schema} circularRefs={circularRefs} context={context} />
76
- </>;
77
- if (properties?.length) return <>
78
- {description ? <Markdown source={description} className="openapi-schema-root-description" /> : null}
79
- <OpenAPISchemaProperties properties={properties} circularRefs={circularRefs} context={context} />
80
- </>;
81
- return <OpenAPISchemaProperty className="openapi-schema-root" property={{ schema }} context={context} circularRefs={parentCircularRefs} />;
109
+ if (alternatives?.schemas) return /* @__PURE__ */ jsxs(Fragment$1, { children: [description ? /* @__PURE__ */ jsx(Markdown, {
110
+ source: description,
111
+ className: "openapi-schema-root-description"
112
+ }) : null, /* @__PURE__ */ jsx(OpenAPISchemaAlternatives, {
113
+ alternatives,
114
+ schema,
115
+ circularRefs,
116
+ context
117
+ })] });
118
+ if (properties?.length) return /* @__PURE__ */ jsxs(Fragment$1, { children: [description ? /* @__PURE__ */ jsx(Markdown, {
119
+ source: description,
120
+ className: "openapi-schema-root-description"
121
+ }) : null, /* @__PURE__ */ jsx(OpenAPISchemaProperties, {
122
+ properties,
123
+ circularRefs,
124
+ context
125
+ })] });
126
+ return /* @__PURE__ */ jsx(OpenAPISchemaProperty, {
127
+ className: "openapi-schema-root",
128
+ property: { schema },
129
+ context,
130
+ circularRefs: parentCircularRefs
131
+ });
82
132
  }
83
133
  function OpenAPIRootSchemaFromServer(props) {
84
- return <OpenAPIRootSchema schema={JSON.parse(props.schema, retrocycle())} context={props.context} />;
134
+ return /* @__PURE__ */ jsx(OpenAPIRootSchema, {
135
+ schema: JSON.parse(props.schema, retrocycle()),
136
+ context: props.context
137
+ });
85
138
  }
86
139
  /**
87
140
  * Get the discriminator value for a schema.
@@ -109,16 +162,24 @@ function OpenAPISchemaAlternatives(props) {
109
162
  const { alternatives, schema, circularRefs, context, parentDiscriminator, parentDiscriminatorValue } = props;
110
163
  if (!alternatives?.schemas) return null;
111
164
  const { schemas, discriminator: alternativeDiscriminator, type } = alternatives;
112
- return <div className="openapi-schema-alternatives">
113
- {schemas.map((alternativeSchema, index) => {
114
- const effectiveDiscriminator = alternativeDiscriminator || (type === "allOf" ? parentDiscriminator : void 0);
115
- const effectiveDiscriminatorValue = !alternativeDiscriminator && type === "allOf" ? parentDiscriminatorValue : void 0;
116
- return <div key={index} className="openapi-schema-alternative">
117
- <OpenAPISchemaAlternative schema={alternativeSchema} discriminator={effectiveDiscriminator} discriminatorValue={effectiveDiscriminatorValue} circularRefs={circularRefs} context={context} />
118
- {index < schemas.length - 1 ? <OpenAPISchemaAlternativeSeparator schema={schema} context={context} /> : null}
119
- </div>;
120
- })}
121
- </div>;
165
+ return /* @__PURE__ */ jsx("div", {
166
+ className: "openapi-schema-alternatives",
167
+ children: schemas.map((alternativeSchema, index) => {
168
+ return /* @__PURE__ */ jsxs("div", {
169
+ className: "openapi-schema-alternative",
170
+ children: [/* @__PURE__ */ jsx(OpenAPISchemaAlternative, {
171
+ schema: alternativeSchema,
172
+ discriminator: alternativeDiscriminator || (type === "allOf" ? parentDiscriminator : void 0),
173
+ discriminatorValue: !alternativeDiscriminator && type === "allOf" ? parentDiscriminatorValue : void 0,
174
+ circularRefs,
175
+ context
176
+ }), index < schemas.length - 1 ? /* @__PURE__ */ jsx(OpenAPISchemaAlternativeSeparator, {
177
+ schema,
178
+ context
179
+ }) : null]
180
+ }, index);
181
+ })
182
+ });
122
183
  }
123
184
  /**
124
185
  * Render a tab for an alternative schema.
@@ -129,13 +190,29 @@ function OpenAPISchemaAlternative(props) {
129
190
  const { schema, discriminator, circularRefs, context } = props;
130
191
  const discriminatorValue = props.discriminatorValue || getDiscriminatorValue(schema, discriminator);
131
192
  const properties = getSchemaProperties(schema, discriminator, discriminatorValue);
132
- return properties?.length ? <OpenAPIDisclosure icon={context.icons.plus} header={<OpenAPISchemaPresentation property={{ schema }} context={context} />} label={(isExpanded) => getDisclosureLabel({
133
- schema,
134
- isExpanded,
193
+ return properties?.length ? /* @__PURE__ */ jsx(OpenAPIDisclosure, {
194
+ icon: context.icons.plus,
195
+ header: /* @__PURE__ */ jsx(OpenAPISchemaPresentation, {
196
+ property: { schema },
197
+ context
198
+ }),
199
+ label: (isExpanded) => getDisclosureLabel({
200
+ schema,
201
+ isExpanded,
202
+ context
203
+ }),
204
+ children: /* @__PURE__ */ jsx(OpenAPISchemaProperties, {
205
+ properties,
206
+ circularRefs,
207
+ context
208
+ })
209
+ }) : /* @__PURE__ */ jsx(OpenAPISchemaProperty, {
210
+ property: { schema },
211
+ discriminator,
212
+ discriminatorValue,
213
+ circularRefs,
135
214
  context
136
- })}>
137
- <OpenAPISchemaProperties properties={properties} circularRefs={circularRefs} context={context} />
138
- </OpenAPIDisclosure> : <OpenAPISchemaProperty property={{ schema }} discriminator={discriminator} discriminatorValue={discriminatorValue} circularRefs={circularRefs} context={context} />;
215
+ });
139
216
  }
140
217
  function OpenAPISchemaAlternativeSeparator(props) {
141
218
  const { schema, context } = props;
@@ -143,20 +220,31 @@ function OpenAPISchemaAlternativeSeparator(props) {
143
220
  const oneOf = schema.oneOf || schema.items?.oneOf;
144
221
  const allOf = schema.allOf || schema.items?.allOf;
145
222
  if (!anyOf && !oneOf && !allOf) return null;
146
- return <span className="openapi-schema-alternative-separator">
147
- {(anyOf || oneOf) && tString(context.translation, "or")}
148
- {allOf && tString(context.translation, "and")}
149
- </span>;
223
+ return /* @__PURE__ */ jsxs("span", {
224
+ className: "openapi-schema-alternative-separator",
225
+ children: [(anyOf || oneOf) && tString(context.translation, "or"), allOf && tString(context.translation, "and")]
226
+ });
150
227
  }
151
228
  /**
152
229
  * Render a circular reference to a schema.
153
230
  */
154
231
  function OpenAPISchemaCircularRef(props) {
155
232
  const { id, schema } = props;
156
- return <div className="openapi-schema-circular">
157
- <span className="openapi-schema-circular-glyph">⤷</span>
158
- Circular reference to <a href={`#${id}`}>{getSchemaTitle(schema)}</a>{" "}
159
- </div>;
233
+ return /* @__PURE__ */ jsxs("div", {
234
+ className: "openapi-schema-circular",
235
+ children: [
236
+ /* @__PURE__ */ jsx("span", {
237
+ className: "openapi-schema-circular-glyph",
238
+ children: "⤷"
239
+ }),
240
+ "Circular reference to ",
241
+ /* @__PURE__ */ jsx("a", {
242
+ href: `#${id}`,
243
+ children: getSchemaTitle(schema)
244
+ }),
245
+ " "
246
+ ]
247
+ });
160
248
  }
161
249
  /**
162
250
  * Render the enum value for a schema.
@@ -184,14 +272,24 @@ function OpenAPISchemaEnum(props) {
184
272
  });
185
273
  })();
186
274
  if (!enumValues?.length) return null;
187
- return <span className="openapi-schema-enum">
188
- {tString(context.translation, "possible_values")}:{" "}
189
- {enumValues.map((item, index) => <span key={index} className="openapi-schema-enum-value">
190
- <OpenAPICopyButton value={item.value} label={item.description} withTooltip={!!item.description} context={context}>
191
- <code>{`${item.value}`}</code>
192
- </OpenAPICopyButton>
193
- </span>)}
194
- </span>;
275
+ return /* @__PURE__ */ jsxs("span", {
276
+ className: "openapi-schema-enum",
277
+ children: [
278
+ tString(context.translation, "possible_values"),
279
+ ":",
280
+ " ",
281
+ enumValues.map((item, index) => /* @__PURE__ */ jsx("span", {
282
+ className: "openapi-schema-enum-value",
283
+ children: /* @__PURE__ */ jsx(OpenAPICopyButton, {
284
+ value: item.value,
285
+ label: item.description,
286
+ withTooltip: !!item.description,
287
+ context,
288
+ children: /* @__PURE__ */ jsx("code", { children: `${item.value}` })
289
+ })
290
+ }, index))
291
+ ]
292
+ });
195
293
  }
196
294
  /**
197
295
  * Render the top row of a schema. e.g: name, type, and required status.
@@ -200,31 +298,57 @@ function OpenAPISchemaPresentation(props) {
200
298
  const { id, property: { schema, propertyName, required, isDiscriminatorProperty }, circularRefId, context } = props;
201
299
  const description = resolveDescription(schema);
202
300
  const example = resolveFirstExample(schema);
203
- return <div id={id} className="openapi-schema-presentation">
204
- <OpenAPISchemaName schema={schema} type={getSchemaTitle(schema, { ignoreAlternatives: !propertyName })} propertyName={propertyName} isDiscriminatorProperty={isDiscriminatorProperty} required={required} context={context} />
205
- {circularRefId ? <OpenAPISchemaCircularRef id={circularRefId} schema={schema} /> : <>
206
- {typeof schema["x-deprecated-sunset"] === "string" ? <div className="openapi-deprecated-sunset openapi-schema-description openapi-markdown">
207
- Sunset date:{" "}
208
- <span className="openapi-deprecated-sunset-date">
209
- {schema["x-deprecated-sunset"]}
210
- </span>
211
- </div> : null}
212
- {description ? <Markdown source={description} className="openapi-schema-description" /> : null}
213
- {schema.default !== void 0 ? <span className="openapi-schema-default">
214
- Default:{" "}
215
- <code>
216
- {typeof schema.default === "string" && schema.default ? schema.default : stringifyOpenAPI(schema.default)}
217
- </code>
218
- </span> : null}
219
- {typeof example === "string" ? <span className="openapi-schema-example">
220
- Example: <code>{example}</code>
221
- </span> : null}
222
- {schema.pattern ? <span className="openapi-schema-pattern">
223
- Pattern: <code>{schema.pattern}</code>
224
- </span> : null}
225
- <OpenAPISchemaEnum schema={schema} context={context} />
226
- </>}
227
- </div>;
301
+ return /* @__PURE__ */ jsxs("div", {
302
+ id,
303
+ className: "openapi-schema-presentation",
304
+ children: [/* @__PURE__ */ jsx(OpenAPISchemaName, {
305
+ schema,
306
+ type: getSchemaTitle(schema, { ignoreAlternatives: !propertyName }),
307
+ propertyName,
308
+ isDiscriminatorProperty,
309
+ required,
310
+ context
311
+ }), circularRefId ? /* @__PURE__ */ jsx(OpenAPISchemaCircularRef, {
312
+ id: circularRefId,
313
+ schema
314
+ }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
315
+ typeof schema["x-deprecated-sunset"] === "string" ? /* @__PURE__ */ jsxs("div", {
316
+ className: "openapi-deprecated-sunset openapi-schema-description openapi-markdown",
317
+ children: [
318
+ "Sunset date:",
319
+ " ",
320
+ /* @__PURE__ */ jsx("span", {
321
+ className: "openapi-deprecated-sunset-date",
322
+ children: schema["x-deprecated-sunset"]
323
+ })
324
+ ]
325
+ }) : null,
326
+ description ? /* @__PURE__ */ jsx(Markdown, {
327
+ source: description,
328
+ className: "openapi-schema-description"
329
+ }) : null,
330
+ schema.default !== void 0 ? /* @__PURE__ */ jsxs("span", {
331
+ className: "openapi-schema-default",
332
+ children: [
333
+ "Default:",
334
+ " ",
335
+ /* @__PURE__ */ jsx("code", { children: typeof schema.default === "string" && schema.default ? schema.default : stringifyOpenAPI(schema.default) })
336
+ ]
337
+ }) : null,
338
+ typeof example === "string" ? /* @__PURE__ */ jsxs("span", {
339
+ className: "openapi-schema-example",
340
+ children: ["Example: ", /* @__PURE__ */ jsx("code", { children: example })]
341
+ }) : null,
342
+ schema.pattern ? /* @__PURE__ */ jsxs("span", {
343
+ className: "openapi-schema-pattern",
344
+ children: ["Pattern: ", /* @__PURE__ */ jsx("code", { children: schema.pattern })]
345
+ }) : null,
346
+ /* @__PURE__ */ jsx(OpenAPISchemaEnum, {
347
+ schema,
348
+ context
349
+ })
350
+ ] })]
351
+ });
228
352
  }
229
353
  /**
230
354
  * Process properties from a schema object into property entries.