mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 15:45:13 +00:00
1e1d202b5a
* Fix integrations blocks and text being too long * Fix size of code blocks * Open expandable by default on print mode * Render tabs one after the other * Adjust colors * Open all in openapi when printing * Fix title * Format * Fix TS
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import { OpenAPIV3 } from 'openapi-types';
|
|
import { OpenAPIRootSchema } from './OpenAPISchema';
|
|
import { noReference } from './utils';
|
|
import { OpenAPIClientContext } from './types';
|
|
import { InteractiveSection } from './InteractiveSection';
|
|
import { Markdown } from './Markdown';
|
|
|
|
/**
|
|
* Display an interactive request body.
|
|
*/
|
|
export function OpenAPIRequestBody(props: {
|
|
requestBody: OpenAPIV3.RequestBodyObject;
|
|
context: OpenAPIClientContext;
|
|
}) {
|
|
const { requestBody, context } = props;
|
|
|
|
return (
|
|
<InteractiveSection
|
|
header="Body"
|
|
className="openapi-requestbody"
|
|
tabs={Object.entries(requestBody.content ?? {}).map(
|
|
([contentType, mediaTypeObject]) => {
|
|
return {
|
|
key: contentType,
|
|
label: contentType,
|
|
body: (
|
|
<OpenAPIRootSchema
|
|
schema={noReference(mediaTypeObject.schema) ?? {}}
|
|
context={context}
|
|
/>
|
|
),
|
|
};
|
|
},
|
|
)}
|
|
defaultOpened={context.defaultInteractiveOpened}
|
|
>
|
|
{requestBody.description ? (
|
|
<Markdown
|
|
source={requestBody.description}
|
|
className="openapi-requestbody-description"
|
|
/>
|
|
) : null}
|
|
</InteractiveSection>
|
|
);
|
|
}
|