@gitbook/react-openapi 1.5.4 → 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.
- package/CHANGELOG.md +13 -0
- package/dist/InteractiveSection.js +52 -30
- package/dist/Markdown.js +5 -1
- package/dist/OpenAPICodeSample.js +45 -9
- package/dist/OpenAPICodeSampleInteractive.js +41 -15
- package/dist/OpenAPICodeSampleSelector.js +34 -14
- package/dist/OpenAPICopyButton.js +21 -15
- package/dist/OpenAPIDisclosure.js +18 -10
- package/dist/OpenAPIDisclosureGroup.js +56 -30
- package/dist/OpenAPIExample.js +6 -4
- package/dist/OpenAPIMediaType.js +38 -17
- package/dist/OpenAPIOperation.d.ts +2 -2
- package/dist/OpenAPIOperation.js +26 -12
- package/dist/OpenAPIOperationContext.d.ts +2 -2
- package/dist/OpenAPIOperationContext.js +5 -3
- package/dist/OpenAPIPath.js +14 -5
- package/dist/OpenAPIPathItem.js +26 -12
- package/dist/OpenAPIPathMultipleServers.js +29 -12
- package/dist/OpenAPIPrefillContextProvider.d.ts +2 -1
- package/dist/OpenAPIPrefillContextProvider.js +5 -3
- package/dist/OpenAPIRequestBody.js +20 -10
- package/dist/OpenAPIRequestBodyHeaderType.js +5 -3
- package/dist/OpenAPIRequiredScopes.js +41 -26
- package/dist/OpenAPIResponse.js +34 -19
- package/dist/OpenAPIResponseExample.js +25 -8
- package/dist/OpenAPIResponseExampleContent.js +39 -18
- package/dist/OpenAPIResponses.js +40 -17
- package/dist/OpenAPISchema.js +212 -88
- package/dist/OpenAPISchemaName.js +44 -24
- package/dist/OpenAPISchemaServer.js +10 -2
- package/dist/OpenAPISecurities.js +125 -57
- package/dist/OpenAPISelect.js +27 -18
- package/dist/OpenAPISpec.js +27 -12
- package/dist/OpenAPITooltip.js +14 -6
- package/dist/OpenAPIWebhook.d.ts +2 -2
- package/dist/OpenAPIWebhook.js +23 -11
- package/dist/OpenAPIWebhookExample.js +18 -8
- package/dist/ScalarApiButton.js +50 -29
- package/dist/StaticSection.js +49 -15
- package/dist/common/OpenAPIColumnSpec.js +21 -9
- package/dist/common/OpenAPIOperationDescription.js +12 -6
- package/dist/common/OpenAPIStability.js +6 -3
- package/dist/common/OpenAPISummary.js +23 -12
- package/dist/formatPath.js +7 -4
- package/dist/schemas/OpenAPISchemaItem.js +18 -11
- package/dist/schemas/OpenAPISchemas.d.ts +2 -2
- package/dist/schemas/OpenAPISchemas.js +55 -31
- package/dist/translate.js +4 -6
- package/dist/util/example.js +6 -1
- package/package.json +3 -3
package/dist/OpenAPIMediaType.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { OpenAPIEmptyExample } from "./OpenAPIExample.js";
|
|
5
5
|
import { StaticSection } from "./StaticSection.js";
|
|
6
6
|
import { OpenAPISelect, OpenAPISelectItem, useSelectState } from "./OpenAPISelect.js";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
|
|
8
9
|
//#region src/OpenAPIMediaType.tsx
|
|
9
10
|
/**
|
|
@@ -20,25 +21,45 @@ function OpenAPIMediaTypeContent(props) {
|
|
|
20
21
|
const state = useMediaTypesState(stateKey, items[0]?.key);
|
|
21
22
|
const examples = items.find((item) => item.key === state.key)?.examples ?? [];
|
|
22
23
|
if (!items.length && !examples.length) return null;
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
return /* @__PURE__ */ jsx(StaticSection, {
|
|
25
|
+
footer: items.length > 1 || examples.length > 1 ? /* @__PURE__ */ jsx(OpenAPIMediaTypeFooter, {
|
|
26
|
+
items,
|
|
27
|
+
examples,
|
|
28
|
+
selectIcon,
|
|
29
|
+
stateKey
|
|
30
|
+
}) : null,
|
|
31
|
+
className: "openapi-response-media-types-examples",
|
|
32
|
+
children: /* @__PURE__ */ jsx(OpenAPIMediaTypeBody, {
|
|
33
|
+
context,
|
|
34
|
+
stateKey,
|
|
35
|
+
items,
|
|
36
|
+
examples
|
|
37
|
+
})
|
|
38
|
+
});
|
|
26
39
|
}
|
|
27
40
|
function OpenAPIMediaTypeFooter(props) {
|
|
28
41
|
const { items, examples, stateKey, selectIcon } = props;
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [items.length > 1 && /* @__PURE__ */ jsx(OpenAPISelect, {
|
|
43
|
+
icon: selectIcon,
|
|
44
|
+
items,
|
|
45
|
+
stateKey,
|
|
46
|
+
placement: "bottom start",
|
|
47
|
+
children: items.map((item) => /* @__PURE__ */ jsx(OpenAPISelectItem, {
|
|
48
|
+
id: item.key,
|
|
49
|
+
value: item,
|
|
50
|
+
children: /* @__PURE__ */ jsx("span", { children: item.label })
|
|
51
|
+
}, item.key))
|
|
52
|
+
}), examples && examples.length > 1 ? /* @__PURE__ */ jsx(OpenAPISelect, {
|
|
53
|
+
icon: selectIcon,
|
|
54
|
+
items: examples,
|
|
55
|
+
stateKey: `${stateKey}-examples`,
|
|
56
|
+
placement: "bottom start",
|
|
57
|
+
children: examples.map((example) => /* @__PURE__ */ jsx(OpenAPISelectItem, {
|
|
58
|
+
id: example.key,
|
|
59
|
+
value: example,
|
|
60
|
+
children: /* @__PURE__ */ jsx("span", { children: example.label })
|
|
61
|
+
}, example.key))
|
|
62
|
+
}) : null] });
|
|
42
63
|
}
|
|
43
64
|
function OpenAPIMediaTypeBody(props) {
|
|
44
65
|
const { stateKey, items, examples, context } = props;
|
|
@@ -48,7 +69,7 @@ function OpenAPIMediaTypeBody(props) {
|
|
|
48
69
|
if (!selectedItem) return null;
|
|
49
70
|
if (examples) {
|
|
50
71
|
const selectedExample = examples.find((example) => example.key === exampleState.key) ?? examples[0];
|
|
51
|
-
if (!selectedExample) return
|
|
72
|
+
if (!selectedExample) return /* @__PURE__ */ jsx(OpenAPIEmptyExample, { context });
|
|
52
73
|
return selectedExample.body;
|
|
53
74
|
}
|
|
54
75
|
return selectedItem.body;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OpenAPIContextInput } from "./context.js";
|
|
2
2
|
import { OpenAPIOperationData } from "./types.js";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/OpenAPIOperation.d.ts
|
|
6
6
|
/**
|
|
@@ -10,6 +10,6 @@ declare function OpenAPIOperation(props: {
|
|
|
10
10
|
className?: string;
|
|
11
11
|
data: OpenAPIOperationData;
|
|
12
12
|
context: OpenAPIContextInput;
|
|
13
|
-
}):
|
|
13
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { OpenAPIOperation };
|
package/dist/OpenAPIOperation.js
CHANGED
|
@@ -4,6 +4,7 @@ import { OpenAPIResponseExample } from "./OpenAPIResponseExample.js";
|
|
|
4
4
|
import { OpenAPIColumnSpec } from "./common/OpenAPIColumnSpec.js";
|
|
5
5
|
import { OpenAPISummary } from "./common/OpenAPISummary.js";
|
|
6
6
|
import clsx from "classnames";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
|
|
8
9
|
//#region src/OpenAPIOperation.tsx
|
|
9
10
|
/**
|
|
@@ -12,18 +13,31 @@ import clsx from "classnames";
|
|
|
12
13
|
function OpenAPIOperation(props) {
|
|
13
14
|
const { className, data, context: contextInput } = props;
|
|
14
15
|
const context = resolveOpenAPIContext(contextInput);
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
17
|
+
className: clsx("openapi-operation", className),
|
|
18
|
+
children: [/* @__PURE__ */ jsx(OpenAPISummary, {
|
|
19
|
+
data,
|
|
20
|
+
context
|
|
21
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
22
|
+
className: "openapi-columns",
|
|
23
|
+
children: [/* @__PURE__ */ jsx(OpenAPIColumnSpec, {
|
|
24
|
+
data,
|
|
25
|
+
context
|
|
26
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
27
|
+
className: "openapi-column-preview",
|
|
28
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
29
|
+
className: "openapi-column-preview-body",
|
|
30
|
+
children: [/* @__PURE__ */ jsx(OpenAPICodeSample, {
|
|
31
|
+
data,
|
|
32
|
+
context
|
|
33
|
+
}), /* @__PURE__ */ jsx(OpenAPIResponseExample, {
|
|
34
|
+
data,
|
|
35
|
+
context
|
|
36
|
+
})]
|
|
37
|
+
})
|
|
38
|
+
})]
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
27
41
|
}
|
|
28
42
|
|
|
29
43
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/OpenAPIOperationContext.d.ts
|
|
4
4
|
interface OpenAPIOperationPointer {
|
|
@@ -11,7 +11,7 @@ interface OpenAPIOperationContextValue {
|
|
|
11
11
|
/**
|
|
12
12
|
* Provider for the OpenAPIOperationContext.
|
|
13
13
|
*/
|
|
14
|
-
declare function OpenAPIOperationContextProvider(props: React.PropsWithChildren<Partial<OpenAPIOperationContextValue>>):
|
|
14
|
+
declare function OpenAPIOperationContextProvider(props: React.PropsWithChildren<Partial<OpenAPIOperationContextValue>>): react_jsx_runtime1.JSX.Element;
|
|
15
15
|
/**
|
|
16
16
|
* Hook to access the OpenAPIOperationContext.
|
|
17
17
|
*/
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
import { createContext, useContext, useMemo } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
import { useEventCallback } from "usehooks-ts";
|
|
6
7
|
|
|
7
8
|
//#region src/OpenAPIOperationContext.tsx
|
|
@@ -15,9 +16,10 @@ function OpenAPIOperationContextProvider(props) {
|
|
|
15
16
|
props.onOpenClient?.(pointer);
|
|
16
17
|
});
|
|
17
18
|
const value = useMemo(() => ({ onOpenClient }), [onOpenClient]);
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
return /* @__PURE__ */ jsx(OpenAPIOperationContext.Provider, {
|
|
20
|
+
value,
|
|
21
|
+
children
|
|
22
|
+
});
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* Hook to access the OpenAPIOperationContext.
|
package/dist/OpenAPIPath.js
CHANGED
|
@@ -3,6 +3,7 @@ import { OpenAPIPathItem } from "./OpenAPIPathItem.js";
|
|
|
3
3
|
import { formatPath } from "./formatPath.js";
|
|
4
4
|
import { getDefaultServerURL } from "./util/server.js";
|
|
5
5
|
import { OpenAPIPathMultipleServers } from "./OpenAPIPathMultipleServers.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
|
|
7
8
|
//#region src/OpenAPIPath.tsx
|
|
8
9
|
/**
|
|
@@ -12,13 +13,21 @@ function OpenAPIPath(props) {
|
|
|
12
13
|
const { data, withServer = true, context } = props;
|
|
13
14
|
const { path } = data;
|
|
14
15
|
const clientContext = getOpenAPIClientContext(context);
|
|
15
|
-
if (withServer && data.servers.length > 1) return
|
|
16
|
+
if (withServer && data.servers.length > 1) return /* @__PURE__ */ jsx(OpenAPIPathMultipleServers, {
|
|
17
|
+
...props,
|
|
18
|
+
context: clientContext
|
|
19
|
+
});
|
|
16
20
|
const formattedPath = formatPath(path);
|
|
17
21
|
const defaultServer = getDefaultServerURL(data.servers);
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
return /* @__PURE__ */ jsxs(OpenAPIPathItem, {
|
|
23
|
+
...props,
|
|
24
|
+
value: `${defaultServer}${path}`,
|
|
25
|
+
context: clientContext,
|
|
26
|
+
children: [withServer ? /* @__PURE__ */ jsx("span", {
|
|
27
|
+
className: "openapi-path-server",
|
|
28
|
+
children: defaultServer
|
|
29
|
+
}) : null, formattedPath]
|
|
30
|
+
});
|
|
22
31
|
}
|
|
23
32
|
|
|
24
33
|
//#endregion
|
package/dist/OpenAPIPathItem.js
CHANGED
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
import { OpenAPICopyButton } from "./OpenAPICopyButton.js";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
3
|
|
|
3
4
|
//#region src/OpenAPIPathItem.tsx
|
|
4
5
|
function OpenAPIPathItem(props) {
|
|
5
6
|
const { value, canCopy = true, context, children, data, copyType = "children" } = props;
|
|
6
7
|
const { operation, method } = data;
|
|
7
|
-
const title =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
const title = /* @__PURE__ */ jsx("span", {
|
|
9
|
+
className: "openapi-path-title",
|
|
10
|
+
children
|
|
11
|
+
});
|
|
12
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
13
|
+
className: "openapi-path",
|
|
14
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
15
|
+
className: `openapi-method openapi-method-${method}`,
|
|
16
|
+
children: method
|
|
17
|
+
}), canCopy && value ? copyType === "children" ? /* @__PURE__ */ jsx(OpenAPICopyButton, {
|
|
18
|
+
value,
|
|
19
|
+
"data-deprecated": operation.deprecated,
|
|
20
|
+
isDisabled: !canCopy,
|
|
21
|
+
context,
|
|
22
|
+
className: "openapi-path-copy-button",
|
|
23
|
+
children: title
|
|
24
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [title, /* @__PURE__ */ jsx(OpenAPICopyButton, {
|
|
25
|
+
value,
|
|
26
|
+
"data-deprecated": operation.deprecated,
|
|
27
|
+
isDisabled: !canCopy,
|
|
28
|
+
context,
|
|
29
|
+
className: "openapi-path-copy-button openapi-path-copy-button-icon",
|
|
30
|
+
children: context.icons.copy
|
|
31
|
+
})] }) : title]
|
|
32
|
+
});
|
|
19
33
|
}
|
|
20
34
|
|
|
21
35
|
//#endregion
|
|
@@ -7,6 +7,7 @@ import { OpenAPISelect, OpenAPISelectItem, useSelectState } from "./OpenAPISelec
|
|
|
7
7
|
import { OpenAPIPathItem } from "./OpenAPIPathItem.js";
|
|
8
8
|
import { formatPath } from "./formatPath.js";
|
|
9
9
|
import { getDefaultServerURL } from "./util/server.js";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
11
|
import { Text } from "react-aria-components";
|
|
11
12
|
|
|
12
13
|
//#region src/OpenAPIPathMultipleServers.tsx
|
|
@@ -25,18 +26,34 @@ function OpenAPIPathMultipleServers(props) {
|
|
|
25
26
|
label: server.url,
|
|
26
27
|
description: server.description
|
|
27
28
|
}));
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
return /* @__PURE__ */ jsxs(OpenAPIPathItem, {
|
|
30
|
+
copyType: "button",
|
|
31
|
+
...props,
|
|
32
|
+
value: `${withServer ? key : ""}${path}`,
|
|
33
|
+
context,
|
|
34
|
+
children: [withServer ? /* @__PURE__ */ jsxs(OpenAPITooltip, { children: [/* @__PURE__ */ jsx(OpenAPISelect, {
|
|
35
|
+
className: "openapi-select openapi-select-unstyled",
|
|
36
|
+
items,
|
|
37
|
+
stateKey: serversStateKey,
|
|
38
|
+
placement: "bottom start",
|
|
39
|
+
icon: context.icons.chevronDown,
|
|
40
|
+
defaultValue: defaultServer,
|
|
41
|
+
onChange: setKey,
|
|
42
|
+
children: items.map((item) => /* @__PURE__ */ jsxs(OpenAPISelectItem, {
|
|
43
|
+
textValue: item.label,
|
|
44
|
+
id: item.key,
|
|
45
|
+
value: item,
|
|
46
|
+
className: "openapi-select-item-column",
|
|
47
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
48
|
+
slot: "label",
|
|
49
|
+
children: item.label
|
|
50
|
+
}), item.description ? /* @__PURE__ */ jsx(Text, {
|
|
51
|
+
slot: "description",
|
|
52
|
+
children: item.description
|
|
53
|
+
}) : null]
|
|
54
|
+
}, item.key))
|
|
55
|
+
}), /* @__PURE__ */ jsx(OpenAPITooltip.Content, { children: "Click to select a server" })] }) : null, formattedPath]
|
|
56
|
+
});
|
|
40
57
|
}
|
|
41
58
|
|
|
42
59
|
//#endregion
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React$1 from "react";
|
|
2
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
2
3
|
|
|
3
4
|
//#region src/OpenAPIPrefillContextProvider.d.ts
|
|
4
5
|
|
|
@@ -17,7 +18,7 @@ type PrefillContextValue = () => PrefillInputContextData | null;
|
|
|
17
18
|
*/
|
|
18
19
|
declare function OpenAPIPrefillContextProvider(props: React$1.PropsWithChildren<{
|
|
19
20
|
getPrefillInputContextData: () => PrefillInputContextData | null;
|
|
20
|
-
}>):
|
|
21
|
+
}>): react_jsx_runtime2.JSX.Element;
|
|
21
22
|
/**
|
|
22
23
|
* Hook to access the prefill context function.
|
|
23
24
|
*/
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
import * as React$1 from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
|
|
6
7
|
//#region src/OpenAPIPrefillContextProvider.tsx
|
|
7
8
|
const OpenAPIPrefillContext = React$1.createContext(null);
|
|
@@ -10,9 +11,10 @@ const OpenAPIPrefillContext = React$1.createContext(null);
|
|
|
10
11
|
*/
|
|
11
12
|
function OpenAPIPrefillContextProvider(props) {
|
|
12
13
|
const { getPrefillInputContextData, children } = props;
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
return /* @__PURE__ */ jsx(OpenAPIPrefillContext.Provider, {
|
|
15
|
+
value: getPrefillInputContextData,
|
|
16
|
+
children
|
|
17
|
+
});
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* Hook to access the prefill context function.
|
|
@@ -3,6 +3,7 @@ import { checkIsReference, createStateKey } from "./utils.js";
|
|
|
3
3
|
import { OpenAPIRootSchema } from "./OpenAPISchemaServer.js";
|
|
4
4
|
import { InteractiveSection } from "./InteractiveSection.js";
|
|
5
5
|
import { OpenAPIRequestBodyHeaderType } from "./OpenAPIRequestBodyHeaderType.js";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
|
|
7
8
|
//#region src/OpenAPIRequestBody.tsx
|
|
8
9
|
/**
|
|
@@ -12,16 +13,25 @@ function OpenAPIRequestBody(props) {
|
|
|
12
13
|
const { requestBody, context, data } = props;
|
|
13
14
|
if (checkIsReference(requestBody)) return null;
|
|
14
15
|
const stateKey = createStateKey("request-body-media-type", context.blockKey);
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
16
|
+
return /* @__PURE__ */ jsx(InteractiveSection, {
|
|
17
|
+
header: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", { children: t(context.translation, "name" in data ? "payload" : "body") }), /* @__PURE__ */ jsx(OpenAPIRequestBodyHeaderType, {
|
|
18
|
+
requestBody,
|
|
19
|
+
stateKey
|
|
20
|
+
})] }),
|
|
21
|
+
className: "openapi-requestbody",
|
|
22
|
+
stateKey,
|
|
23
|
+
selectIcon: context.icons.chevronDown,
|
|
24
|
+
tabs: Object.entries(requestBody.content ?? {}).map(([contentType, mediaTypeObject]) => {
|
|
25
|
+
return {
|
|
26
|
+
key: contentType,
|
|
27
|
+
label: contentType,
|
|
28
|
+
body: /* @__PURE__ */ jsx(OpenAPIRootSchema, {
|
|
29
|
+
schema: mediaTypeObject.schema ?? {},
|
|
30
|
+
context
|
|
31
|
+
}, contentType)
|
|
32
|
+
};
|
|
33
|
+
})
|
|
34
|
+
});
|
|
25
35
|
}
|
|
26
36
|
|
|
27
37
|
//#endregion
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { getSchemaTitle } from "./utils.js";
|
|
5
5
|
import { useSelectState } from "./OpenAPISelect.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
7
|
|
|
7
8
|
//#region src/OpenAPIRequestBodyHeaderType.tsx
|
|
8
9
|
/**
|
|
@@ -14,9 +15,10 @@ function OpenAPIRequestBodyHeaderType(props) {
|
|
|
14
15
|
const state = useSelectState(stateKey, Object.keys(content)[0]);
|
|
15
16
|
const selectedContentMediaType = Object.entries(content).find(([contentType]) => contentType === state.key)?.[1];
|
|
16
17
|
if (!selectedContentMediaType || !selectedContentMediaType.schema?.type || selectedContentMediaType.schema.type !== "array") return null;
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
return /* @__PURE__ */ jsx("span", {
|
|
19
|
+
className: "openapi-requestbody-header-type",
|
|
20
|
+
children: `${getSchemaTitle(selectedContentMediaType.schema)}`
|
|
21
|
+
});
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
//#endregion
|
|
@@ -5,6 +5,7 @@ import { t } from "./translate.js";
|
|
|
5
5
|
import { OpenAPICopyButton } from "./OpenAPICopyButton.js";
|
|
6
6
|
import { useSelectState } from "./OpenAPISelect.js";
|
|
7
7
|
import { OpenAPIDisclosureGroup } from "./OpenAPIDisclosureGroup.js";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
9
|
|
|
9
10
|
//#region src/OpenAPIRequiredScopes.tsx
|
|
10
11
|
/**
|
|
@@ -19,48 +20,62 @@ function OpenAPIRequiredScopes(props) {
|
|
|
19
20
|
return scheme.scopes ?? [];
|
|
20
21
|
});
|
|
21
22
|
if (!scopes.length) return null;
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
return /* @__PURE__ */ jsx(OpenAPIDisclosureGroup, {
|
|
24
|
+
className: "openapi-required-scopes",
|
|
25
|
+
icon: context.icons.chevronRight,
|
|
26
|
+
stateKey: "required-scopes",
|
|
27
|
+
defaultExpandedKeys: ["required-scopes"],
|
|
28
|
+
groups: [{
|
|
29
|
+
key: "required-scopes",
|
|
30
|
+
label: /* @__PURE__ */ jsxs("div", {
|
|
31
|
+
className: "openapi-required-scopes-header",
|
|
32
|
+
children: [context.icons.lock, /* @__PURE__ */ jsx("span", { children: t(context.translation, "required_scopes") })]
|
|
33
|
+
}),
|
|
34
|
+
tabs: [{
|
|
35
|
+
key: "scopes",
|
|
36
|
+
label: "",
|
|
37
|
+
body: /* @__PURE__ */ jsx(OpenAPISchemaScopes, {
|
|
38
|
+
scopes,
|
|
39
|
+
context
|
|
40
|
+
})
|
|
41
|
+
}]
|
|
32
42
|
}]
|
|
33
|
-
}
|
|
43
|
+
});
|
|
34
44
|
}
|
|
35
45
|
function OpenAPISchemaScopes(props) {
|
|
36
46
|
const { scopes, context, isOAuth2 } = props;
|
|
37
|
-
return
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
48
|
+
className: "openapi-securities-scopes openapi-markdown",
|
|
49
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
50
|
+
className: "openapi-required-scopes-description",
|
|
51
|
+
children: t(context.translation, isOAuth2 ? "available_scopes" : "required_scopes_description")
|
|
52
|
+
}), /* @__PURE__ */ jsx("ul", { children: scopes.map((scope) => /* @__PURE__ */ jsx(OpenAPIScopeItem, {
|
|
53
|
+
scope,
|
|
54
|
+
context
|
|
55
|
+
}, scope[0])) })]
|
|
56
|
+
});
|
|
45
57
|
}
|
|
46
58
|
/**
|
|
47
59
|
* Display a scope item. Either a key-value pair or a single string.
|
|
48
60
|
*/
|
|
49
61
|
function OpenAPIScopeItem(props) {
|
|
50
62
|
const { scope, context } = props;
|
|
51
|
-
return
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
return /* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsx(OpenAPIScopeItemKey, {
|
|
64
|
+
name: scope[0],
|
|
65
|
+
context
|
|
66
|
+
}), scope[1] ? /* @__PURE__ */ jsxs("span", { children: [": ", scope[1]] }) : null] });
|
|
55
67
|
}
|
|
56
68
|
/**
|
|
57
69
|
* Displays the scope name within a copyable button.
|
|
58
70
|
*/
|
|
59
71
|
function OpenAPIScopeItemKey(props) {
|
|
60
72
|
const { name, context } = props;
|
|
61
|
-
return
|
|
62
|
-
|
|
63
|
-
|
|
73
|
+
return /* @__PURE__ */ jsx(OpenAPICopyButton, {
|
|
74
|
+
value: name,
|
|
75
|
+
context,
|
|
76
|
+
withTooltip: true,
|
|
77
|
+
children: /* @__PURE__ */ jsx("code", { children: name })
|
|
78
|
+
});
|
|
64
79
|
}
|
|
65
80
|
|
|
66
81
|
//#endregion
|
package/dist/OpenAPIResponse.js
CHANGED
|
@@ -3,6 +3,7 @@ import { OpenAPIDisclosure } from "./OpenAPIDisclosure.js";
|
|
|
3
3
|
import { parameterToProperty, resolveDescription } from "./utils.js";
|
|
4
4
|
import { OpenAPISchemaPresentation } from "./OpenAPISchema.js";
|
|
5
5
|
import { OpenAPISchemaProperties } from "./OpenAPISchemaServer.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
|
|
7
8
|
//#region src/OpenAPIResponse.tsx
|
|
8
9
|
/**
|
|
@@ -14,25 +15,39 @@ function OpenAPIResponse(props) {
|
|
|
14
15
|
const content = Object.entries(mediaType?.schema ?? {});
|
|
15
16
|
const description = resolveDescription(response);
|
|
16
17
|
if (content.length === 0 && !description && headers.length === 0) return null;
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
18
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
19
|
+
className: "openapi-response-body",
|
|
20
|
+
children: [headers.length > 0 ? /* @__PURE__ */ jsx(OpenAPIDisclosure, {
|
|
21
|
+
header: /* @__PURE__ */ jsx(OpenAPISchemaPresentation, {
|
|
22
|
+
context,
|
|
23
|
+
property: {
|
|
24
|
+
propertyName: tString(context.translation, "headers"),
|
|
25
|
+
schema: { type: "object" },
|
|
26
|
+
required: null
|
|
27
|
+
}
|
|
28
|
+
}),
|
|
29
|
+
icon: context.icons.plus,
|
|
30
|
+
label: (isExpanded) => tString(context.translation, isExpanded ? "hide" : "show", tString(context.translation, headers.length === 1 ? "header" : "headers")),
|
|
31
|
+
children: /* @__PURE__ */ jsx(OpenAPISchemaProperties, {
|
|
32
|
+
properties: headers.map(([name, header]) => parameterToProperty({
|
|
33
|
+
name,
|
|
34
|
+
...header
|
|
35
|
+
})),
|
|
36
|
+
context
|
|
37
|
+
})
|
|
38
|
+
}) : null, mediaType?.schema && /* @__PURE__ */ jsx("div", {
|
|
39
|
+
className: "openapi-responsebody",
|
|
40
|
+
children: /* @__PURE__ */ jsx(OpenAPISchemaProperties, {
|
|
41
|
+
id: `response-${context.blockKey}`,
|
|
42
|
+
properties: [{
|
|
43
|
+
schema: mediaType.schema,
|
|
44
|
+
propertyName: tString(context.translation, "response"),
|
|
45
|
+
required: null
|
|
46
|
+
}],
|
|
47
|
+
context
|
|
48
|
+
})
|
|
49
|
+
})]
|
|
50
|
+
});
|
|
36
51
|
}
|
|
37
52
|
|
|
38
53
|
//#endregion
|