@gitbook/react-openapi 1.1.9 → 1.2.0
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 +27 -0
- package/dist/InteractiveSection.d.ts +4 -0
- package/dist/InteractiveSection.jsx +14 -13
- package/dist/OpenAPICodeSample.d.ts +3 -2
- package/dist/OpenAPICodeSample.jsx +8 -12
- package/dist/OpenAPICodeSampleInteractive.d.ts +3 -0
- package/dist/OpenAPICodeSampleInteractive.jsx +37 -49
- package/dist/OpenAPICodeSampleSelector.d.ts +14 -0
- package/dist/OpenAPICodeSampleSelector.jsx +44 -0
- package/dist/OpenAPICopyButton.d.ts +2 -0
- package/dist/OpenAPICopyButton.jsx +5 -2
- package/dist/OpenAPIDisclosure.d.ts +4 -3
- package/dist/OpenAPIDisclosure.jsx +8 -11
- package/dist/OpenAPIDisclosureGroup.d.ts +7 -3
- package/dist/OpenAPIDisclosureGroup.jsx +18 -18
- package/dist/OpenAPIExample.d.ts +16 -0
- package/dist/OpenAPIExample.jsx +36 -0
- package/dist/OpenAPIMediaType.d.ts +21 -0
- package/dist/OpenAPIMediaType.jsx +61 -0
- package/dist/OpenAPIOperation.d.ts +3 -2
- package/dist/OpenAPIOperation.jsx +9 -72
- package/dist/OpenAPIOperationDescription.d.ts +9 -0
- package/dist/OpenAPIOperationDescription.jsx +22 -0
- package/dist/OpenAPIOperationStability.d.ts +9 -0
- package/dist/OpenAPIOperationStability.jsx +27 -0
- package/dist/OpenAPIPath.d.ts +12 -2
- package/dist/OpenAPIPath.jsx +10 -4
- package/dist/OpenAPIRequestBody.d.ts +3 -1
- package/dist/OpenAPIRequestBody.jsx +4 -3
- package/dist/OpenAPIResponse.d.ts +1 -1
- package/dist/OpenAPIResponse.jsx +1 -1
- package/dist/OpenAPIResponseExample.d.ts +4 -3
- package/dist/OpenAPIResponseExample.jsx +24 -154
- package/dist/OpenAPIResponseExampleContent.d.ts +19 -0
- package/dist/OpenAPIResponseExampleContent.jsx +57 -0
- package/dist/OpenAPIResponses.d.ts +1 -1
- package/dist/OpenAPIResponses.jsx +49 -36
- package/dist/OpenAPISchema.d.ts +1 -1
- package/dist/OpenAPISchema.jsx +121 -20
- package/dist/OpenAPISchemaName.d.ts +2 -0
- package/dist/OpenAPISchemaName.jsx +21 -17
- package/dist/OpenAPISchemaServer.d.ts +1 -1
- package/dist/OpenAPISecurities.d.ts +2 -1
- package/dist/OpenAPISecurities.jsx +11 -10
- package/dist/OpenAPISelect.d.ts +22 -0
- package/dist/OpenAPISelect.jsx +43 -0
- package/dist/OpenAPISpec.d.ts +3 -2
- package/dist/OpenAPISpec.jsx +11 -9
- package/dist/OpenAPITabs.jsx +9 -9
- package/dist/OpenAPIWebhook.d.ts +10 -0
- package/dist/OpenAPIWebhook.jsx +23 -0
- package/dist/OpenAPIWebhookExample.d.ts +6 -0
- package/dist/OpenAPIWebhookExample.jsx +41 -0
- package/dist/ScalarApiButton.d.ts +2 -0
- package/dist/ScalarApiButton.jsx +4 -3
- package/dist/StaticSection.d.ts +4 -1
- package/dist/StaticSection.jsx +13 -4
- package/dist/code-samples.js +57 -39
- package/dist/common/OpenAPIColumnSpec.d.ts +6 -0
- package/dist/common/OpenAPIColumnSpec.jsx +20 -0
- package/dist/common/OpenAPIOperationDescription.d.ts +6 -0
- package/dist/common/OpenAPIOperationDescription.jsx +19 -0
- package/dist/common/OpenAPIStability.d.ts +4 -0
- package/dist/common/OpenAPIStability.jsx +15 -0
- package/dist/common/OpenAPISummary.d.ts +6 -0
- package/dist/common/OpenAPISummary.jsx +30 -0
- package/dist/context.d.ts +75 -0
- package/dist/context.js +43 -0
- package/dist/generateSchemaExample.js +4 -0
- package/dist/getOrCreateStoreByKey.d.ts +10 -0
- package/dist/getOrCreateStoreByKey.js +19 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +3 -0
- package/dist/resolveOpenAPIOperation.js +10 -5
- package/dist/resolveOpenAPIWebhook.d.ts +11 -0
- package/dist/resolveOpenAPIWebhook.js +127 -0
- package/dist/schemas/OpenAPISchemas.d.ts +5 -6
- package/dist/schemas/OpenAPISchemas.jsx +52 -49
- package/dist/schemas/resolveOpenAPISchemas.d.ts +4 -3
- package/dist/schemas/resolveOpenAPISchemas.js +0 -1
- package/dist/stringifyOpenAPI.d.ts +1 -1
- package/dist/stringifyOpenAPI.js +6 -3
- package/dist/translate.d.ts +10 -0
- package/dist/translate.jsx +75 -0
- package/dist/translations/de.d.ts +37 -0
- package/dist/translations/de.js +37 -0
- package/dist/translations/en.d.ts +37 -0
- package/dist/translations/en.js +37 -0
- package/dist/translations/es.d.ts +37 -0
- package/dist/translations/es.js +37 -0
- package/dist/translations/fr.d.ts +37 -0
- package/dist/translations/fr.js +37 -0
- package/dist/translations/index.d.ts +341 -0
- package/dist/translations/index.js +27 -0
- package/dist/translations/ja.d.ts +37 -0
- package/dist/translations/ja.js +37 -0
- package/dist/translations/nl.d.ts +37 -0
- package/dist/translations/nl.js +37 -0
- package/dist/translations/no.d.ts +37 -0
- package/dist/translations/no.js +37 -0
- package/dist/translations/pt-br.d.ts +37 -0
- package/dist/translations/pt-br.js +37 -0
- package/dist/translations/types.d.ts +5 -0
- package/dist/translations/types.js +1 -0
- package/dist/translations/zh.d.ts +37 -0
- package/dist/translations/zh.js +37 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types.d.ts +12 -48
- package/dist/util/example.d.ts +35 -0
- package/dist/util/example.jsx +103 -0
- package/dist/utils.d.ts +18 -0
- package/dist/utils.js +57 -0
- package/package.json +3 -3
- package/src/InteractiveSection.tsx +22 -18
- package/src/OpenAPICodeSample.tsx +26 -15
- package/src/OpenAPICodeSampleInteractive.tsx +67 -70
- package/src/OpenAPICodeSampleSelector.tsx +94 -0
- package/src/OpenAPICopyButton.tsx +7 -2
- package/src/OpenAPIDisclosure.tsx +20 -22
- package/src/OpenAPIDisclosureGroup.tsx +40 -22
- package/src/OpenAPIExample.tsx +55 -0
- package/src/OpenAPIMediaType.tsx +139 -0
- package/src/OpenAPIOperation.tsx +11 -104
- package/src/OpenAPIOperationDescription.tsx +34 -0
- package/src/OpenAPIOperationStability.tsx +39 -0
- package/src/OpenAPIPath.tsx +26 -6
- package/src/OpenAPIRequestBody.tsx +9 -4
- package/src/OpenAPIResponse.tsx +2 -2
- package/src/OpenAPIResponseExample.tsx +41 -215
- package/src/OpenAPIResponseExampleContent.tsx +123 -0
- package/src/OpenAPIResponses.tsx +83 -62
- package/src/OpenAPISchema.test.ts +80 -0
- package/src/OpenAPISchema.tsx +149 -25
- package/src/OpenAPISchemaName.tsx +28 -19
- package/src/OpenAPISchemaServer.tsx +1 -1
- package/src/OpenAPISecurities.tsx +46 -12
- package/src/OpenAPISelect.tsx +96 -0
- package/src/OpenAPISpec.tsx +21 -10
- package/src/OpenAPITabs.tsx +9 -9
- package/src/OpenAPIWebhook.tsx +33 -0
- package/src/OpenAPIWebhookExample.tsx +60 -0
- package/src/ScalarApiButton.tsx +6 -6
- package/src/StaticSection.tsx +37 -5
- package/src/code-samples.test.ts +3 -1
- package/src/code-samples.ts +67 -54
- package/src/common/OpenAPIColumnSpec.tsx +31 -0
- package/src/common/OpenAPIOperationDescription.tsx +31 -0
- package/src/common/OpenAPIStability.tsx +23 -0
- package/src/common/OpenAPISummary.tsx +45 -0
- package/src/context.ts +99 -0
- package/src/generateSchemaExample.test.ts +1020 -0
- package/src/generateSchemaExample.ts +5 -0
- package/src/getOrCreateStoreByKey.ts +33 -0
- package/src/index.ts +5 -1
- package/src/resolveOpenAPIOperation.ts +14 -3
- package/src/resolveOpenAPIWebhook.ts +99 -0
- package/src/schemas/OpenAPISchemas.tsx +76 -71
- package/src/schemas/resolveOpenAPISchemas.ts +4 -5
- package/src/stringifyOpenAPI.ts +11 -3
- package/src/translate.tsx +80 -0
- package/src/translations/de.ts +37 -0
- package/src/translations/en.ts +37 -0
- package/src/translations/es.ts +37 -0
- package/src/translations/fr.ts +37 -0
- package/src/translations/index.ts +33 -0
- package/src/translations/ja.ts +37 -0
- package/src/translations/nl.ts +37 -0
- package/src/translations/no.ts +37 -0
- package/src/translations/pt-br.ts +37 -0
- package/src/translations/types.ts +7 -0
- package/src/translations/zh.ts +37 -0
- package/src/types.ts +11 -46
- package/src/util/example.tsx +129 -0
- package/src/utils.ts +67 -0
- package/dist/useSyncedTabsGlobalState.d.ts +0 -10
- package/dist/useSyncedTabsGlobalState.js +0 -20
- package/src/useSyncedTabsGlobalState.ts +0 -35
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { OpenAPISelect, OpenAPISelectItem, useSelectState } from './OpenAPISelect';
|
|
4
|
+
import { StaticSection } from './StaticSection';
|
|
5
|
+
import { createStateKey, getStatusCodeClassName } from './utils';
|
|
6
|
+
/**
|
|
7
|
+
* Get the state of the response examples select.
|
|
8
|
+
*/
|
|
9
|
+
export function useResponseExamplesState(blockKey, initialKey) {
|
|
10
|
+
if (initialKey === void 0) { initialKey = 'default'; }
|
|
11
|
+
return useSelectState(getResponseExampleStateKey(blockKey), initialKey);
|
|
12
|
+
}
|
|
13
|
+
export function OpenAPIResponseExampleContent(props) {
|
|
14
|
+
var blockKey = props.blockKey, items = props.items, selectIcon = props.selectIcon;
|
|
15
|
+
return (<StaticSection header={<OpenAPIResponseExampleHeader selectIcon={selectIcon} blockKey={blockKey} items={items}/>} className="openapi-response-examples">
|
|
16
|
+
<OpenAPIResponseExampleBody blockKey={blockKey} items={items}/>
|
|
17
|
+
</StaticSection>);
|
|
18
|
+
}
|
|
19
|
+
function OpenAPIResponseExampleHeader(props) {
|
|
20
|
+
var items = props.items, blockKey = props.blockKey, selectIcon = props.selectIcon;
|
|
21
|
+
if (items.length === 1) {
|
|
22
|
+
var item = items[0];
|
|
23
|
+
if (!item) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return (<span className="openapi-response-examples-statuscode-title">
|
|
27
|
+
<span className={clsx('openapi-statuscode', "openapi-statuscode-".concat(getStatusCodeClassName(item.statusCode)), 'openapi-response-examples-statuscode')}>
|
|
28
|
+
{item.statusCode}
|
|
29
|
+
</span>
|
|
30
|
+
<span>{item.label}</span>
|
|
31
|
+
</span>);
|
|
32
|
+
}
|
|
33
|
+
return (<OpenAPISelect items={items} icon={selectIcon} stateKey={getResponseExampleStateKey(blockKey)} placement="bottom start">
|
|
34
|
+
{items.map(function (item) { return (<OpenAPISelectItem key={item.key} id={item.key} value={item}>
|
|
35
|
+
<span className={clsx('openapi-statuscode', "openapi-statuscode-".concat(getStatusCodeClassName(item.statusCode)), 'openapi-response-examples-statuscode')}>
|
|
36
|
+
{item.statusCode}
|
|
37
|
+
</span>
|
|
38
|
+
<span>{item.label}</span>
|
|
39
|
+
</OpenAPISelectItem>); })}
|
|
40
|
+
</OpenAPISelect>);
|
|
41
|
+
}
|
|
42
|
+
function OpenAPIResponseExampleBody(props) {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
var blockKey = props.blockKey, items = props.items;
|
|
45
|
+
var state = useResponseExamplesState(blockKey, (_a = items[0]) === null || _a === void 0 ? void 0 : _a.key);
|
|
46
|
+
var selectedItem = (_b = items.find(function (item) { return item.key === state.key; })) !== null && _b !== void 0 ? _b : items[0];
|
|
47
|
+
if (!selectedItem) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return <div className="openapi-response-examples-panel">{selectedItem.body}</div>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Return the state key for the response examples.
|
|
54
|
+
*/
|
|
55
|
+
function getResponseExampleStateKey(blockKey) {
|
|
56
|
+
return createStateKey('openapi-responses', blockKey);
|
|
57
|
+
}
|
|
@@ -1,48 +1,61 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import clsx from 'clsx';
|
|
1
3
|
import { Markdown } from './Markdown';
|
|
2
4
|
import { OpenAPIDisclosureGroup } from './OpenAPIDisclosureGroup';
|
|
3
5
|
import { OpenAPIResponse } from './OpenAPIResponse';
|
|
6
|
+
import { useResponseExamplesState } from './OpenAPIResponseExampleContent';
|
|
4
7
|
import { StaticSection } from './StaticSection';
|
|
8
|
+
import { t } from './translate';
|
|
9
|
+
import { createStateKey, getStatusCodeClassName, getStatusCodeDefaultLabel } from './utils';
|
|
5
10
|
/**
|
|
6
11
|
* Display an interactive response body.
|
|
7
12
|
*/
|
|
8
13
|
export function OpenAPIResponses(props) {
|
|
14
|
+
var _a;
|
|
9
15
|
var responses = props.responses, context = props.context;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
});
|
|
16
|
+
var groups = Object.entries(responses).map(function (_a) {
|
|
17
|
+
var statusCode = _a[0], response = _a[1];
|
|
18
|
+
var tabs = (function () {
|
|
19
|
+
var _a;
|
|
20
|
+
// If there is no content, but there are headers, we need to show the headers
|
|
21
|
+
if ((!response.content || !Object.keys(response.content).length) &&
|
|
22
|
+
response.headers &&
|
|
23
|
+
Object.keys(response.headers).length) {
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
key: 'default',
|
|
27
|
+
label: '',
|
|
28
|
+
body: (<OpenAPIResponse response={response} mediaType={{}} context={context}/>),
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
return Object.entries((_a = response.content) !== null && _a !== void 0 ? _a : {}).map(function (_a) {
|
|
33
|
+
var contentType = _a[0], mediaType = _a[1];
|
|
34
|
+
return ({
|
|
35
|
+
key: contentType,
|
|
36
|
+
label: contentType,
|
|
37
|
+
body: (<OpenAPIResponse response={response} mediaType={mediaType} context={context}/>),
|
|
33
38
|
});
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
39
|
+
});
|
|
40
|
+
})();
|
|
41
|
+
var description = response.description;
|
|
42
|
+
return {
|
|
43
|
+
key: statusCode,
|
|
44
|
+
label: (<div className="openapi-response-tab-content">
|
|
45
|
+
<span className={clsx('openapi-statuscode', "openapi-statuscode-".concat(getStatusCodeClassName(statusCode)))}>
|
|
46
|
+
{statusCode}
|
|
47
|
+
</span>
|
|
48
|
+
{description ? (<Markdown source={description} className="openapi-response-description"/>) : (getStatusCodeDefaultLabel(statusCode, context))}
|
|
49
|
+
</div>),
|
|
50
|
+
tabs: tabs,
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
var state = useResponseExamplesState(context.blockKey, (_a = groups[0]) === null || _a === void 0 ? void 0 : _a.key);
|
|
54
|
+
return (<StaticSection header={t(context.translation, 'responses')} className="openapi-responses">
|
|
55
|
+
<OpenAPIDisclosureGroup icon={context.icons.chevronRight} expandedKeys={state.key ? new Set([state.key]) : new Set()} onExpandedChange={function (keys) {
|
|
56
|
+
var _a;
|
|
57
|
+
var key = (_a = keys.values().next().value) !== null && _a !== void 0 ? _a : null;
|
|
58
|
+
state.setKey(key);
|
|
59
|
+
}} groups={groups} selectStateKey={createStateKey('response-media-types', context.blockKey)}/>
|
|
47
60
|
</StaticSection>);
|
|
48
61
|
}
|
package/dist/OpenAPISchema.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from '@gitbook/openapi-parser';
|
|
2
|
-
import type { OpenAPIClientContext } from './
|
|
2
|
+
import type { OpenAPIClientContext } from './context';
|
|
3
3
|
export interface OpenAPISchemaPropertyEntry {
|
|
4
4
|
propertyName?: string | undefined;
|
|
5
5
|
required?: boolean | undefined;
|
package/dist/OpenAPISchema.jsx
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
2
22
|
import { useId } from 'react';
|
|
3
23
|
import clsx from 'clsx';
|
|
4
24
|
import { Markdown } from './Markdown';
|
|
@@ -6,6 +26,8 @@ import { OpenAPICopyButton } from './OpenAPICopyButton';
|
|
|
6
26
|
import { OpenAPIDisclosure } from './OpenAPIDisclosure';
|
|
7
27
|
import { OpenAPISchemaName } from './OpenAPISchemaName';
|
|
8
28
|
import { retrocycle } from './decycle';
|
|
29
|
+
import { stringifyOpenAPI } from './stringifyOpenAPI';
|
|
30
|
+
import { tString } from './translate';
|
|
9
31
|
import { checkIsReference, resolveDescription, resolveFirstExample } from './utils';
|
|
10
32
|
/**
|
|
11
33
|
* Render a property of an OpenAPI schema.
|
|
@@ -15,7 +37,7 @@ function OpenAPISchemaProperty(props) {
|
|
|
15
37
|
var schema = property.schema;
|
|
16
38
|
var id = useId();
|
|
17
39
|
return (<div id={id} className={clsx('openapi-schema', className)}>
|
|
18
|
-
<OpenAPISchemaPresentation property={property}/>
|
|
40
|
+
<OpenAPISchemaPresentation context={context} property={property}/>
|
|
19
41
|
{(function () {
|
|
20
42
|
var circularRefId = parentCircularRefs.get(schema);
|
|
21
43
|
// Avoid recursing infinitely, and instead render a link to the parent schema
|
|
@@ -26,7 +48,9 @@ function OpenAPISchemaProperty(props) {
|
|
|
26
48
|
circularRefs.set(schema, id);
|
|
27
49
|
var properties = getSchemaProperties(schema);
|
|
28
50
|
if (properties === null || properties === void 0 ? void 0 : properties.length) {
|
|
29
|
-
return (<OpenAPIDisclosure
|
|
51
|
+
return (<OpenAPIDisclosure icon={context.icons.plus} label={function (isExpanded) {
|
|
52
|
+
return getDisclosureLabel({ schema: schema, isExpanded: isExpanded, context: context });
|
|
53
|
+
}}>
|
|
30
54
|
<OpenAPISchemaProperties properties={properties} circularRefs={circularRefs} context={context}/>
|
|
31
55
|
</OpenAPIDisclosure>);
|
|
32
56
|
}
|
|
@@ -60,10 +84,14 @@ function OpenAPIRootSchema(props) {
|
|
|
60
84
|
var schema = props.schema, context = props.context, _a = props.circularRefs, parentCircularRefs = _a === void 0 ? new Map() : _a;
|
|
61
85
|
var id = useId();
|
|
62
86
|
var properties = getSchemaProperties(schema);
|
|
87
|
+
var description = resolveDescription(schema);
|
|
63
88
|
if (properties === null || properties === void 0 ? void 0 : properties.length) {
|
|
64
89
|
var circularRefs = new Map(parentCircularRefs);
|
|
65
90
|
circularRefs.set(schema, id);
|
|
66
|
-
return (
|
|
91
|
+
return (<>
|
|
92
|
+
{description ? (<Markdown source={description} className="openapi-schema-root-description"/>) : null}
|
|
93
|
+
<OpenAPISchemaProperties properties={properties} circularRefs={circularRefs} context={context}/>
|
|
94
|
+
</>);
|
|
67
95
|
}
|
|
68
96
|
return (<OpenAPISchemaProperty className="openapi-schema-root" property={{ schema: schema }} context={context} circularRefs={parentCircularRefs}/>);
|
|
69
97
|
}
|
|
@@ -81,7 +109,7 @@ function OpenAPISchemaAlternative(props) {
|
|
|
81
109
|
var properties = getSchemaProperties(schema);
|
|
82
110
|
return (<>
|
|
83
111
|
{description ? (<Markdown source={description} className="openapi-schema-description"/>) : null}
|
|
84
|
-
<OpenAPIDisclosure
|
|
112
|
+
<OpenAPIDisclosure icon={context.icons.plus} label={function (isExpanded) { return getDisclosureLabel({ schema: schema, isExpanded: isExpanded, context: context }); }}>
|
|
85
113
|
{(properties === null || properties === void 0 ? void 0 : properties.length) ? (<OpenAPISchemaProperties properties={properties} circularRefs={circularRefs} context={context}/>) : (<OpenAPISchemaProperty property={{ schema: schema }} circularRefs={circularRefs} context={context}/>)}
|
|
86
114
|
</OpenAPIDisclosure>
|
|
87
115
|
</>);
|
|
@@ -100,7 +128,7 @@ function OpenAPISchemaCircularRef(props) {
|
|
|
100
128
|
* Render the enum value for a schema.
|
|
101
129
|
*/
|
|
102
130
|
function OpenAPISchemaEnum(props) {
|
|
103
|
-
var schema = props.schema;
|
|
131
|
+
var schema = props.schema, context = props.context;
|
|
104
132
|
var enumValues = (function () {
|
|
105
133
|
var _a;
|
|
106
134
|
// Render x-gitbook-enum first, as it has a different format
|
|
@@ -135,7 +163,7 @@ function OpenAPISchemaEnum(props) {
|
|
|
135
163
|
return (<span className="openapi-schema-enum">
|
|
136
164
|
Available options:{' '}
|
|
137
165
|
{enumValues.map(function (item, index) { return (<span key={index} className="openapi-schema-enum-value">
|
|
138
|
-
<OpenAPICopyButton value={item.value} label={item.description} withTooltip={!!item.description}>
|
|
166
|
+
<OpenAPICopyButton value={item.value} label={item.description} withTooltip={!!item.description} context={context}>
|
|
139
167
|
<code>{"".concat(item.value)}</code>
|
|
140
168
|
</OpenAPICopyButton>
|
|
141
169
|
</span>); })}
|
|
@@ -145,11 +173,11 @@ function OpenAPISchemaEnum(props) {
|
|
|
145
173
|
* Render the top row of a schema. e.g: name, type, and required status.
|
|
146
174
|
*/
|
|
147
175
|
function OpenAPISchemaPresentation(props) {
|
|
148
|
-
var _a = props.property, schema = _a.schema, propertyName = _a.propertyName, required = _a.required;
|
|
176
|
+
var _a = props.property, schema = _a.schema, propertyName = _a.propertyName, required = _a.required, context = props.context;
|
|
149
177
|
var description = resolveDescription(schema);
|
|
150
178
|
var example = resolveFirstExample(schema);
|
|
151
179
|
return (<div className="openapi-schema-presentation">
|
|
152
|
-
<OpenAPISchemaName schema={schema} type={getSchemaTitle(schema)} propertyName={propertyName} required={required}/>
|
|
180
|
+
<OpenAPISchemaName schema={schema} type={getSchemaTitle(schema)} propertyName={propertyName} required={required} context={context}/>
|
|
153
181
|
{typeof schema['x-deprecated-sunset'] === 'string' ? (<div className="openapi-deprecated-sunset openapi-schema-description openapi-markdown">
|
|
154
182
|
Sunset date:{' '}
|
|
155
183
|
<span className="openapi-deprecated-sunset-date">
|
|
@@ -157,13 +185,21 @@ function OpenAPISchemaPresentation(props) {
|
|
|
157
185
|
</span>
|
|
158
186
|
</div>) : null}
|
|
159
187
|
{description ? (<Markdown source={description} className="openapi-schema-description"/>) : null}
|
|
160
|
-
{
|
|
188
|
+
{schema.default !== undefined ? (<span className="openapi-schema-default">
|
|
189
|
+
Default:{' '}
|
|
190
|
+
<code>
|
|
191
|
+
{typeof schema.default === 'string' && schema.default
|
|
192
|
+
? schema.default
|
|
193
|
+
: stringifyOpenAPI(schema.default)}
|
|
194
|
+
</code>
|
|
195
|
+
</span>) : null}
|
|
196
|
+
{typeof example === 'string' ? (<span className="openapi-schema-example">
|
|
161
197
|
Example: <code>{example}</code>
|
|
162
|
-
</
|
|
163
|
-
{schema.pattern ? (<
|
|
198
|
+
</span>) : null}
|
|
199
|
+
{schema.pattern ? (<span className="openapi-schema-pattern">
|
|
164
200
|
Pattern: <code>{schema.pattern}</code>
|
|
165
|
-
</
|
|
166
|
-
<OpenAPISchemaEnum schema={schema}/>
|
|
201
|
+
</span>) : null}
|
|
202
|
+
<OpenAPISchemaEnum schema={schema} context={context}/>
|
|
167
203
|
</div>);
|
|
168
204
|
}
|
|
169
205
|
/**
|
|
@@ -235,7 +271,65 @@ export function getSchemaAlternatives(schema, ancestors) {
|
|
|
235
271
|
return null;
|
|
236
272
|
}
|
|
237
273
|
var type = alternatives[0], schemas = alternatives[1];
|
|
238
|
-
return flattenAlternatives(type, schemas, new Set(ancestors).add(schema));
|
|
274
|
+
return mergeAlternatives(type, flattenAlternatives(type, schemas, new Set(ancestors).add(schema)));
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Merge alternatives of the same type into a single schema.
|
|
278
|
+
* - Merge string enums
|
|
279
|
+
*/
|
|
280
|
+
function mergeAlternatives(alternativeType, schemasOrRefs) {
|
|
281
|
+
switch (alternativeType) {
|
|
282
|
+
case 'oneOf': {
|
|
283
|
+
return schemasOrRefs.reduce(function (acc, schemaOrRef) {
|
|
284
|
+
var latest = acc.at(-1);
|
|
285
|
+
if (latest &&
|
|
286
|
+
latest.type === 'string' &&
|
|
287
|
+
latest.enum &&
|
|
288
|
+
schemaOrRef.type === 'string' &&
|
|
289
|
+
schemaOrRef.enum) {
|
|
290
|
+
latest.enum = Array.from(new Set(__spreadArray(__spreadArray([], latest.enum, true), schemaOrRef.enum, true)));
|
|
291
|
+
latest.nullable = latest.nullable || schemaOrRef.nullable;
|
|
292
|
+
return acc;
|
|
293
|
+
}
|
|
294
|
+
acc.push(schemaOrRef);
|
|
295
|
+
return acc;
|
|
296
|
+
}, []);
|
|
297
|
+
}
|
|
298
|
+
case 'allOf': {
|
|
299
|
+
return schemasOrRefs.reduce(function (acc, schemaOrRef) {
|
|
300
|
+
var latest = acc.at(-1);
|
|
301
|
+
if (latest &&
|
|
302
|
+
latest.type === 'string' &&
|
|
303
|
+
latest.enum &&
|
|
304
|
+
schemaOrRef.type === 'string' &&
|
|
305
|
+
schemaOrRef.enum) {
|
|
306
|
+
var keys = Object.keys(schemaOrRef);
|
|
307
|
+
if (keys.every(function (key) { return ['type', 'enum', 'nullable'].includes(key); })) {
|
|
308
|
+
latest.enum = Array.from(new Set(__spreadArray(__spreadArray([], latest.enum, true), schemaOrRef.enum, true)));
|
|
309
|
+
latest.nullable = latest.nullable || schemaOrRef.nullable;
|
|
310
|
+
return acc;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (latest && latest.type === 'object' && schemaOrRef.type === 'object') {
|
|
314
|
+
var keys = Object.keys(schemaOrRef);
|
|
315
|
+
if (keys.every(function (key) {
|
|
316
|
+
return ['type', 'properties', 'required', 'nullable'].includes(key);
|
|
317
|
+
})) {
|
|
318
|
+
latest.properties = __assign(__assign({}, latest.properties), schemaOrRef.properties);
|
|
319
|
+
latest.required = Array.from(new Set(__spreadArray(__spreadArray([], (Array.isArray(latest.required) ? latest.required : []), true), (Array.isArray(schemaOrRef.required)
|
|
320
|
+
? schemaOrRef.required
|
|
321
|
+
: []), true)));
|
|
322
|
+
latest.nullable = latest.nullable || schemaOrRef.nullable;
|
|
323
|
+
return acc;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
acc.push(schemaOrRef);
|
|
327
|
+
return acc;
|
|
328
|
+
}, []);
|
|
329
|
+
}
|
|
330
|
+
default:
|
|
331
|
+
return schemasOrRefs;
|
|
332
|
+
}
|
|
239
333
|
}
|
|
240
334
|
function flattenAlternatives(alternativeType, schemasOrRefs, ancestors) {
|
|
241
335
|
return schemasOrRefs.reduce(function (acc, schemaOrRef) {
|
|
@@ -287,17 +381,24 @@ function getSchemaTitle(schema) {
|
|
|
287
381
|
}
|
|
288
382
|
return type;
|
|
289
383
|
}
|
|
290
|
-
function getDisclosureLabel(
|
|
384
|
+
function getDisclosureLabel(props) {
|
|
291
385
|
var _a, _b;
|
|
386
|
+
var schema = props.schema, isExpanded = props.isExpanded, context = props.context;
|
|
387
|
+
var label;
|
|
292
388
|
if (schema.type === 'array' && !!schema.items) {
|
|
293
389
|
if (schema.items.oneOf) {
|
|
294
|
-
|
|
390
|
+
label = tString(context.translation, 'available_items').toLowerCase();
|
|
295
391
|
}
|
|
296
392
|
// Fallback to "child attributes" for enums and objects
|
|
297
|
-
if (schema.items.enum || schema.items.type === 'object') {
|
|
298
|
-
|
|
393
|
+
else if (schema.items.enum || schema.items.type === 'object') {
|
|
394
|
+
label = tString(context.translation, 'child_attributes').toLowerCase();
|
|
299
395
|
}
|
|
300
|
-
|
|
396
|
+
else {
|
|
397
|
+
label = (_b = (_a = schema.items.title) !== null && _a !== void 0 ? _a : schema.title) !== null && _b !== void 0 ? _b : getSchemaTitle(schema.items);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
label = schema.title || tString(context.translation, 'child_attributes').toLowerCase();
|
|
301
402
|
}
|
|
302
|
-
return
|
|
403
|
+
return "".concat(isExpanded ? tString(context.translation, 'hide') : tString(context.translation, 'show'), " ").concat(label);
|
|
303
404
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from '@gitbook/openapi-parser';
|
|
2
2
|
import type React from 'react';
|
|
3
|
+
import type { OpenAPIClientContext } from './context';
|
|
3
4
|
interface OpenAPISchemaNameProps {
|
|
4
5
|
schema?: OpenAPIV3.SchemaObject;
|
|
5
6
|
propertyName?: string | React.JSX.Element;
|
|
6
7
|
required?: boolean;
|
|
7
8
|
type?: string;
|
|
9
|
+
context: OpenAPIClientContext;
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
12
|
* Display the schema name row.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t, tString } from './translate';
|
|
2
2
|
/**
|
|
3
3
|
* Display the schema name row.
|
|
4
4
|
* It includes the property name, type, required and deprecated status.
|
|
5
5
|
*/
|
|
6
6
|
export function OpenAPISchemaName(props) {
|
|
7
|
-
var schema = props.schema, type = props.type, propertyName = props.propertyName, required = props.required;
|
|
8
|
-
var additionalItems = schema && getAdditionalItems(schema);
|
|
9
|
-
return (<
|
|
7
|
+
var schema = props.schema, type = props.type, propertyName = props.propertyName, required = props.required, context = props.context;
|
|
8
|
+
var additionalItems = schema && getAdditionalItems(schema, context);
|
|
9
|
+
return (<span className="openapi-schema-name">
|
|
10
10
|
{propertyName ? (<span data-deprecated={schema === null || schema === void 0 ? void 0 : schema.deprecated} className="openapi-schema-propertyname">
|
|
11
11
|
{propertyName}
|
|
12
12
|
</span>) : null}
|
|
@@ -14,26 +14,30 @@ export function OpenAPISchemaName(props) {
|
|
|
14
14
|
{type ? <span className="openapi-schema-type">{type}</span> : null}
|
|
15
15
|
{additionalItems ? (<span className="openapi-schema-type">{additionalItems}</span>) : null}
|
|
16
16
|
</span>
|
|
17
|
-
{(schema === null || schema === void 0 ? void 0 : schema.readOnly) ? <span className="openapi-schema-readonly">
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{(schema === null || schema === void 0 ? void 0 : schema.
|
|
21
|
-
|
|
17
|
+
{(schema === null || schema === void 0 ? void 0 : schema.readOnly) ? (<span className="openapi-schema-readonly">
|
|
18
|
+
{t(context.translation, 'read_only')}
|
|
19
|
+
</span>) : null}
|
|
20
|
+
{(schema === null || schema === void 0 ? void 0 : schema.writeOnly) ? (<span className="openapi-schema-writeonly">
|
|
21
|
+
{t(context.translation, 'write_only')}
|
|
22
|
+
</span>) : null}
|
|
23
|
+
{required ? (<span className="openapi-schema-required">
|
|
24
|
+
{t(context.translation, 'required')}
|
|
25
|
+
</span>) : (<span className="openapi-schema-optional">
|
|
26
|
+
{t(context.translation, 'optional')}
|
|
27
|
+
</span>)}
|
|
28
|
+
{(schema === null || schema === void 0 ? void 0 : schema.deprecated) ? (<span className="openapi-deprecated">{t(context.translation, 'deprecated')}</span>) : null}
|
|
29
|
+
</span>);
|
|
22
30
|
}
|
|
23
|
-
function getAdditionalItems(schema) {
|
|
31
|
+
function getAdditionalItems(schema, context) {
|
|
24
32
|
var additionalItems = '';
|
|
25
33
|
if (schema.minimum || schema.minLength || schema.minItems) {
|
|
26
|
-
additionalItems += " \u00B7 min: ".concat(schema.minimum || schema.minLength || schema.minItems);
|
|
34
|
+
additionalItems += " \u00B7 ".concat(tString(context.translation, 'min').toLowerCase(), ": ").concat(schema.minimum || schema.minLength || schema.minItems);
|
|
27
35
|
}
|
|
28
36
|
if (schema.maximum || schema.maxLength || schema.maxItems) {
|
|
29
|
-
additionalItems += " \u00B7 max: ".concat(schema.maximum || schema.maxLength || schema.maxItems);
|
|
30
|
-
}
|
|
31
|
-
// If the schema has a default value, we display it
|
|
32
|
-
if (typeof schema.default !== 'undefined') {
|
|
33
|
-
additionalItems += " \u00B7 default: ".concat(stringifyOpenAPI(schema.default));
|
|
37
|
+
additionalItems += " \u00B7 ".concat(tString(context.translation, 'max').toLowerCase(), ": ").concat(schema.maximum || schema.maxLength || schema.maxItems);
|
|
34
38
|
}
|
|
35
39
|
if (schema.nullable) {
|
|
36
|
-
additionalItems =
|
|
40
|
+
additionalItems = " | ".concat(tString(context.translation, 'nullable').toLowerCase());
|
|
37
41
|
}
|
|
38
42
|
return additionalItems;
|
|
39
43
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from '@gitbook/openapi-parser';
|
|
2
2
|
import { type OpenAPISchemaPropertyEntry } from './OpenAPISchema';
|
|
3
|
-
import type { OpenAPIClientContext } from './
|
|
3
|
+
import type { OpenAPIClientContext } from './context';
|
|
4
4
|
export declare function OpenAPISchemaProperties(props: {
|
|
5
5
|
id?: string;
|
|
6
6
|
properties: OpenAPISchemaPropertyEntry[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { OpenAPIClientContext
|
|
1
|
+
import type { OpenAPIClientContext } from './context';
|
|
2
|
+
import type { OpenAPIOperationData } from './types';
|
|
2
3
|
/**
|
|
3
4
|
* Present securities authorization that can be used for this operation.
|
|
4
5
|
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { InteractiveSection } from './InteractiveSection';
|
|
2
2
|
import { Markdown } from './Markdown';
|
|
3
3
|
import { OpenAPISchemaName } from './OpenAPISchemaName';
|
|
4
|
-
import {
|
|
4
|
+
import { t } from './translate';
|
|
5
|
+
import { createStateKey, resolveDescription } from './utils';
|
|
5
6
|
/**
|
|
6
7
|
* Present securities authorization that can be used for this operation.
|
|
7
8
|
*/
|
|
@@ -10,7 +11,7 @@ export function OpenAPISecurities(props) {
|
|
|
10
11
|
if (securities.length === 0) {
|
|
11
12
|
return null;
|
|
12
13
|
}
|
|
13
|
-
return (<InteractiveSection header=
|
|
14
|
+
return (<InteractiveSection header={t(context.translation, 'authorizations')} stateKey={createStateKey('securities', context.blockKey)} toggeable defaultOpened={false} toggleIcon={context.icons.chevronRight} selectIcon={context.icons.chevronDown} className="openapi-securities" tabs={securities.map(function (_a) {
|
|
14
15
|
var key = _a[0], security = _a[1];
|
|
15
16
|
var description = resolveDescription(security);
|
|
16
17
|
return {
|
|
@@ -18,7 +19,7 @@ export function OpenAPISecurities(props) {
|
|
|
18
19
|
label: key,
|
|
19
20
|
body: (<div className="openapi-schema">
|
|
20
21
|
<div className="openapi-schema-presentation">
|
|
21
|
-
{getLabelForType(security)}
|
|
22
|
+
{getLabelForType(security, context)}
|
|
22
23
|
|
|
23
24
|
{description ? (<Markdown source={description} className="openapi-securities-description"/>) : null}
|
|
24
25
|
</div>
|
|
@@ -26,28 +27,28 @@ export function OpenAPISecurities(props) {
|
|
|
26
27
|
};
|
|
27
28
|
})}/>);
|
|
28
29
|
}
|
|
29
|
-
function getLabelForType(security) {
|
|
30
|
+
function getLabelForType(security, context) {
|
|
30
31
|
var _a;
|
|
31
32
|
switch (security.type) {
|
|
32
33
|
case 'apiKey':
|
|
33
|
-
return (<OpenAPISchemaName propertyName={(_a = security.name) !== null && _a !== void 0 ? _a : 'apiKey'} type="string" required/>);
|
|
34
|
+
return (<OpenAPISchemaName context={context} propertyName={(_a = security.name) !== null && _a !== void 0 ? _a : 'apiKey'} type="string" required={security.required}/>);
|
|
34
35
|
case 'http':
|
|
35
36
|
if (security.scheme === 'basic') {
|
|
36
|
-
return <OpenAPISchemaName propertyName="Authorization" type="string" required
|
|
37
|
+
return (<OpenAPISchemaName context={context} propertyName="Authorization" type="string" required={security.required}/>);
|
|
37
38
|
}
|
|
38
39
|
if (security.scheme === 'bearer') {
|
|
39
40
|
var description = resolveDescription(security);
|
|
40
41
|
return (<>
|
|
41
|
-
<OpenAPISchemaName propertyName="Authorization" type="string" required/>
|
|
42
|
+
<OpenAPISchemaName context={context} propertyName="Authorization" type="string" required={security.required}/>
|
|
42
43
|
{/** Show a default description if none is provided */}
|
|
43
44
|
{!description ? (<Markdown source={"Bearer authentication header of the form Bearer ".concat('<token>', ".")} className="openapi-securities-description"/>) : null}
|
|
44
45
|
</>);
|
|
45
46
|
}
|
|
46
|
-
return <OpenAPISchemaName propertyName="HTTP" required
|
|
47
|
+
return (<OpenAPISchemaName context={context} propertyName="HTTP" required={security.required}/>);
|
|
47
48
|
case 'oauth2':
|
|
48
|
-
return <OpenAPISchemaName propertyName="OAuth2" required
|
|
49
|
+
return (<OpenAPISchemaName context={context} propertyName="OAuth2" required={security.required}/>);
|
|
49
50
|
case 'openIdConnect':
|
|
50
|
-
return <OpenAPISchemaName propertyName="OpenID Connect" required
|
|
51
|
+
return (<OpenAPISchemaName context={context} propertyName="OpenID Connect" required={security.required}/>);
|
|
51
52
|
default:
|
|
52
53
|
// @ts-ignore
|
|
53
54
|
return security.type;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Key, type ListBoxItemProps, type PopoverProps, type SelectProps } from 'react-aria-components';
|
|
2
|
+
export type OpenAPISelectItem = {
|
|
3
|
+
key: Key;
|
|
4
|
+
label: string | React.ReactNode;
|
|
5
|
+
};
|
|
6
|
+
interface OpenAPISelectProps<T extends OpenAPISelectItem> extends Omit<SelectProps<T>, 'children'> {
|
|
7
|
+
items: T[];
|
|
8
|
+
children: React.ReactNode | ((item: T) => React.ReactNode);
|
|
9
|
+
placement?: PopoverProps['placement'];
|
|
10
|
+
stateKey?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Icon to display in the select button.
|
|
13
|
+
*/
|
|
14
|
+
icon?: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export declare function useSelectState(stateKey?: string, initialKey?: Key): {
|
|
17
|
+
key: (string | number) | null;
|
|
18
|
+
setKey: (key: Key | null) => void;
|
|
19
|
+
};
|
|
20
|
+
export declare function OpenAPISelect<T extends OpenAPISelectItem>(props: OpenAPISelectProps<T>): import("react").JSX.Element;
|
|
21
|
+
export declare function OpenAPISelectItem(props: ListBoxItemProps): import("react").JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { Button, ListBox, ListBoxItem, Popover, Select, SelectValue, } from 'react-aria-components';
|
|
5
|
+
import { useStore } from 'zustand';
|
|
6
|
+
import { getOrCreateStoreByKey } from './getOrCreateStoreByKey';
|
|
7
|
+
export function useSelectState(stateKey, initialKey) {
|
|
8
|
+
if (stateKey === void 0) { stateKey = 'select-state'; }
|
|
9
|
+
var store = useStore(getOrCreateStoreByKey(stateKey, initialKey));
|
|
10
|
+
return {
|
|
11
|
+
key: store.key,
|
|
12
|
+
setKey: useCallback(function (key) { return store.setKey(key); }, [store.setKey]),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function OpenAPISelect(props) {
|
|
16
|
+
var _a;
|
|
17
|
+
var _b = props.icon, icon = _b === void 0 ? '▼' : _b, items = props.items, children = props.children, className = props.className, placement = props.placement, stateKey = props.stateKey, selectedKey = props.selectedKey, onSelectionChange = props.onSelectionChange;
|
|
18
|
+
var state = useSelectState(stateKey, (_a = items[0]) === null || _a === void 0 ? void 0 : _a.key);
|
|
19
|
+
var selected = items.find(function (item) { return item.key === state.key; }) || items[0];
|
|
20
|
+
return (<Select aria-label="OpenAPI Select" {...props} selectedKey={selectedKey || (selected === null || selected === void 0 ? void 0 : selected.key)} onSelectionChange={function (key) {
|
|
21
|
+
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(key);
|
|
22
|
+
state.setKey(key);
|
|
23
|
+
}} className={clsx('openapi-select', className)}>
|
|
24
|
+
<Button>
|
|
25
|
+
<SelectValue />
|
|
26
|
+
{icon}
|
|
27
|
+
</Button>
|
|
28
|
+
<Popover placement={placement} className="openapi-select-popover">
|
|
29
|
+
<ListBox className="openapi-select-listbox" items={items}>
|
|
30
|
+
{children}
|
|
31
|
+
</ListBox>
|
|
32
|
+
</Popover>
|
|
33
|
+
</Select>);
|
|
34
|
+
}
|
|
35
|
+
export function OpenAPISelectItem(props) {
|
|
36
|
+
return (<ListBoxItem {...props} className={function (_a) {
|
|
37
|
+
var isFocused = _a.isFocused, isSelected = _a.isSelected;
|
|
38
|
+
return clsx('openapi-select-item', {
|
|
39
|
+
'openapi-select-item-focused': isFocused,
|
|
40
|
+
'openapi-select-item-selected': isSelected,
|
|
41
|
+
});
|
|
42
|
+
}}/>);
|
|
43
|
+
}
|
package/dist/OpenAPISpec.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { OpenAPIClientContext
|
|
1
|
+
import type { OpenAPIClientContext } from './context';
|
|
2
|
+
import type { OpenAPIOperationData, OpenAPIWebhookData } from './types';
|
|
2
3
|
export declare function OpenAPISpec(props: {
|
|
3
|
-
data: OpenAPIOperationData;
|
|
4
|
+
data: OpenAPIOperationData | OpenAPIWebhookData;
|
|
4
5
|
context: OpenAPIClientContext;
|
|
5
6
|
}): import("react").JSX.Element;
|