@gitbook/react-openapi 0.7.1 → 1.0.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 +41 -0
- package/dist/InteractiveSection.d.ts +4 -6
- package/dist/InteractiveSection.jsx +96 -0
- package/dist/Markdown.d.ts +1 -2
- package/dist/Markdown.jsx +5 -0
- package/dist/OpenAPICodeSample.d.ts +2 -4
- package/dist/OpenAPICodeSample.jsx +143 -0
- package/dist/OpenAPIDisclosure.d.ts +12 -0
- package/dist/OpenAPIDisclosure.jsx +32 -0
- package/dist/OpenAPIDisclosureGroup.d.ts +19 -0
- package/dist/OpenAPIDisclosureGroup.jsx +81 -0
- package/dist/OpenAPIOperation.d.ts +2 -4
- package/dist/OpenAPIOperation.jsx +51 -0
- package/dist/OpenAPIOperationContext.d.ts +16 -0
- package/dist/OpenAPIOperationContext.jsx +26 -0
- package/dist/OpenAPIPath.d.ts +8 -0
- package/dist/OpenAPIPath.jsx +54 -0
- package/dist/OpenAPIRequestBody.d.ts +3 -4
- package/dist/OpenAPIRequestBody.jsx +19 -0
- package/dist/OpenAPIResponse.d.ts +4 -4
- package/dist/OpenAPIResponse.jsx +49 -0
- package/dist/OpenAPIResponseExample.d.ts +2 -4
- package/dist/OpenAPIResponseExample.jsx +108 -0
- package/dist/OpenAPIResponses.d.ts +3 -4
- package/dist/OpenAPIResponses.jsx +36 -0
- package/dist/OpenAPISchema.d.ts +11 -8
- package/dist/OpenAPISchema.jsx +295 -0
- package/dist/OpenAPISchemaName.d.ts +12 -0
- package/dist/OpenAPISchemaName.jsx +15 -0
- package/dist/OpenAPISecurities.d.ts +2 -4
- package/dist/OpenAPISecurities.jsx +55 -0
- package/dist/OpenAPIServerURL.d.ts +2 -3
- package/dist/OpenAPIServerURL.jsx +67 -0
- package/dist/OpenAPIServerURLVariable.d.ts +2 -3
- package/dist/OpenAPIServerURLVariable.jsx +8 -0
- package/dist/OpenAPISpec.d.ts +3 -4
- package/dist/OpenAPISpec.jsx +91 -0
- package/dist/OpenAPITabs.d.ts +25 -0
- package/dist/OpenAPITabs.jsx +67 -0
- package/dist/ScalarApiButton.d.ts +3 -3
- package/dist/ScalarApiButton.jsx +51 -0
- package/dist/code-samples.d.ts +4 -0
- package/dist/code-samples.js +103 -38
- package/dist/fetchOpenAPIOperation.d.ts +9 -54
- package/dist/fetchOpenAPIOperation.js +178 -107
- package/dist/generateSchemaExample.d.ts +2 -2
- package/dist/generateSchemaExample.js +28 -100
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/resolveOpenAPIOperation.d.ts +11 -0
- package/dist/resolveOpenAPIOperation.js +194 -0
- package/dist/stringifyOpenAPI.d.ts +4 -0
- package/dist/stringifyOpenAPI.js +6 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +11 -12
- package/dist/utils.d.ts +6 -1
- package/dist/utils.js +15 -2
- package/package.json +11 -10
- package/src/InteractiveSection.tsx +119 -78
- package/src/Markdown.tsx +2 -3
- package/src/OpenAPICodeSample.tsx +35 -21
- package/src/OpenAPIDisclosure.tsx +50 -0
- package/src/OpenAPIDisclosureGroup.tsx +136 -0
- package/src/OpenAPIOperation.tsx +36 -42
- package/src/OpenAPIOperationContext.tsx +45 -0
- package/src/OpenAPIPath.tsx +65 -0
- package/src/OpenAPIRequestBody.tsx +3 -14
- package/src/OpenAPIResponse.tsx +39 -43
- package/src/OpenAPIResponseExample.tsx +89 -31
- package/src/OpenAPIResponses.tsx +51 -15
- package/src/OpenAPISchema.test.ts +1 -1
- package/src/OpenAPISchema.tsx +124 -92
- package/src/OpenAPISchemaName.tsx +27 -0
- package/src/OpenAPISecurities.tsx +45 -24
- package/src/OpenAPIServerURL.tsx +17 -10
- package/src/OpenAPIServerURLVariable.tsx +2 -4
- package/src/OpenAPISpec.tsx +56 -53
- package/src/OpenAPITabs.tsx +113 -0
- package/src/ScalarApiButton.tsx +84 -7
- package/src/code-samples.test.ts +51 -0
- package/src/code-samples.ts +95 -31
- package/src/generateSchemaExample.ts +25 -151
- package/src/index.ts +3 -2
- package/src/resolveOpenAPIOperation.test.ts +177 -0
- package/src/resolveOpenAPIOperation.ts +163 -0
- package/src/stringifyOpenAPI.ts +6 -0
- package/src/types.ts +17 -10
- package/src/utils.ts +17 -2
- package/dist/InteractiveSection.js +0 -47
- package/dist/Markdown.js +0 -6
- package/dist/OpenAPICodeSample.js +0 -110
- package/dist/OpenAPIOperation.js +0 -38
- package/dist/OpenAPIRequestBody.js +0 -18
- package/dist/OpenAPIResponse.js +0 -32
- package/dist/OpenAPIResponseExample.js +0 -54
- package/dist/OpenAPIResponses.js +0 -18
- package/dist/OpenAPISchema.js +0 -235
- package/dist/OpenAPISchema.test.d.ts +0 -1
- package/dist/OpenAPISchema.test.js +0 -91
- package/dist/OpenAPISecurities.js +0 -42
- package/dist/OpenAPIServerURL.js +0 -51
- package/dist/OpenAPIServerURLVariable.js +0 -10
- package/dist/OpenAPISpec.js +0 -70
- package/dist/ScalarApiButton.js +0 -14
- package/dist/fetchOpenAPIOperation.test.d.ts +0 -1
- package/dist/fetchOpenAPIOperation.test.js +0 -152
- package/dist/resolveOpenAPIPath.d.ts +0 -7
- package/dist/resolveOpenAPIPath.js +0 -112
- package/dist/resolveOpenAPIPath.test.d.ts +0 -1
- package/dist/resolveOpenAPIPath.test.js +0 -39
- package/src/fetchOpenAPIOperation.test.ts +0 -185
- package/src/fetchOpenAPIOperation.ts +0 -230
- package/src/resolveOpenAPIPath.test.ts +0 -60
- package/src/resolveOpenAPIPath.ts +0 -145
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
import { ScalarApiButton } from './ScalarApiButton';
|
|
11
|
+
/**
|
|
12
|
+
* Display the path of an operation.
|
|
13
|
+
*/
|
|
14
|
+
export function OpenAPIPath(props) {
|
|
15
|
+
var data = props.data, context = props.context;
|
|
16
|
+
var method = data.method, path = data.path;
|
|
17
|
+
var specUrl = context.specUrl;
|
|
18
|
+
return (<div className="openapi-path">
|
|
19
|
+
<div className={"openapi-method openapi-method-".concat(method)}>{method}</div>
|
|
20
|
+
<div className="openapi-path-title" data-deprecated={data.operation.deprecated}>
|
|
21
|
+
<p>{formatPath(path)}</p>
|
|
22
|
+
</div>
|
|
23
|
+
{data['x-hideTryItPanel'] || data.operation['x-hideTryItPanel'] ? null : (<ScalarApiButton method={method} path={path} specUrl={specUrl}/>)}
|
|
24
|
+
</div>);
|
|
25
|
+
}
|
|
26
|
+
// Format the path to highlight placeholders
|
|
27
|
+
function formatPath(path) {
|
|
28
|
+
// Matches placeholders like {id}, {userId}, etc.
|
|
29
|
+
var regex = /\{(\w+)\}/g;
|
|
30
|
+
var parts = [];
|
|
31
|
+
var lastIndex = 0;
|
|
32
|
+
// Replace placeholders with <em> tags
|
|
33
|
+
path.replace(regex, function (match, key, offset) {
|
|
34
|
+
parts.push(path.slice(lastIndex, offset));
|
|
35
|
+
parts.push(<em key={key}>{"{".concat(key, "}")}</em>);
|
|
36
|
+
lastIndex = offset + match.length;
|
|
37
|
+
return match;
|
|
38
|
+
});
|
|
39
|
+
// Push remaining text after the last placeholder
|
|
40
|
+
parts.push(path.slice(lastIndex));
|
|
41
|
+
// Join parts with separators wrapped in <span>
|
|
42
|
+
var formattedPath = parts.reduce(function (acc, part, index) {
|
|
43
|
+
if (typeof part === 'string' && index > 0 && part === '/') {
|
|
44
|
+
return __spreadArray(__spreadArray([], acc, true), [
|
|
45
|
+
<span className="openapi-path-separator" key={"sep-".concat(index)}>
|
|
46
|
+
/
|
|
47
|
+
</span>,
|
|
48
|
+
part,
|
|
49
|
+
], false);
|
|
50
|
+
}
|
|
51
|
+
return __spreadArray(__spreadArray([], acc, true), [part], false);
|
|
52
|
+
}, []);
|
|
53
|
+
return <span>{formattedPath}</span>;
|
|
54
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { OpenAPIClientContext } from './types';
|
|
1
|
+
import type { OpenAPIV3 } from '@gitbook/openapi-parser';
|
|
2
|
+
import type { OpenAPIClientContext } from './types';
|
|
4
3
|
/**
|
|
5
4
|
* Display an interactive request body.
|
|
6
5
|
*/
|
|
7
6
|
export declare function OpenAPIRequestBody(props: {
|
|
8
7
|
requestBody: OpenAPIV3.RequestBodyObject;
|
|
9
8
|
context: OpenAPIClientContext;
|
|
10
|
-
}):
|
|
9
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { OpenAPIRootSchema } from './OpenAPISchema';
|
|
2
|
+
import { noReference } from './utils';
|
|
3
|
+
import { InteractiveSection } from './InteractiveSection';
|
|
4
|
+
/**
|
|
5
|
+
* Display an interactive request body.
|
|
6
|
+
*/
|
|
7
|
+
export function OpenAPIRequestBody(props) {
|
|
8
|
+
var _a;
|
|
9
|
+
var requestBody = props.requestBody, context = props.context;
|
|
10
|
+
return (<InteractiveSection header="Body" className="openapi-requestbody" tabs={Object.entries((_a = requestBody.content) !== null && _a !== void 0 ? _a : {}).map(function (_a) {
|
|
11
|
+
var _b;
|
|
12
|
+
var contentType = _a[0], mediaTypeObject = _a[1];
|
|
13
|
+
return {
|
|
14
|
+
key: contentType,
|
|
15
|
+
label: contentType,
|
|
16
|
+
body: (<OpenAPIRootSchema schema={(_b = noReference(mediaTypeObject.schema)) !== null && _b !== void 0 ? _b : {}} context={context}/>),
|
|
17
|
+
};
|
|
18
|
+
})}/>);
|
|
19
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { OpenAPIClientContext } from './types';
|
|
1
|
+
import type { OpenAPIV3 } from '@gitbook/openapi-parser';
|
|
2
|
+
import type { OpenAPIClientContext } from './types';
|
|
4
3
|
/**
|
|
5
4
|
* Display an interactive response body.
|
|
6
5
|
*/
|
|
7
6
|
export declare function OpenAPIResponse(props: {
|
|
8
7
|
response: OpenAPIV3.ResponseObject;
|
|
8
|
+
mediaType: OpenAPIV3.MediaTypeObject;
|
|
9
9
|
context: OpenAPIClientContext;
|
|
10
|
-
}):
|
|
10
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { OpenAPISchemaProperties } from './OpenAPISchema';
|
|
2
|
+
import { checkIsReference, noReference, resolveDescription } from './utils';
|
|
3
|
+
import { OpenAPIDisclosure } from './OpenAPIDisclosure';
|
|
4
|
+
/**
|
|
5
|
+
* Display an interactive response body.
|
|
6
|
+
*/
|
|
7
|
+
export function OpenAPIResponse(props) {
|
|
8
|
+
var _a, _b, _c;
|
|
9
|
+
var response = props.response, context = props.context, mediaType = props.mediaType;
|
|
10
|
+
var headers = Object.entries((_a = response.headers) !== null && _a !== void 0 ? _a : {}).map(function (_a) {
|
|
11
|
+
var _b;
|
|
12
|
+
var name = _a[0], header = _a[1];
|
|
13
|
+
return [name, (_b = noReference(header)) !== null && _b !== void 0 ? _b : {}];
|
|
14
|
+
});
|
|
15
|
+
var content = Object.entries((_b = mediaType.schema) !== null && _b !== void 0 ? _b : {});
|
|
16
|
+
var description = resolveDescription(response);
|
|
17
|
+
if (content.length === 0 && !description && headers.length === 0) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return (<div className="openapi-response-body">
|
|
21
|
+
{headers.length > 0 ? (<OpenAPIDisclosure context={context} label={'Headers'}>
|
|
22
|
+
<OpenAPISchemaProperties properties={headers.map(function (_a) {
|
|
23
|
+
var _b;
|
|
24
|
+
var name = _a[0], header = _a[1];
|
|
25
|
+
return ({
|
|
26
|
+
propertyName: name,
|
|
27
|
+
schema: (_b = noReference(header.schema)) !== null && _b !== void 0 ? _b : {},
|
|
28
|
+
required: header.required,
|
|
29
|
+
});
|
|
30
|
+
})} context={context}/>
|
|
31
|
+
</OpenAPIDisclosure>) : null}
|
|
32
|
+
<div className="openapi-responsebody">
|
|
33
|
+
<OpenAPISchemaProperties id={"response-".concat(context.blockKey)} properties={[
|
|
34
|
+
{
|
|
35
|
+
schema: (_c = handleUnresolvedReference(mediaType.schema)) !== null && _c !== void 0 ? _c : {},
|
|
36
|
+
},
|
|
37
|
+
]} context={context}/>
|
|
38
|
+
</div>
|
|
39
|
+
</div>);
|
|
40
|
+
}
|
|
41
|
+
function handleUnresolvedReference(input) {
|
|
42
|
+
var isReference = checkIsReference(input);
|
|
43
|
+
if (isReference || input === undefined) {
|
|
44
|
+
// If we find a reference that wasn't resolved or needed to be resolved externally, do not try to render it.
|
|
45
|
+
// Instead we render `any`
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
return input;
|
|
49
|
+
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { OpenAPIOperationData } from './fetchOpenAPIOperation';
|
|
3
|
-
import { OpenAPIContextProps } from './types';
|
|
1
|
+
import type { OpenAPIContextProps, OpenAPIOperationData } from './types';
|
|
4
2
|
/**
|
|
5
3
|
* Display an example of the response content.
|
|
6
4
|
*/
|
|
7
5
|
export declare function OpenAPIResponseExample(props: {
|
|
8
6
|
data: OpenAPIOperationData;
|
|
9
7
|
context: OpenAPIContextProps;
|
|
10
|
-
}):
|
|
8
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { generateSchemaExample } from './generateSchemaExample';
|
|
2
|
+
import { checkIsReference, noReference, resolveDescription } from './utils';
|
|
3
|
+
import { stringifyOpenAPI } from './stringifyOpenAPI';
|
|
4
|
+
import { OpenAPITabs, OpenAPITabsList, OpenAPITabsPanels } from './OpenAPITabs';
|
|
5
|
+
import { InteractiveSection } from './InteractiveSection';
|
|
6
|
+
/**
|
|
7
|
+
* Display an example of the response content.
|
|
8
|
+
*/
|
|
9
|
+
export function OpenAPIResponseExample(props) {
|
|
10
|
+
var data = props.data, context = props.context;
|
|
11
|
+
// if there are no responses defined for the operation
|
|
12
|
+
if (!data.operation.responses) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
var responses = Object.entries(data.operation.responses);
|
|
16
|
+
// Sort response to get 200, and 2xx first
|
|
17
|
+
responses.sort(function (_a, _b) {
|
|
18
|
+
var a = _a[0];
|
|
19
|
+
var b = _b[0];
|
|
20
|
+
if (a === 'default') {
|
|
21
|
+
return 1;
|
|
22
|
+
}
|
|
23
|
+
if (b === 'default') {
|
|
24
|
+
return -1;
|
|
25
|
+
}
|
|
26
|
+
if (a === '200') {
|
|
27
|
+
return -1;
|
|
28
|
+
}
|
|
29
|
+
if (b === '200') {
|
|
30
|
+
return 1;
|
|
31
|
+
}
|
|
32
|
+
return Number(a) - Number(b);
|
|
33
|
+
});
|
|
34
|
+
var examples = responses
|
|
35
|
+
.map(function (_a) {
|
|
36
|
+
var key = _a[0], value = _a[1];
|
|
37
|
+
var responseObject = noReference(value);
|
|
38
|
+
var mediaTypeObject = (function () {
|
|
39
|
+
var _a;
|
|
40
|
+
if (!responseObject.content) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
var key = Object.keys(responseObject.content)[0];
|
|
44
|
+
return ((_a = responseObject.content['application/json']) !== null && _a !== void 0 ? _a : (key ? responseObject.content[key] : null));
|
|
45
|
+
})();
|
|
46
|
+
if (!mediaTypeObject) {
|
|
47
|
+
return {
|
|
48
|
+
key: key,
|
|
49
|
+
label: key,
|
|
50
|
+
description: resolveDescription(responseObject),
|
|
51
|
+
body: <OpenAPIEmptyResponseExample />,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
var example = handleUnresolvedReference((function () {
|
|
55
|
+
var examples = mediaTypeObject.examples, example = mediaTypeObject.example;
|
|
56
|
+
if (examples) {
|
|
57
|
+
var key_1 = Object.keys(examples)[0];
|
|
58
|
+
if (key_1) {
|
|
59
|
+
// @TODO handle multiple examples
|
|
60
|
+
var firstExample = noReference(examples[key_1]);
|
|
61
|
+
if (firstExample) {
|
|
62
|
+
return firstExample;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (example) {
|
|
67
|
+
return { value: example };
|
|
68
|
+
}
|
|
69
|
+
var schema = noReference(mediaTypeObject.schema);
|
|
70
|
+
if (!schema) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return { value: generateSchemaExample(schema) };
|
|
74
|
+
})());
|
|
75
|
+
return {
|
|
76
|
+
key: key,
|
|
77
|
+
label: key,
|
|
78
|
+
description: resolveDescription(responseObject),
|
|
79
|
+
body: (example === null || example === void 0 ? void 0 : example.value) ? (<context.CodeBlock code={typeof example.value === 'string'
|
|
80
|
+
? example.value
|
|
81
|
+
: stringifyOpenAPI(example.value, null, 2)} syntax="json"/>) : (<OpenAPIEmptyResponseExample />),
|
|
82
|
+
};
|
|
83
|
+
})
|
|
84
|
+
.filter(function (val) {
|
|
85
|
+
return Boolean(val);
|
|
86
|
+
});
|
|
87
|
+
if (examples.length === 0) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return (<OpenAPITabs items={examples}>
|
|
91
|
+
<InteractiveSection header={<OpenAPITabsList />} className="openapi-response-example">
|
|
92
|
+
<OpenAPITabsPanels />
|
|
93
|
+
</InteractiveSection>
|
|
94
|
+
</OpenAPITabs>);
|
|
95
|
+
}
|
|
96
|
+
function OpenAPIEmptyResponseExample() {
|
|
97
|
+
return (<pre className="openapi-response-example-empty">
|
|
98
|
+
<p>No body</p>
|
|
99
|
+
</pre>);
|
|
100
|
+
}
|
|
101
|
+
function handleUnresolvedReference(input) {
|
|
102
|
+
var isReference = checkIsReference(input === null || input === void 0 ? void 0 : input.value);
|
|
103
|
+
if (isReference) {
|
|
104
|
+
// If we find a reference that wasn't resolved or needed to be resolved externally, render out the URL
|
|
105
|
+
return { value: input.value.$ref };
|
|
106
|
+
}
|
|
107
|
+
return input;
|
|
108
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { OpenAPIV3 } from 'openapi-types';
|
|
1
|
+
import type { OpenAPIV3, OpenAPIV3_1 } from '@gitbook/openapi-parser';
|
|
3
2
|
import { OpenAPIClientContext } from './types';
|
|
4
3
|
/**
|
|
5
4
|
* Display an interactive response body.
|
|
6
5
|
*/
|
|
7
6
|
export declare function OpenAPIResponses(props: {
|
|
8
|
-
responses: OpenAPIV3.ResponsesObject;
|
|
7
|
+
responses: OpenAPIV3.ResponsesObject | OpenAPIV3_1.ResponsesObject;
|
|
9
8
|
context: OpenAPIClientContext;
|
|
10
|
-
}):
|
|
9
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createStateKey, resolveDescription } from './utils';
|
|
2
|
+
import { OpenAPIResponse } from './OpenAPIResponse';
|
|
3
|
+
import { InteractiveSection } from './InteractiveSection';
|
|
4
|
+
import { OpenAPIDisclosureGroup } from './OpenAPIDisclosureGroup';
|
|
5
|
+
import { Markdown } from './Markdown';
|
|
6
|
+
/**
|
|
7
|
+
* Display an interactive response body.
|
|
8
|
+
*/
|
|
9
|
+
export function OpenAPIResponses(props) {
|
|
10
|
+
var responses = props.responses, context = props.context;
|
|
11
|
+
return (<InteractiveSection stateKey={createStateKey('response', context.blockKey)} header="Responses" className="openapi-responses">
|
|
12
|
+
<OpenAPIDisclosureGroup allowsMultipleExpanded icon={context.icons.chevronRight} groups={Object.entries(responses).map(function (_a) {
|
|
13
|
+
var _b;
|
|
14
|
+
var statusCode = _a[0], response = _a[1];
|
|
15
|
+
var content = Object.entries((_b = response.content) !== null && _b !== void 0 ? _b : {});
|
|
16
|
+
var description = resolveDescription(response);
|
|
17
|
+
return {
|
|
18
|
+
id: statusCode,
|
|
19
|
+
label: (<div className="openapi-response-tab-content" key={"response-".concat(statusCode)}>
|
|
20
|
+
<span className="openapi-response-statuscode">
|
|
21
|
+
{statusCode}
|
|
22
|
+
</span>
|
|
23
|
+
{description ? (<Markdown source={description} className="openapi-response-description"/>) : null}
|
|
24
|
+
</div>),
|
|
25
|
+
tabs: content.map(function (_a) {
|
|
26
|
+
var contentType = _a[0], mediaType = _a[1];
|
|
27
|
+
return ({
|
|
28
|
+
id: contentType,
|
|
29
|
+
label: contentType,
|
|
30
|
+
body: (<OpenAPIResponse key={"$response-".concat(statusCode, "-").concat(contentType)} response={response} mediaType={mediaType} context={context}/>),
|
|
31
|
+
});
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
34
|
+
})}/>
|
|
35
|
+
</InteractiveSection>);
|
|
36
|
+
}
|
package/dist/OpenAPISchema.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { OpenAPIV3 } from 'openapi-
|
|
2
|
-
import
|
|
3
|
-
import { OpenAPIClientContext } from './types';
|
|
1
|
+
import type { OpenAPIV3 } from '@gitbook/openapi-parser';
|
|
2
|
+
import type { OpenAPIClientContext } from './types';
|
|
4
3
|
type CircularRefsIds = Map<OpenAPIV3.SchemaObject, string>;
|
|
5
|
-
interface OpenAPISchemaPropertyEntry {
|
|
4
|
+
export interface OpenAPISchemaPropertyEntry {
|
|
6
5
|
propertyName?: string;
|
|
7
6
|
required?: boolean;
|
|
8
7
|
schema: OpenAPIV3.SchemaObject;
|
|
@@ -15,7 +14,7 @@ export declare function OpenAPISchemaProperty(props: OpenAPISchemaPropertyEntry
|
|
|
15
14
|
circularRefs?: CircularRefsIds;
|
|
16
15
|
context: OpenAPIClientContext;
|
|
17
16
|
className?: string;
|
|
18
|
-
}):
|
|
17
|
+
}): import("react").JSX.Element;
|
|
19
18
|
/**
|
|
20
19
|
* Render a set of properties of an OpenAPI schema.
|
|
21
20
|
*/
|
|
@@ -24,22 +23,26 @@ export declare function OpenAPISchemaProperties(props: {
|
|
|
24
23
|
properties: OpenAPISchemaPropertyEntry[];
|
|
25
24
|
circularRefs?: CircularRefsIds;
|
|
26
25
|
context: OpenAPIClientContext;
|
|
27
|
-
}):
|
|
26
|
+
}): import("react").JSX.Element | null;
|
|
28
27
|
/**
|
|
29
28
|
* Render a root schema (such as the request body or response body).
|
|
30
29
|
*/
|
|
31
30
|
export declare function OpenAPIRootSchema(props: {
|
|
32
31
|
schema: OpenAPIV3.SchemaObject;
|
|
33
32
|
context: OpenAPIClientContext;
|
|
34
|
-
}):
|
|
33
|
+
}): import("react").JSX.Element;
|
|
35
34
|
/**
|
|
36
35
|
* Render the enum value for a schema.
|
|
37
36
|
*/
|
|
38
37
|
export declare function OpenAPISchemaEnum(props: {
|
|
39
38
|
enumValues: any[];
|
|
40
|
-
}):
|
|
39
|
+
}): import("react").JSX.Element;
|
|
40
|
+
export declare function OpenAPISchemaPresentation(props: OpenAPISchemaPropertyEntry): import("react").JSX.Element;
|
|
41
41
|
/**
|
|
42
42
|
* Get the alternatives to display for a schema.
|
|
43
43
|
*/
|
|
44
44
|
export declare function getSchemaAlternatives(schema: OpenAPIV3.SchemaObject, ancestors?: Set<OpenAPIV3.SchemaObject>): null | [OpenAPIV3.SchemaObject[], OpenAPIV3.DiscriminatorObject | undefined];
|
|
45
|
+
export declare function getSchemaTitle(schema: OpenAPIV3.SchemaObject,
|
|
46
|
+
/** If the title is inferred in a oneOf with discriminator, we can use it to optimize the title */
|
|
47
|
+
discriminator?: OpenAPIV3.DiscriminatorObject): string;
|
|
45
48
|
export {};
|