@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
package/dist/util/example.jsx
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { OpenAPIExample } from '../OpenAPIExample';
|
|
2
|
-
import { generateSchemaExample } from '../generateSchemaExample';
|
|
3
|
-
import { tString } from '../translate';
|
|
4
|
-
import { checkIsReference } from '../utils';
|
|
5
|
-
/**
|
|
6
|
-
* Generate an example from a reference object.
|
|
7
|
-
*/
|
|
8
|
-
export function getExampleFromReference(ref, context) {
|
|
9
|
-
return {
|
|
10
|
-
summary: tString(context.translation, 'unresolved_reference'),
|
|
11
|
-
value: { $ref: ref.$ref },
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Get examples from a media type object.
|
|
16
|
-
*/
|
|
17
|
-
export function getExamplesFromMediaTypeObject(args) {
|
|
18
|
-
var _a;
|
|
19
|
-
var _b, _c;
|
|
20
|
-
var mediaTypeObject = args.mediaTypeObject, mediaType = args.mediaType, context = args.context;
|
|
21
|
-
if (mediaTypeObject.examples) {
|
|
22
|
-
return Object.entries(mediaTypeObject.examples).map(function (_a) {
|
|
23
|
-
var key = _a[0], example = _a[1];
|
|
24
|
-
return {
|
|
25
|
-
key: key,
|
|
26
|
-
example: checkIsReference(example)
|
|
27
|
-
? getExampleFromReference(example, context)
|
|
28
|
-
: example,
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
if (mediaTypeObject.example) {
|
|
33
|
-
return [{ key: 'default', example: { value: mediaTypeObject.example } }];
|
|
34
|
-
}
|
|
35
|
-
if (mediaTypeObject.schema) {
|
|
36
|
-
if (mediaType === 'application/xml') {
|
|
37
|
-
// @TODO normally we should use the name of the schema but we don't have it
|
|
38
|
-
// fix it when we got the reference name
|
|
39
|
-
var root = (_c = (_b = mediaTypeObject.schema.xml) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : 'object';
|
|
40
|
-
return [
|
|
41
|
-
{
|
|
42
|
-
key: 'default',
|
|
43
|
-
example: {
|
|
44
|
-
value: (_a = {},
|
|
45
|
-
_a[root] = generateSchemaExample(mediaTypeObject.schema, {
|
|
46
|
-
xml: mediaType === 'application/xml',
|
|
47
|
-
mode: 'read',
|
|
48
|
-
}),
|
|
49
|
-
_a),
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
];
|
|
53
|
-
}
|
|
54
|
-
return [
|
|
55
|
-
{
|
|
56
|
-
key: 'default',
|
|
57
|
-
example: {
|
|
58
|
-
value: generateSchemaExample(mediaTypeObject.schema, {
|
|
59
|
-
mode: 'read',
|
|
60
|
-
}),
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
];
|
|
64
|
-
}
|
|
65
|
-
return [];
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Get example from a schema object.
|
|
69
|
-
*/
|
|
70
|
-
export function getExampleFromSchema(args) {
|
|
71
|
-
var schema = args.schema;
|
|
72
|
-
if (schema.example) {
|
|
73
|
-
return { value: schema.example };
|
|
74
|
-
}
|
|
75
|
-
return { value: generateSchemaExample(schema, { mode: 'read' }) };
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Get the examples from a media type object.
|
|
79
|
-
*/
|
|
80
|
-
export function getExamples(props) {
|
|
81
|
-
var mediaTypeObject = props.mediaTypeObject, mediaType = props.mediaType, context = props.context;
|
|
82
|
-
var examples = getExamplesFromMediaTypeObject({ mediaTypeObject: mediaTypeObject, mediaType: mediaType, context: context });
|
|
83
|
-
var syntax = getSyntaxFromMediaType(mediaType);
|
|
84
|
-
return examples.map(function (example) {
|
|
85
|
-
return {
|
|
86
|
-
key: example.key,
|
|
87
|
-
label: example.example.summary || example.key,
|
|
88
|
-
body: (<OpenAPIExample example={example.example} context={props.context} syntax={syntax}/>),
|
|
89
|
-
};
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Get the syntax from a media type.
|
|
94
|
-
*/
|
|
95
|
-
function getSyntaxFromMediaType(mediaType) {
|
|
96
|
-
if (mediaType.includes('json')) {
|
|
97
|
-
return 'json';
|
|
98
|
-
}
|
|
99
|
-
if (mediaType === 'application/xml') {
|
|
100
|
-
return 'xml';
|
|
101
|
-
}
|
|
102
|
-
return 'text';
|
|
103
|
-
}
|
package/dist/util/server.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { OpenAPIV3 } from '@gitbook/openapi-parser';
|
|
2
|
-
/**
|
|
3
|
-
* Get the default URL for the server.
|
|
4
|
-
*/
|
|
5
|
-
export declare function getDefaultServerURL(servers: OpenAPIV3.ServerObject[]): string;
|
|
6
|
-
/**
|
|
7
|
-
* Interpolate the server URL with the default values of the variables.
|
|
8
|
-
*/
|
|
9
|
-
export declare function interpolateServerURL(server: OpenAPIV3.ServerObject): string;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ApiClientConfiguration } from '@scalar/types';
|
|
2
|
-
import type { PrefillInputContextData } from '../OpenAPIPrefillContextProvider';
|
|
3
|
-
import type { OpenAPIOperationData } from '../types';
|
|
4
|
-
export interface TryItPrefillConfiguration {
|
|
5
|
-
authentication?: ApiClientConfiguration['authentication'];
|
|
6
|
-
servers?: ApiClientConfiguration['servers'];
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Resolve the Scalar API client prefill configuration for a given OpenAPI operation.
|
|
10
|
-
*/
|
|
11
|
-
export declare function resolveTryItPrefillForOperation(args: {
|
|
12
|
-
/**
|
|
13
|
-
* The parsed OpenAPI operation.
|
|
14
|
-
*/
|
|
15
|
-
operation: Pick<OpenAPIOperationData, 'securities' | 'servers'>;
|
|
16
|
-
/**
|
|
17
|
-
* Prefill input context data.
|
|
18
|
-
*/
|
|
19
|
-
prefillInputContext: PrefillInputContextData | null;
|
|
20
|
-
}): TryItPrefillConfiguration;
|
package/dist/utils.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { AnyObject, OpenAPIV3, OpenAPIV3_1 } from '@gitbook/openapi-parser';
|
|
2
|
-
import type { OpenAPIUniversalContext } from './context';
|
|
3
|
-
export declare function checkIsReference(input: unknown): input is OpenAPIV3.ReferenceObject;
|
|
4
|
-
export declare function createStateKey(key: string, scope?: string): string;
|
|
5
|
-
/**
|
|
6
|
-
* Resolve the description of an object.
|
|
7
|
-
*/
|
|
8
|
-
export declare function resolveDescription(object: OpenAPIV3.SchemaObject | AnyObject): string | undefined;
|
|
9
|
-
/**
|
|
10
|
-
* Extract descriptions from an object.
|
|
11
|
-
*/
|
|
12
|
-
export declare function extractDescriptions(object: AnyObject): {
|
|
13
|
-
description: any;
|
|
14
|
-
'x-gitbook-description-html': any;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Resolve the first example from an object.
|
|
18
|
-
*/
|
|
19
|
-
export declare function resolveFirstExample(object: AnyObject): string | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Resolve the schema of a parameter.
|
|
22
|
-
* Extract the description, example and deprecated from parameter.
|
|
23
|
-
*/
|
|
24
|
-
export declare function resolveParameterSchema(parameter: OpenAPIV3.ParameterBaseObject): OpenAPIV3.SchemaObject;
|
|
25
|
-
/**
|
|
26
|
-
* Transform a parameter object to a property object.
|
|
27
|
-
*/
|
|
28
|
-
export declare function parameterToProperty(parameter: OpenAPIV3.ParameterObject | OpenAPIV3.ReferenceObject | OpenAPIV3_1.ReferenceObject): {
|
|
29
|
-
propertyName: string | undefined;
|
|
30
|
-
schema: OpenAPIV3.SchemaObject;
|
|
31
|
-
required: boolean | undefined;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Get the class name for a status code.
|
|
35
|
-
* 1xx: informational
|
|
36
|
-
* 2xx: success
|
|
37
|
-
* 3xx: redirect
|
|
38
|
-
* 4xx, 5xx: error
|
|
39
|
-
*/
|
|
40
|
-
export declare function getStatusCodeClassName(statusCode: number | string): string;
|
|
41
|
-
/**
|
|
42
|
-
* Get a default label for a status code.
|
|
43
|
-
* This is used when there is no label provided in the OpenAPI spec.
|
|
44
|
-
* 1xx: Information
|
|
45
|
-
* 2xx: Success
|
|
46
|
-
* 3xx: Redirect
|
|
47
|
-
* 4xx, 5xx: Error
|
|
48
|
-
*/
|
|
49
|
-
export declare function getStatusCodeDefaultLabel(statusCode: number | string, context: OpenAPIUniversalContext): string;
|
|
50
|
-
export declare function getSchemaTitle(schema: OpenAPIV3.SchemaObject): string;
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import { useRef } from 'react';
|
|
5
|
-
import { mergeProps, useButton, useDisclosure, useFocusRing } from 'react-aria';
|
|
6
|
-
import { useDisclosureState } from 'react-stately';
|
|
7
|
-
import { OpenAPISelect, OpenAPISelectItem, useSelectState } from './OpenAPISelect';
|
|
8
|
-
import { Section, SectionBody, SectionHeader, SectionHeaderContent } from './StaticSection';
|
|
9
|
-
|
|
10
|
-
interface InteractiveSectionTab {
|
|
11
|
-
key: string;
|
|
12
|
-
label: string;
|
|
13
|
-
body: React.ReactNode;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* To optimize rendering, most of the components are server-components,
|
|
18
|
-
* and the interactiveness is mainly handled by a few key components like this one.
|
|
19
|
-
*/
|
|
20
|
-
export function InteractiveSection(props: {
|
|
21
|
-
id?: string;
|
|
22
|
-
/** Class name to be set on the section, sub-elements will use it as prefix */
|
|
23
|
-
className: string;
|
|
24
|
-
/** If true, the content can be toggeable */
|
|
25
|
-
toggeable?: boolean;
|
|
26
|
-
/** Default state of the toggle */
|
|
27
|
-
defaultOpened?: boolean;
|
|
28
|
-
/** Icon to display for the toggle */
|
|
29
|
-
toggleIcon?: React.ReactNode;
|
|
30
|
-
/** Tabs of content to display */
|
|
31
|
-
tabs?: Array<InteractiveSectionTab>;
|
|
32
|
-
/** Default tab to have opened */
|
|
33
|
-
defaultTab?: string;
|
|
34
|
-
/** Content of the header */
|
|
35
|
-
header?: React.ReactNode;
|
|
36
|
-
/** Children to display within the container */
|
|
37
|
-
overlay?: React.ReactNode;
|
|
38
|
-
/** State key to use with a store */
|
|
39
|
-
stateKey?: string;
|
|
40
|
-
/** Icon for the tabs select */
|
|
41
|
-
selectIcon?: React.ReactNode;
|
|
42
|
-
}) {
|
|
43
|
-
const {
|
|
44
|
-
id,
|
|
45
|
-
className,
|
|
46
|
-
toggeable = false,
|
|
47
|
-
defaultOpened = true,
|
|
48
|
-
tabs = [],
|
|
49
|
-
defaultTab = tabs[0]?.key,
|
|
50
|
-
header,
|
|
51
|
-
overlay,
|
|
52
|
-
toggleIcon = '▶',
|
|
53
|
-
selectIcon,
|
|
54
|
-
stateKey = 'interactive-section',
|
|
55
|
-
} = props;
|
|
56
|
-
const state = useDisclosureState({
|
|
57
|
-
defaultExpanded: defaultOpened,
|
|
58
|
-
});
|
|
59
|
-
const panelRef = useRef<HTMLDivElement | null>(null);
|
|
60
|
-
const triggerRef = useRef<HTMLButtonElement | null>(null);
|
|
61
|
-
const { buttonProps: triggerProps, panelProps } = useDisclosure({}, state, panelRef);
|
|
62
|
-
const { buttonProps } = useButton(triggerProps, triggerRef);
|
|
63
|
-
const { isFocusVisible, focusProps } = useFocusRing();
|
|
64
|
-
const store = useSelectState(stateKey, defaultTab);
|
|
65
|
-
|
|
66
|
-
const selectedTab: InteractiveSectionTab | undefined =
|
|
67
|
-
tabs.find((tab) => tab.key === store.key) ?? tabs[0];
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<Section
|
|
71
|
-
id={id}
|
|
72
|
-
className={clsx(
|
|
73
|
-
'openapi-section',
|
|
74
|
-
toggeable ? 'openapi-section-toggeable' : null,
|
|
75
|
-
className,
|
|
76
|
-
toggeable ? `${className}-${state.isExpanded ? 'opened' : 'closed'}` : null
|
|
77
|
-
)}
|
|
78
|
-
>
|
|
79
|
-
{header ? (
|
|
80
|
-
<SectionHeader
|
|
81
|
-
onClick={() => {
|
|
82
|
-
if (toggeable) {
|
|
83
|
-
state.toggle();
|
|
84
|
-
}
|
|
85
|
-
}}
|
|
86
|
-
className={className}
|
|
87
|
-
>
|
|
88
|
-
<SectionHeaderContent className={className}>
|
|
89
|
-
{selectedTab?.body && toggeable ? (
|
|
90
|
-
<button
|
|
91
|
-
{...mergeProps(buttonProps, focusProps)}
|
|
92
|
-
ref={triggerRef}
|
|
93
|
-
className={clsx('openapi-section-toggle', `${className}-toggle`)}
|
|
94
|
-
style={{
|
|
95
|
-
outline: isFocusVisible
|
|
96
|
-
? '2px solid rgb(var(--primary-color-500) / 0.4)'
|
|
97
|
-
: 'none',
|
|
98
|
-
}}
|
|
99
|
-
>
|
|
100
|
-
{toggleIcon}
|
|
101
|
-
</button>
|
|
102
|
-
) : null}
|
|
103
|
-
{header}
|
|
104
|
-
</SectionHeaderContent>
|
|
105
|
-
{/* biome-ignore lint/a11y/useKeyWithClickEvents: we prevent default here */}
|
|
106
|
-
<div
|
|
107
|
-
className={clsx(
|
|
108
|
-
'openapi-section-header-controls',
|
|
109
|
-
`${className}-header-controls`
|
|
110
|
-
)}
|
|
111
|
-
onClick={(event) => {
|
|
112
|
-
event.stopPropagation();
|
|
113
|
-
}}
|
|
114
|
-
>
|
|
115
|
-
{tabs.length > 0 ? (
|
|
116
|
-
<OpenAPISelect
|
|
117
|
-
stateKey={stateKey}
|
|
118
|
-
items={tabs}
|
|
119
|
-
onSelectionChange={() => {
|
|
120
|
-
state.expand();
|
|
121
|
-
}}
|
|
122
|
-
icon={selectIcon}
|
|
123
|
-
placement="bottom end"
|
|
124
|
-
>
|
|
125
|
-
{tabs.map((tab) => (
|
|
126
|
-
<OpenAPISelectItem key={tab.key} id={tab.key} value={tab}>
|
|
127
|
-
{tab.label}
|
|
128
|
-
</OpenAPISelectItem>
|
|
129
|
-
))}
|
|
130
|
-
</OpenAPISelect>
|
|
131
|
-
) : null}
|
|
132
|
-
</div>
|
|
133
|
-
</SectionHeader>
|
|
134
|
-
) : null}
|
|
135
|
-
{(!toggeable || state.isExpanded) && selectedTab?.body ? (
|
|
136
|
-
<SectionBody ref={panelRef} {...panelProps} className={className}>
|
|
137
|
-
{selectedTab?.body}
|
|
138
|
-
</SectionBody>
|
|
139
|
-
) : null}
|
|
140
|
-
{overlay ? (
|
|
141
|
-
<div className={clsx('openapi-section-overlay', `${className}-overlay`)}>
|
|
142
|
-
{overlay}
|
|
143
|
-
</div>
|
|
144
|
-
) : null}
|
|
145
|
-
</Section>
|
|
146
|
-
);
|
|
147
|
-
}
|
package/src/Markdown.tsx
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
|
-
|
|
3
|
-
export function Markdown(props: { source: string; className?: string }) {
|
|
4
|
-
const { source, className } = props;
|
|
5
|
-
|
|
6
|
-
return (
|
|
7
|
-
<div
|
|
8
|
-
className={clsx('openapi-markdown', className)}
|
|
9
|
-
dangerouslySetInnerHTML={{ __html: source }}
|
|
10
|
-
/>
|
|
11
|
-
);
|
|
12
|
-
}
|
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
import type { OpenAPIV3 } from '@gitbook/openapi-parser';
|
|
2
|
-
import {
|
|
3
|
-
OpenAPIMediaTypeExamplesBody,
|
|
4
|
-
OpenAPIMediaTypeExamplesSelector,
|
|
5
|
-
} from './OpenAPICodeSampleInteractive';
|
|
6
|
-
import { OpenAPICodeSampleBody } from './OpenAPICodeSampleSelector';
|
|
7
|
-
import { ScalarApiButton } from './ScalarApiButton';
|
|
8
|
-
import { type CodeSampleGenerator, codeSampleGenerators } from './code-samples';
|
|
9
|
-
import { type OpenAPIContext, getOpenAPIClientContext } from './context';
|
|
10
|
-
import { generateMediaTypeExamples, generateSchemaExample } from './generateSchemaExample';
|
|
11
|
-
import { stringifyOpenAPI } from './stringifyOpenAPI';
|
|
12
|
-
import type { OpenAPIOperationData } from './types';
|
|
13
|
-
import { getDefaultServerURL } from './util/server';
|
|
14
|
-
import { checkIsReference } from './utils';
|
|
15
|
-
|
|
16
|
-
const CUSTOM_CODE_SAMPLES_KEYS = ['x-custom-examples', 'x-code-samples', 'x-codeSamples'] as const;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Display code samples to execute the operation.
|
|
20
|
-
* It supports the Redocly custom syntax as well (https://redocly.com/docs/api-reference-docs/specification-extensions/x-code-samples/)
|
|
21
|
-
*/
|
|
22
|
-
export function OpenAPICodeSample(props: {
|
|
23
|
-
data: OpenAPIOperationData;
|
|
24
|
-
context: OpenAPIContext;
|
|
25
|
-
}) {
|
|
26
|
-
const { data, context } = props;
|
|
27
|
-
|
|
28
|
-
// If code samples are disabled at operation level, we don't display the code samples.
|
|
29
|
-
if (data.operation['x-codeSamples'] === false) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const customCodeSamples = getCustomCodeSamples(props);
|
|
34
|
-
|
|
35
|
-
// If code samples are disabled at the top-level and not custom code samples are defined,
|
|
36
|
-
// we don't display the code samples.
|
|
37
|
-
if (data['x-codeSamples'] === false && !customCodeSamples) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const samples = customCodeSamples ?? generateCodeSamples(props);
|
|
42
|
-
|
|
43
|
-
if (samples.length === 0) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<OpenAPICodeSampleBody
|
|
49
|
-
context={getOpenAPIClientContext(context)}
|
|
50
|
-
data={data}
|
|
51
|
-
items={samples}
|
|
52
|
-
selectIcon={context.icons.chevronDown}
|
|
53
|
-
/>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Generate code samples for the operation.
|
|
59
|
-
*/
|
|
60
|
-
function generateCodeSamples(props: {
|
|
61
|
-
data: OpenAPIOperationData;
|
|
62
|
-
context: OpenAPIContext;
|
|
63
|
-
}) {
|
|
64
|
-
const { data, context } = props;
|
|
65
|
-
|
|
66
|
-
const searchParams = new URLSearchParams();
|
|
67
|
-
const headersObject: { [k: string]: string } = {};
|
|
68
|
-
|
|
69
|
-
// The parser can sometimes returns invalid parameters (an object instead of an array).
|
|
70
|
-
// It should get fixed in scalar, but in the meantime we just ignore the parameters in that case.
|
|
71
|
-
const params = Array.isArray(data.operation.parameters) ? data.operation.parameters : [];
|
|
72
|
-
|
|
73
|
-
params.forEach((param) => {
|
|
74
|
-
if (!param) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (param.in === 'header' && param.required) {
|
|
79
|
-
const example = param.schema
|
|
80
|
-
? generateSchemaExample(param.schema, { mode: 'write' })
|
|
81
|
-
: undefined;
|
|
82
|
-
if (example !== undefined && param.name) {
|
|
83
|
-
headersObject[param.name] =
|
|
84
|
-
typeof example !== 'string' ? stringifyOpenAPI(example) : example;
|
|
85
|
-
}
|
|
86
|
-
} else if (param.in === 'query' && param.required) {
|
|
87
|
-
const example = param.schema
|
|
88
|
-
? generateSchemaExample(param.schema, { mode: 'write' })
|
|
89
|
-
: undefined;
|
|
90
|
-
if (example !== undefined && param.name) {
|
|
91
|
-
searchParams.append(
|
|
92
|
-
param.name,
|
|
93
|
-
String(Array.isArray(example) ? example[0] : example)
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
const requestBody = !checkIsReference(data.operation.requestBody)
|
|
100
|
-
? data.operation.requestBody
|
|
101
|
-
: undefined;
|
|
102
|
-
|
|
103
|
-
const url =
|
|
104
|
-
getDefaultServerURL(data.servers) +
|
|
105
|
-
data.path +
|
|
106
|
-
(searchParams.size ? `?${searchParams.toString()}` : '');
|
|
107
|
-
|
|
108
|
-
const genericHeaders = {
|
|
109
|
-
...getSecurityHeaders(data.securities),
|
|
110
|
-
...headersObject,
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const mediaTypeRendererFactories = Object.entries(requestBody?.content ?? {}).map(
|
|
114
|
-
([mediaType, mediaTypeObject]) => {
|
|
115
|
-
return (generator: CodeSampleGenerator) => {
|
|
116
|
-
const mediaTypeHeaders = {
|
|
117
|
-
...genericHeaders,
|
|
118
|
-
'Content-Type': mediaType,
|
|
119
|
-
};
|
|
120
|
-
return {
|
|
121
|
-
mediaType,
|
|
122
|
-
element: context.renderCodeBlock({
|
|
123
|
-
code: generator.generate({
|
|
124
|
-
url,
|
|
125
|
-
method: data.method,
|
|
126
|
-
body: undefined,
|
|
127
|
-
headers: mediaTypeHeaders,
|
|
128
|
-
}),
|
|
129
|
-
syntax: generator.syntax,
|
|
130
|
-
}),
|
|
131
|
-
examples: generateMediaTypeExamples(mediaTypeObject, {
|
|
132
|
-
mode: 'write',
|
|
133
|
-
}).map((example) => ({
|
|
134
|
-
example,
|
|
135
|
-
element: context.renderCodeBlock({
|
|
136
|
-
code: generator.generate({
|
|
137
|
-
url,
|
|
138
|
-
method: data.method,
|
|
139
|
-
body: example.value,
|
|
140
|
-
headers: mediaTypeHeaders,
|
|
141
|
-
}),
|
|
142
|
-
syntax: generator.syntax,
|
|
143
|
-
}),
|
|
144
|
-
})),
|
|
145
|
-
} satisfies MediaTypeRenderer;
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
return codeSampleGenerators.map((generator) => {
|
|
151
|
-
if (mediaTypeRendererFactories.length > 0) {
|
|
152
|
-
const renderers = mediaTypeRendererFactories.map((generate) => generate(generator));
|
|
153
|
-
return {
|
|
154
|
-
key: `default-${generator.id}`,
|
|
155
|
-
label: generator.label,
|
|
156
|
-
body: (
|
|
157
|
-
<OpenAPIMediaTypeExamplesBody
|
|
158
|
-
method={data.method}
|
|
159
|
-
path={data.path}
|
|
160
|
-
renderers={renderers}
|
|
161
|
-
blockKey={context.blockKey}
|
|
162
|
-
/>
|
|
163
|
-
),
|
|
164
|
-
footer: (
|
|
165
|
-
<OpenAPICodeSampleFooter renderers={renderers} data={data} context={context} />
|
|
166
|
-
),
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
return {
|
|
170
|
-
key: `default-${generator.id}`,
|
|
171
|
-
label: generator.label,
|
|
172
|
-
body: context.renderCodeBlock({
|
|
173
|
-
code: generator.generate({
|
|
174
|
-
url,
|
|
175
|
-
method: data.method,
|
|
176
|
-
body: undefined,
|
|
177
|
-
headers: genericHeaders,
|
|
178
|
-
}),
|
|
179
|
-
syntax: generator.syntax,
|
|
180
|
-
}),
|
|
181
|
-
footer: <OpenAPICodeSampleFooter data={data} renderers={[]} context={context} />,
|
|
182
|
-
};
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export interface MediaTypeRenderer {
|
|
187
|
-
mediaType: string;
|
|
188
|
-
element: React.ReactNode;
|
|
189
|
-
examples: Array<{
|
|
190
|
-
example: OpenAPIV3.ExampleObject;
|
|
191
|
-
element: React.ReactNode;
|
|
192
|
-
}>;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function OpenAPICodeSampleFooter(props: {
|
|
196
|
-
data: OpenAPIOperationData;
|
|
197
|
-
renderers: MediaTypeRenderer[];
|
|
198
|
-
context: OpenAPIContext;
|
|
199
|
-
}) {
|
|
200
|
-
const { data, context, renderers } = props;
|
|
201
|
-
const { method, path, securities, servers } = data;
|
|
202
|
-
const { specUrl } = context;
|
|
203
|
-
const hideTryItPanel = data['x-hideTryItPanel'] || data.operation['x-hideTryItPanel'];
|
|
204
|
-
const hasMultipleMediaTypes =
|
|
205
|
-
renderers.length > 1 || renderers.some((renderer) => renderer.examples.length > 0);
|
|
206
|
-
|
|
207
|
-
if (hideTryItPanel && !hasMultipleMediaTypes) {
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (!validateHttpMethod(method)) {
|
|
212
|
-
return null;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return (
|
|
216
|
-
<div className="openapi-codesample-footer">
|
|
217
|
-
{hasMultipleMediaTypes ? (
|
|
218
|
-
<OpenAPIMediaTypeExamplesSelector
|
|
219
|
-
method={data.method}
|
|
220
|
-
path={data.path}
|
|
221
|
-
renderers={renderers}
|
|
222
|
-
selectIcon={context.icons.chevronDown}
|
|
223
|
-
blockKey={context.blockKey}
|
|
224
|
-
/>
|
|
225
|
-
) : (
|
|
226
|
-
<span />
|
|
227
|
-
)}
|
|
228
|
-
{!hideTryItPanel && (
|
|
229
|
-
<ScalarApiButton
|
|
230
|
-
context={getOpenAPIClientContext(context)}
|
|
231
|
-
method={method}
|
|
232
|
-
path={path}
|
|
233
|
-
securities={securities}
|
|
234
|
-
servers={servers}
|
|
235
|
-
specUrl={specUrl}
|
|
236
|
-
/>
|
|
237
|
-
)}
|
|
238
|
-
</div>
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Get custom code samples for the operation.
|
|
244
|
-
*/
|
|
245
|
-
function getCustomCodeSamples(props: {
|
|
246
|
-
data: OpenAPIOperationData;
|
|
247
|
-
context: OpenAPIContext;
|
|
248
|
-
}) {
|
|
249
|
-
const { data, context } = props;
|
|
250
|
-
|
|
251
|
-
let customCodeSamples: null | Array<{
|
|
252
|
-
key: string;
|
|
253
|
-
label: string;
|
|
254
|
-
body: React.ReactNode;
|
|
255
|
-
}> = null;
|
|
256
|
-
|
|
257
|
-
CUSTOM_CODE_SAMPLES_KEYS.forEach((key) => {
|
|
258
|
-
const customSamples = data.operation[key];
|
|
259
|
-
if (customSamples && Array.isArray(customSamples)) {
|
|
260
|
-
customCodeSamples = customSamples
|
|
261
|
-
.filter((sample) => {
|
|
262
|
-
return typeof sample.source === 'string' && typeof sample.lang === 'string';
|
|
263
|
-
})
|
|
264
|
-
.map((sample, index) => ({
|
|
265
|
-
key: `custom-sample-${sample.lang}-${index}`,
|
|
266
|
-
label: sample.label || sample.lang,
|
|
267
|
-
body: context.renderCodeBlock({
|
|
268
|
-
code: sample.source,
|
|
269
|
-
syntax: sample.lang,
|
|
270
|
-
}),
|
|
271
|
-
footer: (
|
|
272
|
-
<OpenAPICodeSampleFooter renderers={[]} data={data} context={context} />
|
|
273
|
-
),
|
|
274
|
-
}));
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
return customCodeSamples;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
function getSecurityHeaders(securities: OpenAPIOperationData['securities']): {
|
|
282
|
-
[key: string]: string;
|
|
283
|
-
} {
|
|
284
|
-
const security = securities[0];
|
|
285
|
-
|
|
286
|
-
if (!security) {
|
|
287
|
-
return {};
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
switch (security[1].type) {
|
|
291
|
-
case 'http': {
|
|
292
|
-
let scheme = security[1].scheme;
|
|
293
|
-
let format = security[1].bearerFormat ?? 'YOUR_SECRET_TOKEN';
|
|
294
|
-
|
|
295
|
-
if (scheme?.includes('bearer')) {
|
|
296
|
-
scheme = 'Bearer';
|
|
297
|
-
} else if (scheme?.includes('basic')) {
|
|
298
|
-
scheme = 'Basic';
|
|
299
|
-
format = 'username:password';
|
|
300
|
-
} else if (scheme?.includes('token')) {
|
|
301
|
-
scheme = 'Token';
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
return {
|
|
305
|
-
Authorization: `${scheme} ${format}`,
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
case 'apiKey': {
|
|
309
|
-
if (security[1].in !== 'header') return {};
|
|
310
|
-
|
|
311
|
-
const name = security[1].name ?? 'Authorization';
|
|
312
|
-
|
|
313
|
-
return {
|
|
314
|
-
[name]: 'YOUR_API_KEY',
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
case 'oauth2': {
|
|
318
|
-
return {
|
|
319
|
-
Authorization: 'Bearer YOUR_OAUTH2_TOKEN',
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
default: {
|
|
323
|
-
return {};
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
function validateHttpMethod(method: string): method is OpenAPIV3.HttpMethods {
|
|
329
|
-
return ['get', 'post', 'put', 'delete', 'patch', 'head', 'options', 'trace'].includes(method);
|
|
330
|
-
}
|