@gitbook/react-openapi 1.4.3 → 1.5.2
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 +36 -0
- package/dist/InteractiveSection.js +59 -0
- package/dist/Markdown.js +10 -0
- package/dist/OpenAPICodeSample.js +219 -0
- package/dist/OpenAPICodeSampleInteractive.js +66 -0
- package/dist/OpenAPICodeSampleSelector.js +45 -0
- package/dist/OpenAPICopyButton.js +39 -0
- package/dist/OpenAPIDisclosure.js +30 -0
- package/dist/OpenAPIDisclosureGroup.js +75 -0
- package/dist/OpenAPIExample.js +41 -0
- package/dist/OpenAPIMediaType.js +58 -0
- package/dist/OpenAPIOperation.d.ts +12 -7
- package/dist/OpenAPIOperation.js +30 -0
- package/dist/OpenAPIOperationContext.d.ts +10 -6
- package/dist/OpenAPIOperationContext.js +30 -0
- package/dist/OpenAPIPath.js +51 -0
- package/dist/OpenAPIPrefillContextProvider.d.ts +11 -7
- package/dist/OpenAPIPrefillContextProvider.js +25 -0
- package/dist/OpenAPIRequestBody.js +28 -0
- package/dist/OpenAPIRequestBodyHeaderType.js +23 -0
- package/dist/OpenAPIResponse.js +39 -0
- package/dist/OpenAPIResponseExample.js +75 -0
- package/dist/OpenAPIResponseExampleContent.js +61 -0
- package/dist/OpenAPIResponses.js +61 -0
- package/dist/OpenAPISchema.js +373 -0
- package/dist/OpenAPISchemaName.js +45 -0
- package/dist/OpenAPISchemaServer.js +13 -0
- package/dist/OpenAPISecurities.js +124 -0
- package/dist/OpenAPISelect.js +45 -0
- package/dist/OpenAPISpec.js +73 -0
- package/dist/OpenAPIWebhook.d.ts +12 -7
- package/dist/OpenAPIWebhook.js +28 -0
- package/dist/OpenAPIWebhookExample.js +40 -0
- package/dist/ScalarApiButton.js +87 -0
- package/dist/StaticSection.js +37 -0
- package/dist/code-samples.js +267 -419
- package/dist/common/OpenAPIColumnSpec.js +23 -0
- package/dist/common/OpenAPIOperationDescription.js +18 -0
- package/dist/common/OpenAPIStability.js +17 -0
- package/dist/common/OpenAPISummary.js +27 -0
- package/dist/contentTypeChecks.js +24 -20
- package/dist/context.d.ts +68 -72
- package/dist/context.js +25 -39
- package/dist/decycle.js +39 -68
- package/dist/dereference.js +20 -64
- package/dist/generateSchemaExample.js +188 -332
- package/dist/getDisclosureLabel.js +15 -16
- package/dist/getOrCreateStoreByKey.js +20 -17
- package/dist/index.d.ts +12 -10
- package/dist/index.js +11 -8
- package/dist/json2xml.js +10 -5
- package/dist/resolveOpenAPIOperation.d.ts +11 -7
- package/dist/resolveOpenAPIOperation.js +88 -159
- package/dist/resolveOpenAPIWebhook.d.ts +11 -7
- package/dist/resolveOpenAPIWebhook.js +41 -116
- package/dist/schemas/OpenAPISchemaItem.js +26 -0
- package/dist/schemas/OpenAPISchemas.d.ts +16 -11
- package/dist/schemas/OpenAPISchemas.js +57 -0
- package/dist/schemas/resolveOpenAPISchemas.d.ts +9 -4
- package/dist/schemas/resolveOpenAPISchemas.js +15 -59
- package/dist/stringifyOpenAPI.js +12 -13
- package/dist/translate.js +43 -0
- package/dist/translations/de.js +47 -42
- package/dist/translations/en.d.ts +46 -42
- package/dist/translations/en.js +47 -42
- package/dist/translations/es.js +47 -42
- package/dist/translations/fr.js +47 -42
- package/dist/translations/index.d.ts +404 -391
- package/dist/translations/index.js +28 -24
- package/dist/translations/ja.js +47 -42
- package/dist/translations/nl.js +47 -42
- package/dist/translations/no.js +47 -42
- package/dist/translations/pt-br.js +47 -42
- package/dist/translations/types.d.ts +7 -5
- package/dist/translations/zh.js +47 -42
- package/dist/types.d.ts +30 -24
- package/dist/util/example.js +84 -0
- package/dist/util/server.js +32 -38
- package/dist/util/tryit-prefill.js +135 -121
- package/dist/utils.js +135 -196
- package/package.json +18 -11
- package/dist/InteractiveSection.d.ts +0 -33
- package/dist/InteractiveSection.jsx +0 -61
- package/dist/Markdown.d.ts +0 -4
- package/dist/Markdown.jsx +0 -5
- package/dist/OpenAPICodeSample.d.ts +0 -19
- package/dist/OpenAPICodeSample.jsx +0 -230
- package/dist/OpenAPICodeSampleInteractive.d.ts +0 -14
- package/dist/OpenAPICodeSampleInteractive.jsx +0 -73
- package/dist/OpenAPICodeSampleSelector.d.ts +0 -14
- package/dist/OpenAPICodeSampleSelector.jsx +0 -44
- package/dist/OpenAPICopyButton.d.ts +0 -13
- package/dist/OpenAPICopyButton.jsx +0 -35
- package/dist/OpenAPIDisclosure.d.ts +0 -11
- package/dist/OpenAPIDisclosure.jsx +0 -30
- package/dist/OpenAPIDisclosureGroup.d.ts +0 -23
- package/dist/OpenAPIDisclosureGroup.jsx +0 -83
- package/dist/OpenAPIExample.d.ts +0 -16
- package/dist/OpenAPIExample.jsx +0 -36
- package/dist/OpenAPIMediaType.d.ts +0 -21
- package/dist/OpenAPIMediaType.jsx +0 -61
- package/dist/OpenAPIOperation.jsx +0 -25
- package/dist/OpenAPIOperationContext.jsx +0 -26
- package/dist/OpenAPIOperationDescription.d.ts +0 -9
- package/dist/OpenAPIOperationDescription.jsx +0 -22
- package/dist/OpenAPIOperationStability.d.ts +0 -9
- package/dist/OpenAPIOperationStability.jsx +0 -27
- package/dist/OpenAPIPath.d.ts +0 -18
- package/dist/OpenAPIPath.jsx +0 -55
- package/dist/OpenAPIPrefillContextProvider.jsx +0 -19
- package/dist/OpenAPIRequestBody.d.ts +0 -11
- package/dist/OpenAPIRequestBody.jsx +0 -28
- package/dist/OpenAPIRequestBodyHeaderType.d.ts +0 -8
- package/dist/OpenAPIRequestBodyHeaderType.jsx +0 -25
- package/dist/OpenAPIResponse.d.ts +0 -10
- package/dist/OpenAPIResponse.jsx +0 -57
- package/dist/OpenAPIResponseExample.d.ts +0 -9
- package/dist/OpenAPIResponseExample.jsx +0 -105
- package/dist/OpenAPIResponseExampleContent.d.ts +0 -22
- package/dist/OpenAPIResponseExampleContent.jsx +0 -60
- package/dist/OpenAPIResponses.d.ts +0 -9
- package/dist/OpenAPIResponses.jsx +0 -77
- package/dist/OpenAPISchema.d.ts +0 -27
- package/dist/OpenAPISchema.jsx +0 -400
- package/dist/OpenAPISchemaName.d.ts +0 -16
- package/dist/OpenAPISchemaName.jsx +0 -43
- package/dist/OpenAPISchemaServer.d.ts +0 -12
- package/dist/OpenAPISchemaServer.jsx +0 -8
- package/dist/OpenAPISecurities.d.ts +0 -9
- package/dist/OpenAPISecurities.jsx +0 -114
- package/dist/OpenAPISelect.d.ts +0 -22
- package/dist/OpenAPISelect.jsx +0 -44
- package/dist/OpenAPISpec.d.ts +0 -6
- package/dist/OpenAPISpec.jsx +0 -80
- package/dist/OpenAPITabs.d.ts +0 -26
- package/dist/OpenAPITabs.jsx +0 -109
- package/dist/OpenAPIWebhook.jsx +0 -23
- package/dist/OpenAPIWebhookExample.d.ts +0 -6
- package/dist/OpenAPIWebhookExample.jsx +0 -41
- package/dist/ScalarApiButton.d.ts +0 -14
- package/dist/ScalarApiButton.jsx +0 -81
- package/dist/StaticSection.d.ts +0 -13
- package/dist/StaticSection.jsx +0 -32
- package/dist/code-samples.d.ts +0 -17
- package/dist/common/OpenAPIColumnSpec.d.ts +0 -6
- package/dist/common/OpenAPIColumnSpec.jsx +0 -20
- package/dist/common/OpenAPIOperationDescription.d.ts +0 -6
- package/dist/common/OpenAPIOperationDescription.jsx +0 -19
- package/dist/common/OpenAPIStability.d.ts +0 -4
- package/dist/common/OpenAPIStability.jsx +0 -15
- package/dist/common/OpenAPISummary.d.ts +0 -6
- package/dist/common/OpenAPISummary.jsx +0 -30
- package/dist/contentTypeChecks.d.ts +0 -10
- package/dist/decycle.d.ts +0 -2
- package/dist/dereference.d.ts +0 -5
- package/dist/generateSchemaExample.d.ts +0 -45
- package/dist/getDisclosureLabel.d.ts +0 -7
- package/dist/getOrCreateStoreByKey.d.ts +0 -10
- package/dist/json2xml.d.ts +0 -4
- package/dist/schemas/OpenAPISchemaItem.d.ts +0 -7
- package/dist/schemas/OpenAPISchemaItem.jsx +0 -16
- package/dist/schemas/OpenAPISchemas.jsx +0 -59
- package/dist/schemas/index.d.ts +0 -2
- package/dist/schemas/index.js +0 -2
- package/dist/stringifyOpenAPI.d.ts +0 -4
- package/dist/translate.d.ts +0 -10
- package/dist/translate.jsx +0 -75
- package/dist/translations/de.d.ts +0 -43
- package/dist/translations/es.d.ts +0 -43
- package/dist/translations/fr.d.ts +0 -43
- package/dist/translations/ja.d.ts +0 -43
- package/dist/translations/nl.d.ts +0 -43
- package/dist/translations/no.d.ts +0 -43
- package/dist/translations/pt-br.d.ts +0 -43
- package/dist/translations/types.js +0 -1
- package/dist/translations/zh.d.ts +0 -43
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/types.js +0 -1
- package/dist/util/example.d.ts +0 -35
- package/dist/util/example.jsx +0 -103
- package/dist/util/server.d.ts +0 -9
- package/dist/util/tryit-prefill.d.ts +0 -20
- package/dist/utils.d.ts +0 -50
- package/src/InteractiveSection.tsx +0 -147
- package/src/Markdown.tsx +0 -12
- package/src/OpenAPICodeSample.tsx +0 -330
- package/src/OpenAPICodeSampleInteractive.tsx +0 -136
- package/src/OpenAPICodeSampleSelector.tsx +0 -94
- package/src/OpenAPICopyButton.tsx +0 -72
- package/src/OpenAPIDisclosure.tsx +0 -46
- package/src/OpenAPIDisclosureGroup.tsx +0 -158
- package/src/OpenAPIExample.tsx +0 -55
- package/src/OpenAPIMediaType.tsx +0 -139
- package/src/OpenAPIOperation.tsx +0 -35
- package/src/OpenAPIOperationContext.tsx +0 -45
- package/src/OpenAPIOperationDescription.tsx +0 -34
- package/src/OpenAPIOperationStability.tsx +0 -39
- package/src/OpenAPIPath.tsx +0 -90
- package/src/OpenAPIPrefillContextProvider.tsx +0 -40
- package/src/OpenAPIRequestBody.tsx +0 -54
- package/src/OpenAPIRequestBodyHeaderType.tsx +0 -36
- package/src/OpenAPIResponse.tsx +0 -82
- package/src/OpenAPIResponseExample.tsx +0 -151
- package/src/OpenAPIResponseExampleContent.tsx +0 -125
- package/src/OpenAPIResponses.tsx +0 -125
- package/src/OpenAPISchema.test.ts +0 -172
- package/src/OpenAPISchema.tsx +0 -654
- package/src/OpenAPISchemaName.tsx +0 -80
- package/src/OpenAPISchemaServer.tsx +0 -34
- package/src/OpenAPISecurities.tsx +0 -231
- package/src/OpenAPISelect.tsx +0 -96
- package/src/OpenAPISpec.tsx +0 -138
- package/src/OpenAPITabs.tsx +0 -147
- package/src/OpenAPIWebhook.tsx +0 -33
- package/src/OpenAPIWebhookExample.tsx +0 -60
- package/src/ScalarApiButton.tsx +0 -132
- package/src/StaticSection.tsx +0 -91
- package/src/__snapshots__/json2xml.test.ts.snap +0 -18
- package/src/code-samples.test.ts +0 -714
- package/src/code-samples.ts +0 -448
- package/src/common/OpenAPIColumnSpec.tsx +0 -31
- package/src/common/OpenAPIOperationDescription.tsx +0 -31
- package/src/common/OpenAPIStability.tsx +0 -23
- package/src/common/OpenAPISummary.tsx +0 -45
- package/src/contentTypeChecks.ts +0 -39
- package/src/context.ts +0 -99
- package/src/decycle.ts +0 -68
- package/src/dereference.ts +0 -29
- package/src/generateSchemaExample.test.ts +0 -1040
- package/src/generateSchemaExample.ts +0 -530
- package/src/getDisclosureLabel.ts +0 -25
- package/src/getOrCreateStoreByKey.ts +0 -33
- package/src/index.ts +0 -10
- package/src/json2xml.test.ts +0 -46
- package/src/json2xml.ts +0 -8
- package/src/resolveOpenAPIOperation.test.ts +0 -177
- package/src/resolveOpenAPIOperation.ts +0 -151
- package/src/resolveOpenAPIWebhook.ts +0 -99
- package/src/schemas/OpenAPISchemaItem.tsx +0 -34
- package/src/schemas/OpenAPISchemas.tsx +0 -98
- package/src/schemas/index.ts +0 -2
- package/src/schemas/resolveOpenAPISchemas.test.ts +0 -174
- package/src/schemas/resolveOpenAPISchemas.ts +0 -28
- package/src/stringifyOpenAPI.ts +0 -25
- package/src/translate.tsx +0 -80
- package/src/translations/de.ts +0 -43
- package/src/translations/en.ts +0 -43
- package/src/translations/es.ts +0 -43
- package/src/translations/fr.ts +0 -43
- package/src/translations/index.ts +0 -33
- package/src/translations/ja.ts +0 -43
- package/src/translations/nl.ts +0 -43
- package/src/translations/no.ts +0 -43
- package/src/translations/pt-br.ts +0 -43
- package/src/translations/types.ts +0 -7
- package/src/translations/zh.ts +0 -43
- package/src/types.ts +0 -46
- package/src/util/example.tsx +0 -129
- package/src/util/server.test.ts +0 -58
- package/src/util/server.ts +0 -47
- package/src/util/tryit-prefill.test.ts +0 -311
- package/src/util/tryit-prefill.ts +0 -160
- package/src/utils.ts +0 -255
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { InteractiveSection } from './InteractiveSection';
|
|
2
|
-
import { Markdown } from './Markdown';
|
|
3
|
-
import { OpenAPICopyButton } from './OpenAPICopyButton';
|
|
4
|
-
import { OpenAPISchemaName } from './OpenAPISchemaName';
|
|
5
|
-
import { t } from './translate';
|
|
6
|
-
import { createStateKey, resolveDescription } from './utils';
|
|
7
|
-
/**
|
|
8
|
-
* Present securities authorization that can be used for this operation.
|
|
9
|
-
*/
|
|
10
|
-
export function OpenAPISecurities(props) {
|
|
11
|
-
var securities = props.securities, context = props.context;
|
|
12
|
-
if (securities.length === 0) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
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) {
|
|
16
|
-
var key = _a[0], security = _a[1];
|
|
17
|
-
var description = resolveDescription(security);
|
|
18
|
-
return {
|
|
19
|
-
key: key,
|
|
20
|
-
label: key,
|
|
21
|
-
body: (<div className="openapi-schema">
|
|
22
|
-
<div className="openapi-schema-presentation">
|
|
23
|
-
{getLabelForType(security, context)}
|
|
24
|
-
|
|
25
|
-
{description ? (<Markdown source={description} className="openapi-securities-description"/>) : null}
|
|
26
|
-
</div>
|
|
27
|
-
</div>),
|
|
28
|
-
};
|
|
29
|
-
})}/>);
|
|
30
|
-
}
|
|
31
|
-
function getLabelForType(security, context) {
|
|
32
|
-
var _a;
|
|
33
|
-
switch (security.type) {
|
|
34
|
-
case 'apiKey':
|
|
35
|
-
return (<OpenAPISchemaName context={context} propertyName={(_a = security.name) !== null && _a !== void 0 ? _a : 'apiKey'} type="string" required={security.required}/>);
|
|
36
|
-
case 'http':
|
|
37
|
-
if (security.scheme === 'basic') {
|
|
38
|
-
return (<OpenAPISchemaName context={context} propertyName="Authorization" type="string" required={security.required}/>);
|
|
39
|
-
}
|
|
40
|
-
if (security.scheme === 'bearer') {
|
|
41
|
-
var description = resolveDescription(security);
|
|
42
|
-
return (<>
|
|
43
|
-
<OpenAPISchemaName context={context} propertyName="Authorization" type="string" required={security.required}/>
|
|
44
|
-
{/** Show a default description if none is provided */}
|
|
45
|
-
{!description ? (<Markdown source={"Bearer authentication header of the form Bearer ".concat('<token>', ".")} className="openapi-securities-description"/>) : null}
|
|
46
|
-
</>);
|
|
47
|
-
}
|
|
48
|
-
return (<OpenAPISchemaName context={context} propertyName="HTTP" required={security.required}/>);
|
|
49
|
-
case 'oauth2':
|
|
50
|
-
return <OpenAPISchemaOAuth2Flows context={context} security={security}/>;
|
|
51
|
-
case 'openIdConnect':
|
|
52
|
-
return (<OpenAPISchemaName context={context} propertyName="OpenID Connect" required={security.required}/>);
|
|
53
|
-
default:
|
|
54
|
-
// @ts-ignore
|
|
55
|
-
return security.type;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function OpenAPISchemaOAuth2Flows(props) {
|
|
59
|
-
var _a;
|
|
60
|
-
var context = props.context, security = props.security;
|
|
61
|
-
var flows = Object.entries((_a = security.flows) !== null && _a !== void 0 ? _a : {});
|
|
62
|
-
return (<div className="openapi-securities-oauth-flows">
|
|
63
|
-
{flows.map(function (_a, index) {
|
|
64
|
-
var name = _a[0], flow = _a[1];
|
|
65
|
-
return (<OpenAPISchemaOAuth2Item key={index} flow={flow} name={name} context={context} security={security}/>);
|
|
66
|
-
})}
|
|
67
|
-
</div>);
|
|
68
|
-
}
|
|
69
|
-
function OpenAPISchemaOAuth2Item(props) {
|
|
70
|
-
var _a;
|
|
71
|
-
var flow = props.flow, context = props.context, security = props.security, name = props.name;
|
|
72
|
-
if (!flow) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
var scopes = Object.entries((_a = flow === null || flow === void 0 ? void 0 : flow.scopes) !== null && _a !== void 0 ? _a : {});
|
|
76
|
-
return (<div>
|
|
77
|
-
<OpenAPISchemaName context={context} propertyName="OAuth2" type={name} required={security.required}/>
|
|
78
|
-
<div className="openapi-securities-oauth-content openapi-markdown">
|
|
79
|
-
{security.description ? <Markdown source={security.description}/> : null}
|
|
80
|
-
{'authorizationUrl' in flow && flow.authorizationUrl ? (<span>
|
|
81
|
-
Authorization URL:{' '}
|
|
82
|
-
<OpenAPICopyButton value={flow.authorizationUrl} context={context} className="openapi-securities-url" withTooltip>
|
|
83
|
-
{flow.authorizationUrl}
|
|
84
|
-
</OpenAPICopyButton>
|
|
85
|
-
</span>) : null}
|
|
86
|
-
{'tokenUrl' in flow && flow.tokenUrl ? (<span>
|
|
87
|
-
Token URL:{' '}
|
|
88
|
-
<OpenAPICopyButton value={flow.tokenUrl} context={context} className="openapi-securities-url" withTooltip>
|
|
89
|
-
{flow.tokenUrl}
|
|
90
|
-
</OpenAPICopyButton>
|
|
91
|
-
</span>) : null}
|
|
92
|
-
{'refreshUrl' in flow && flow.refreshUrl ? (<span>
|
|
93
|
-
Refresh URL:{' '}
|
|
94
|
-
<OpenAPICopyButton value={flow.refreshUrl} context={context} className="openapi-securities-url" withTooltip>
|
|
95
|
-
{flow.refreshUrl}
|
|
96
|
-
</OpenAPICopyButton>
|
|
97
|
-
</span>) : null}
|
|
98
|
-
{scopes.length ? (<div>
|
|
99
|
-
{t(context.translation, 'available_scopes')}:{' '}
|
|
100
|
-
<ul>
|
|
101
|
-
{scopes.map(function (_a) {
|
|
102
|
-
var key = _a[0], value = _a[1];
|
|
103
|
-
return (<li key={key}>
|
|
104
|
-
<OpenAPICopyButton value={key} context={context} withTooltip>
|
|
105
|
-
<code>{key}</code>
|
|
106
|
-
</OpenAPICopyButton>
|
|
107
|
-
: {value}
|
|
108
|
-
</li>);
|
|
109
|
-
})}
|
|
110
|
-
</ul>
|
|
111
|
-
</div>) : null}
|
|
112
|
-
</div>
|
|
113
|
-
</div>);
|
|
114
|
-
}
|
package/dist/OpenAPISelect.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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 {};
|
package/dist/OpenAPISelect.jsx
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
if (initialKey === void 0) { initialKey = 'default'; }
|
|
10
|
-
var store = useStore(getOrCreateStoreByKey(stateKey, initialKey));
|
|
11
|
-
return {
|
|
12
|
-
key: store.key,
|
|
13
|
-
setKey: useCallback(function (key) { return store.setKey(key); }, [store.setKey]),
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export function OpenAPISelect(props) {
|
|
17
|
-
var _a;
|
|
18
|
-
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;
|
|
19
|
-
var state = useSelectState(stateKey, (_a = items[0]) === null || _a === void 0 ? void 0 : _a.key);
|
|
20
|
-
var selected = items.find(function (item) { return item.key === state.key; }) || items[0];
|
|
21
|
-
return (<Select aria-label="OpenAPI Select" {...props} selectedKey={selectedKey || (selected === null || selected === void 0 ? void 0 : selected.key)} onSelectionChange={function (key) {
|
|
22
|
-
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(key);
|
|
23
|
-
state.setKey(key);
|
|
24
|
-
}} className={clsx('openapi-select', className)}>
|
|
25
|
-
<Button>
|
|
26
|
-
<SelectValue />
|
|
27
|
-
{icon}
|
|
28
|
-
</Button>
|
|
29
|
-
<Popover placement={placement} className="openapi-select-popover">
|
|
30
|
-
<ListBox className="openapi-select-listbox" items={items}>
|
|
31
|
-
{children}
|
|
32
|
-
</ListBox>
|
|
33
|
-
</Popover>
|
|
34
|
-
</Select>);
|
|
35
|
-
}
|
|
36
|
-
export function OpenAPISelectItem(props) {
|
|
37
|
-
return (<ListBoxItem {...props} className={function (_a) {
|
|
38
|
-
var isFocused = _a.isFocused, isSelected = _a.isSelected;
|
|
39
|
-
return clsx('openapi-select-item', {
|
|
40
|
-
'openapi-select-item-focused': isFocused,
|
|
41
|
-
'openapi-select-item-selected': isSelected,
|
|
42
|
-
});
|
|
43
|
-
}}/>);
|
|
44
|
-
}
|
package/dist/OpenAPISpec.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { OpenAPIClientContext } from './context';
|
|
2
|
-
import type { OpenAPIOperationData, OpenAPIWebhookData } from './types';
|
|
3
|
-
export declare function OpenAPISpec(props: {
|
|
4
|
-
data: OpenAPIOperationData | OpenAPIWebhookData;
|
|
5
|
-
context: OpenAPIClientContext;
|
|
6
|
-
}): import("react").JSX.Element;
|
package/dist/OpenAPISpec.jsx
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { OpenAPIRequestBody } from './OpenAPIRequestBody';
|
|
2
|
-
import { OpenAPIResponses } from './OpenAPIResponses';
|
|
3
|
-
import { OpenAPISchemaProperties } from './OpenAPISchemaServer';
|
|
4
|
-
import { OpenAPISecurities } from './OpenAPISecurities';
|
|
5
|
-
import { StaticSection } from './StaticSection';
|
|
6
|
-
import { tString } from './translate';
|
|
7
|
-
import { parameterToProperty } from './utils';
|
|
8
|
-
export function OpenAPISpec(props) {
|
|
9
|
-
var _a;
|
|
10
|
-
var data = props.data, context = props.context;
|
|
11
|
-
var operation = data.operation;
|
|
12
|
-
var parameters = deduplicateParameters((_a = operation.parameters) !== null && _a !== void 0 ? _a : []);
|
|
13
|
-
var parameterGroups = groupParameters(parameters, context);
|
|
14
|
-
var securities = 'securities' in data ? data.securities : [];
|
|
15
|
-
return (<>
|
|
16
|
-
{securities.length > 0 ? (<OpenAPISecurities key="securities" securities={securities} context={context}/>) : null}
|
|
17
|
-
|
|
18
|
-
{parameterGroups.map(function (group) {
|
|
19
|
-
return (<StaticSection key={"parameter-".concat(group.key)} className="openapi-parameters" header={group.label}>
|
|
20
|
-
<OpenAPISchemaProperties properties={group.parameters.map(parameterToProperty)} context={context}/>
|
|
21
|
-
</StaticSection>);
|
|
22
|
-
})}
|
|
23
|
-
|
|
24
|
-
{operation.requestBody ? (<OpenAPIRequestBody key="body" requestBody={operation.requestBody} context={context} data={data}/>) : null}
|
|
25
|
-
{operation.responses ? (<OpenAPIResponses key="responses" responses={operation.responses} context={context}/>) : null}
|
|
26
|
-
</>);
|
|
27
|
-
}
|
|
28
|
-
function groupParameters(parameters, context) {
|
|
29
|
-
var sorted = ['path', 'query', 'header'];
|
|
30
|
-
var groups = [];
|
|
31
|
-
parameters
|
|
32
|
-
.filter(function (parameter) { return parameter.in; })
|
|
33
|
-
.forEach(function (parameter) {
|
|
34
|
-
var key = parameter.in;
|
|
35
|
-
var label = getParameterGroupName(parameter.in, context);
|
|
36
|
-
var group = groups.find(function (group) { return group.key === key; });
|
|
37
|
-
if (group) {
|
|
38
|
-
group.parameters.push(parameter);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
groups.push({
|
|
42
|
-
key: key,
|
|
43
|
-
label: label,
|
|
44
|
-
parameters: [parameter],
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
groups.sort(function (a, b) { return sorted.indexOf(a.key) - sorted.indexOf(b.key); });
|
|
49
|
-
return groups;
|
|
50
|
-
}
|
|
51
|
-
function getParameterGroupName(paramIn, context) {
|
|
52
|
-
switch (paramIn) {
|
|
53
|
-
case 'path':
|
|
54
|
-
return tString(context.translation, 'path_parameters');
|
|
55
|
-
case 'query':
|
|
56
|
-
return tString(context.translation, 'query_parameters');
|
|
57
|
-
case 'header':
|
|
58
|
-
return tString(context.translation, 'header_parameters');
|
|
59
|
-
default:
|
|
60
|
-
return paramIn;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/** Deduplicate parameters by name and in.
|
|
64
|
-
* Some specs have both parameters define at path and operation level.
|
|
65
|
-
* We only want to display one of them.
|
|
66
|
-
* Parameters can have the wrong type (object instead of array) sometimes, we just return an empty array in that case.
|
|
67
|
-
*/
|
|
68
|
-
function deduplicateParameters(parameters) {
|
|
69
|
-
var seen = new Set();
|
|
70
|
-
return Array.isArray(parameters)
|
|
71
|
-
? parameters.filter(function (param) {
|
|
72
|
-
var key = "".concat(param.name, ":").concat(param.in);
|
|
73
|
-
if (seen.has(key)) {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
seen.add(key);
|
|
77
|
-
return true;
|
|
78
|
-
})
|
|
79
|
-
: [];
|
|
80
|
-
}
|
package/dist/OpenAPITabs.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type Key, type TabsProps } from 'react-aria-components';
|
|
2
|
-
export type TabItem = {
|
|
3
|
-
key: Key;
|
|
4
|
-
label: string;
|
|
5
|
-
body: React.ReactNode;
|
|
6
|
-
footer?: React.ReactNode;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* The OpenAPI Tabs wrapper component.
|
|
10
|
-
*/
|
|
11
|
-
export declare function OpenAPITabs(props: React.PropsWithChildren<TabsProps & {
|
|
12
|
-
items: TabItem[];
|
|
13
|
-
stateKey?: string;
|
|
14
|
-
}>): import("react").JSX.Element;
|
|
15
|
-
/**
|
|
16
|
-
* The OpenAPI Tabs list component.
|
|
17
|
-
* This component should be used as a child of the OpenAPITabs component.
|
|
18
|
-
* It renders the list of tabs.
|
|
19
|
-
*/
|
|
20
|
-
export declare function OpenAPITabsList(): import("react").JSX.Element;
|
|
21
|
-
/**
|
|
22
|
-
* The OpenAPI Tabs panels component.
|
|
23
|
-
* This component should be used as a child of the OpenAPITabs component.
|
|
24
|
-
* It renders the content of the selected tab.
|
|
25
|
-
*/
|
|
26
|
-
export declare function OpenAPITabsPanels(): import("react").JSX.Element | null;
|
package/dist/OpenAPITabs.jsx
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { createContext, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
-
import { Tab, TabList, TabPanel, Tabs } from 'react-aria-components';
|
|
4
|
-
import { useEventCallback } from 'usehooks-ts';
|
|
5
|
-
import { getOrCreateStoreByKey } from './getOrCreateStoreByKey';
|
|
6
|
-
var OpenAPITabsContext = createContext(null);
|
|
7
|
-
function useOpenAPITabsContext() {
|
|
8
|
-
var context = useContext(OpenAPITabsContext);
|
|
9
|
-
if (!context) {
|
|
10
|
-
throw new Error('OpenAPITabsContext is missing');
|
|
11
|
-
}
|
|
12
|
-
return context;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* The OpenAPI Tabs wrapper component.
|
|
16
|
-
*/
|
|
17
|
-
export function OpenAPITabs(props) {
|
|
18
|
-
var _a, _b;
|
|
19
|
-
var children = props.children, items = props.items, stateKey = props.stateKey;
|
|
20
|
-
var _c = useState(function () {
|
|
21
|
-
var _a, _b;
|
|
22
|
-
if (stateKey && typeof window !== 'undefined') {
|
|
23
|
-
var store = getOrCreateStoreByKey(stateKey);
|
|
24
|
-
var tabKey_1 = store.getState().key;
|
|
25
|
-
if (tabKey_1) {
|
|
26
|
-
return tabKey_1;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return (_b = (_a = items[0]) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : null;
|
|
30
|
-
}), tabKey = _c[0], setTabKey = _c[1];
|
|
31
|
-
var selectTab = useEventCallback(function (key) {
|
|
32
|
-
if (!key || key === tabKey) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
var tab = items.find(function (item) { return item.key === key; });
|
|
36
|
-
if (!tab) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
setTabKey(key);
|
|
40
|
-
});
|
|
41
|
-
var selectedTab = (_b = (_a = items.find(function (item) { return item.key === tabKey; })) !== null && _a !== void 0 ? _a : items[0]) !== null && _b !== void 0 ? _b : null;
|
|
42
|
-
var cancelDeferRef = useRef(null);
|
|
43
|
-
useEffect(function () {
|
|
44
|
-
if (!stateKey) {
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|
|
47
|
-
var store = getOrCreateStoreByKey(stateKey);
|
|
48
|
-
return store.subscribe(function (state) {
|
|
49
|
-
var _a;
|
|
50
|
-
(_a = cancelDeferRef.current) === null || _a === void 0 ? void 0 : _a.call(cancelDeferRef);
|
|
51
|
-
cancelDeferRef.current = defer(function () { return selectTab(state.key); });
|
|
52
|
-
});
|
|
53
|
-
}, [stateKey, selectTab]);
|
|
54
|
-
useEffect(function () {
|
|
55
|
-
return function () { var _a; return (_a = cancelDeferRef.current) === null || _a === void 0 ? void 0 : _a.call(cancelDeferRef); };
|
|
56
|
-
}, []);
|
|
57
|
-
var contextValue = useMemo(function () { return ({ items: items, selectedTab: selectedTab }); }, [items, selectedTab]);
|
|
58
|
-
return (<OpenAPITabsContext.Provider value={contextValue}>
|
|
59
|
-
<Tabs className="openapi-tabs" onSelectionChange={function (tabKey) {
|
|
60
|
-
selectTab(tabKey);
|
|
61
|
-
if (stateKey) {
|
|
62
|
-
var store = getOrCreateStoreByKey(stateKey);
|
|
63
|
-
store.setState({ key: tabKey });
|
|
64
|
-
}
|
|
65
|
-
}} selectedKey={tabKey}>
|
|
66
|
-
{children}
|
|
67
|
-
</Tabs>
|
|
68
|
-
</OpenAPITabsContext.Provider>);
|
|
69
|
-
}
|
|
70
|
-
var defer = function (fn) {
|
|
71
|
-
var id = setTimeout(fn, 0);
|
|
72
|
-
return function () { return clearTimeout(id); };
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* The OpenAPI Tabs list component.
|
|
76
|
-
* This component should be used as a child of the OpenAPITabs component.
|
|
77
|
-
* It renders the list of tabs.
|
|
78
|
-
*/
|
|
79
|
-
export function OpenAPITabsList() {
|
|
80
|
-
var items = useOpenAPITabsContext().items;
|
|
81
|
-
return (<TabList className="openapi-tabs-list">
|
|
82
|
-
{items.map(function (tab) { return (<Tab key={tab.key} id={tab.key} style={function (_a) {
|
|
83
|
-
var isFocusVisible = _a.isFocusVisible;
|
|
84
|
-
return ({
|
|
85
|
-
outline: isFocusVisible
|
|
86
|
-
? '2px solid rgb(var(--primary-color-500)/0.4)'
|
|
87
|
-
: 'none',
|
|
88
|
-
});
|
|
89
|
-
}} className="openapi-tabs-tab">
|
|
90
|
-
{tab.label}
|
|
91
|
-
</Tab>); })}
|
|
92
|
-
</TabList>);
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* The OpenAPI Tabs panels component.
|
|
96
|
-
* This component should be used as a child of the OpenAPITabs component.
|
|
97
|
-
* It renders the content of the selected tab.
|
|
98
|
-
*/
|
|
99
|
-
export function OpenAPITabsPanels() {
|
|
100
|
-
var selectedTab = useOpenAPITabsContext().selectedTab;
|
|
101
|
-
if (!selectedTab) {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
var key = selectedTab.key.toString();
|
|
105
|
-
return (<TabPanel id={key} className="openapi-tabs-panel">
|
|
106
|
-
<div className="openapi-panel-body">{selectedTab.body}</div>
|
|
107
|
-
{selectedTab.footer ? (<div className="openapi-panel-footer">{selectedTab.footer}</div>) : null}
|
|
108
|
-
</TabPanel>);
|
|
109
|
-
}
|
package/dist/OpenAPIWebhook.jsx
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
|
-
import { OpenAPIWebhookExample } from './OpenAPIWebhookExample';
|
|
3
|
-
import { OpenAPIColumnSpec } from './common/OpenAPIColumnSpec';
|
|
4
|
-
import { OpenAPISummary } from './common/OpenAPISummary';
|
|
5
|
-
import { resolveOpenAPIContext } from './context';
|
|
6
|
-
/**
|
|
7
|
-
* Display an interactive OpenAPI webhook.
|
|
8
|
-
*/
|
|
9
|
-
export function OpenAPIWebhook(props) {
|
|
10
|
-
var className = props.className, data = props.data, contextInput = props.context;
|
|
11
|
-
var context = resolveOpenAPIContext(contextInput);
|
|
12
|
-
return (<div className={clsx('openapi-webhook', className)}>
|
|
13
|
-
<OpenAPISummary data={data} context={context}/>
|
|
14
|
-
<div className="openapi-columns">
|
|
15
|
-
<OpenAPIColumnSpec data={data} context={context}/>
|
|
16
|
-
<div className="openapi-column-preview">
|
|
17
|
-
<div className="openapi-column-preview-body">
|
|
18
|
-
<OpenAPIWebhookExample data={data} context={context}/>
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
</div>);
|
|
23
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { OpenAPIEmptyExample } from './OpenAPIExample';
|
|
2
|
-
import { OpenAPIMediaTypeContent } from './OpenAPIMediaType';
|
|
3
|
-
import { getOpenAPIClientContext } from './context';
|
|
4
|
-
import { getExamples } from './util/example';
|
|
5
|
-
import { createStateKey } from './utils';
|
|
6
|
-
export function OpenAPIWebhookExample(props) {
|
|
7
|
-
var data = props.data, context = props.context;
|
|
8
|
-
var operation = data.operation;
|
|
9
|
-
var items = (function () {
|
|
10
|
-
if (!operation.requestBody) {
|
|
11
|
-
return [];
|
|
12
|
-
}
|
|
13
|
-
return Object.entries(operation.requestBody.content).map(function (_a) {
|
|
14
|
-
var key = _a[0], value = _a[1];
|
|
15
|
-
var schema = value === null || value === void 0 ? void 0 : value.schema;
|
|
16
|
-
if (!schema) {
|
|
17
|
-
return {
|
|
18
|
-
key: key,
|
|
19
|
-
label: key,
|
|
20
|
-
body: <OpenAPIEmptyExample context={context}/>,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
key: key,
|
|
25
|
-
label: key,
|
|
26
|
-
body: <></>,
|
|
27
|
-
examples: getExamples({
|
|
28
|
-
mediaTypeObject: value,
|
|
29
|
-
mediaType: key,
|
|
30
|
-
context: context,
|
|
31
|
-
}),
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
})();
|
|
35
|
-
return (<div className="openapi-panel">
|
|
36
|
-
<h4 className="openapi-panel-heading">Payload</h4>
|
|
37
|
-
<div className="openapi-panel-body">
|
|
38
|
-
<OpenAPIMediaTypeContent selectIcon={context.icons.chevronDown} stateKey={createStateKey('request-body-media-type', context.blockKey)} items={items} context={getOpenAPIClientContext(context)}/>
|
|
39
|
-
</div>
|
|
40
|
-
</div>);
|
|
41
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { OpenAPIV3_1 } from '@gitbook/openapi-parser';
|
|
2
|
-
import type { OpenAPIClientContext } from './context';
|
|
3
|
-
import type { OpenAPIOperationData } from './types';
|
|
4
|
-
/**
|
|
5
|
-
* Button which launches the Scalar API Client
|
|
6
|
-
*/
|
|
7
|
-
export declare function ScalarApiButton(props: {
|
|
8
|
-
method: OpenAPIV3_1.HttpMethods;
|
|
9
|
-
path: string;
|
|
10
|
-
securities: OpenAPIOperationData['securities'];
|
|
11
|
-
servers: OpenAPIOperationData['servers'];
|
|
12
|
-
specUrl: string;
|
|
13
|
-
context: OpenAPIClientContext;
|
|
14
|
-
}): import("react").JSX.Element;
|
package/dist/ScalarApiButton.jsx
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
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
|
-
import { ApiClientModalProvider, useApiClientModal } from '@scalar/api-client-react';
|
|
14
|
-
import { Suspense, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
15
|
-
import { createPortal } from 'react-dom';
|
|
16
|
-
import { useOpenAPIOperationContext } from './OpenAPIOperationContext';
|
|
17
|
-
import { useOpenAPIPrefillContext } from './OpenAPIPrefillContextProvider';
|
|
18
|
-
import { t } from './translate';
|
|
19
|
-
import { resolveTryItPrefillForOperation } from './util/tryit-prefill';
|
|
20
|
-
/**
|
|
21
|
-
* Button which launches the Scalar API Client
|
|
22
|
-
*/
|
|
23
|
-
export function ScalarApiButton(props) {
|
|
24
|
-
var method = props.method, path = props.path, securities = props.securities, servers = props.servers, specUrl = props.specUrl, context = props.context;
|
|
25
|
-
var _a = useState(false), isOpen = _a[0], setIsOpen = _a[1];
|
|
26
|
-
var controllerRef = useRef(null);
|
|
27
|
-
return (<div className="scalar scalar-activate">
|
|
28
|
-
<button className="scalar-activate-button button" onClick={function () {
|
|
29
|
-
var _a, _b;
|
|
30
|
-
(_b = (_a = controllerRef.current) === null || _a === void 0 ? void 0 : _a.openClient) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
31
|
-
setIsOpen(true);
|
|
32
|
-
}}>
|
|
33
|
-
{t(context.translation, 'test_it')}
|
|
34
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 12" fill="currentColor">
|
|
35
|
-
<path stroke="currentColor" strokeWidth="1.5" d="M1 10.05V1.43c0-.2.2-.31.37-.22l7.26 4.08c.17.1.17.33.01.43l-7.26 4.54a.25.25 0 0 1-.38-.21Z"/>
|
|
36
|
-
</svg>
|
|
37
|
-
</button>
|
|
38
|
-
|
|
39
|
-
{isOpen &&
|
|
40
|
-
createPortal(<Suspense fallback={null}>
|
|
41
|
-
<ScalarModal controllerRef={controllerRef} method={method} path={path} securities={securities} servers={servers} specUrl={specUrl}/>
|
|
42
|
-
</Suspense>, document.body)}
|
|
43
|
-
</div>);
|
|
44
|
-
}
|
|
45
|
-
function ScalarModal(props) {
|
|
46
|
-
var method = props.method, path = props.path, securities = props.securities, servers = props.servers, specUrl = props.specUrl, controllerRef = props.controllerRef;
|
|
47
|
-
var getPrefillInputContextData = useOpenAPIPrefillContext();
|
|
48
|
-
var prefillInputContext = getPrefillInputContextData();
|
|
49
|
-
var prefillConfig = resolveTryItPrefillForOperation({
|
|
50
|
-
operation: { securities: securities, servers: servers },
|
|
51
|
-
prefillInputContext: prefillInputContext,
|
|
52
|
-
});
|
|
53
|
-
return (<ApiClientModalProvider configuration={__assign({ url: specUrl }, prefillConfig)} initialRequest={{ method: method, path: path }}>
|
|
54
|
-
<ScalarModalController method={method} path={path} controllerRef={controllerRef}/>
|
|
55
|
-
</ApiClientModalProvider>);
|
|
56
|
-
}
|
|
57
|
-
function ScalarModalController(props) {
|
|
58
|
-
var method = props.method, path = props.path, controllerRef = props.controllerRef;
|
|
59
|
-
var client = useApiClientModal();
|
|
60
|
-
var openScalarClient = client === null || client === void 0 ? void 0 : client.open;
|
|
61
|
-
var trackClientOpening = useOpenAPIOperationContext().onOpenClient;
|
|
62
|
-
var openClient = useMemo(function () {
|
|
63
|
-
if (openScalarClient) {
|
|
64
|
-
return function () {
|
|
65
|
-
openScalarClient({
|
|
66
|
-
method: method,
|
|
67
|
-
path: path,
|
|
68
|
-
_source: 'gitbook',
|
|
69
|
-
});
|
|
70
|
-
trackClientOpening({ method: method, path: path });
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
return null;
|
|
74
|
-
}, [openScalarClient, method, path, trackClientOpening]);
|
|
75
|
-
useImperativeHandle(controllerRef, function () { return ({ openClient: openClient ? function () { return openClient(); } : undefined }); }, [openClient]);
|
|
76
|
-
// Open at mount
|
|
77
|
-
useEffect(function () {
|
|
78
|
-
openClient === null || openClient === void 0 ? void 0 : openClient();
|
|
79
|
-
}, [openClient]);
|
|
80
|
-
return null;
|
|
81
|
-
}
|
package/dist/StaticSection.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
|
-
export declare function Section(props: ComponentPropsWithoutRef<'div'>): import("react").JSX.Element;
|
|
3
|
-
export declare function SectionHeader(props: ComponentPropsWithoutRef<'div'>): import("react").JSX.Element;
|
|
4
|
-
export declare function SectionHeaderContent(props: ComponentPropsWithoutRef<'div'>): import("react").JSX.Element;
|
|
5
|
-
export declare const SectionBody: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
6
|
-
export declare function SectionFooter(props: ComponentPropsWithoutRef<'div'>): import("react").JSX.Element;
|
|
7
|
-
export declare function SectionFooterContent(props: ComponentPropsWithoutRef<'div'>): import("react").JSX.Element;
|
|
8
|
-
export declare function StaticSection(props: {
|
|
9
|
-
className: string;
|
|
10
|
-
header?: React.ReactNode;
|
|
11
|
-
children: React.ReactNode;
|
|
12
|
-
footer?: React.ReactNode;
|
|
13
|
-
}): import("react").JSX.Element;
|
package/dist/StaticSection.jsx
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
export function Section(props) {
|
|
4
|
-
return <div {...props} className={clsx('openapi-section', props.className)}/>;
|
|
5
|
-
}
|
|
6
|
-
export function SectionHeader(props) {
|
|
7
|
-
return (<div {...props} className={clsx('openapi-section-header', props.className ? "".concat(props.className, "-header") : undefined)}/>);
|
|
8
|
-
}
|
|
9
|
-
export function SectionHeaderContent(props) {
|
|
10
|
-
return (<div {...props} className={clsx('openapi-section-header-content', props.className && "".concat(props.className, "-header-content"))}/>);
|
|
11
|
-
}
|
|
12
|
-
export var SectionBody = forwardRef(function SectionBody(props, ref) {
|
|
13
|
-
return (<div ref={ref} {...props} className={clsx('openapi-section-body', props.className && "".concat(props.className, "-body"))}/>);
|
|
14
|
-
});
|
|
15
|
-
export function SectionFooter(props) {
|
|
16
|
-
return (<div {...props} className={clsx('openapi-section-footer', props.className && "".concat(props.className, "-footer"))}/>);
|
|
17
|
-
}
|
|
18
|
-
export function SectionFooterContent(props) {
|
|
19
|
-
return (<div {...props} className={clsx('openapi-section-footer-content', props.className && "".concat(props.className, "-footer-content"))}/>);
|
|
20
|
-
}
|
|
21
|
-
export function StaticSection(props) {
|
|
22
|
-
var className = props.className, header = props.header, children = props.children, footer = props.footer;
|
|
23
|
-
return (<Section className={className}>
|
|
24
|
-
{header ? (<SectionHeader className={className}>
|
|
25
|
-
<SectionHeaderContent className={className}>{header}</SectionHeaderContent>
|
|
26
|
-
</SectionHeader>) : null}
|
|
27
|
-
<SectionBody className={className}>{children}</SectionBody>
|
|
28
|
-
{footer ? (<SectionFooter className={className}>
|
|
29
|
-
<SectionFooterContent className={className}>{footer}</SectionFooterContent>
|
|
30
|
-
</SectionFooter>) : null}
|
|
31
|
-
</Section>);
|
|
32
|
-
}
|
package/dist/code-samples.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export interface CodeSampleInput {
|
|
2
|
-
method: string;
|
|
3
|
-
url: string;
|
|
4
|
-
headers?: Record<string, string>;
|
|
5
|
-
body?: any;
|
|
6
|
-
}
|
|
7
|
-
export interface CodeSampleGenerator {
|
|
8
|
-
id: string;
|
|
9
|
-
label: string;
|
|
10
|
-
syntax: string;
|
|
11
|
-
generate: (operation: CodeSampleInput) => string;
|
|
12
|
-
}
|
|
13
|
-
export declare const codeSampleGenerators: CodeSampleGenerator[];
|
|
14
|
-
export declare function parseHostAndPath(url: string): {
|
|
15
|
-
host: string | undefined;
|
|
16
|
-
path: string;
|
|
17
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type OpenAPIContext } from '../context';
|
|
2
|
-
import type { OpenAPIOperationData, OpenAPIWebhookData } from '../types';
|
|
3
|
-
export declare function OpenAPIColumnSpec(props: {
|
|
4
|
-
data: OpenAPIOperationData | OpenAPIWebhookData;
|
|
5
|
-
context: OpenAPIContext;
|
|
6
|
-
}): import("react").JSX.Element;
|