MCPcopy
hub / github.com/GitbookIO/gitbook / OpenAPIRequestBody

Function OpenAPIRequestBody

packages/react-openapi/src/OpenAPIRequestBody.tsx:13–54  ·  view source on GitHub ↗
(props: {
    requestBody: OpenAPIV3.RequestBodyObject | OpenAPIV3.ReferenceObject;
    context: OpenAPIClientContext;
    data: OpenAPIOperationData | OpenAPIWebhookData;
})

Source from the content-addressed store, hash-verified

11 * Display an interactive request body.
12 */
13export function OpenAPIRequestBody(props: {
14 requestBody: OpenAPIV3.RequestBodyObject | OpenAPIV3.ReferenceObject;
15 context: OpenAPIClientContext;
16 data: OpenAPIOperationData | OpenAPIWebhookData;
17}) {
18 const { requestBody, context, data } = props;
19
20 if (checkIsReference(requestBody)) {
21 return null;
22 }
23
24 const stateKey = createStateKey('request-body-media-type', context.blockKey);
25
26 return (
27 <InteractiveSection
28 header={
29 <>
30 <span>{t(context.translation, 'name' in data ? 'payload' : 'body')}</span>
31 <OpenAPIRequestBodyHeaderType requestBody={requestBody} stateKey={stateKey} />
32 </>
33 }
34 className="openapi-requestbody"
35 stateKey={stateKey}
36 selectIcon={context.icons.chevronDown}
37 tabs={Object.entries(requestBody.content ?? {}).map(
38 ([contentType, mediaTypeObject]) => {
39 return {
40 key: contentType,
41 label: contentType,
42 body: (
43 <OpenAPIRootSchema
44 schema={mediaTypeObject.schema ?? {}}
45 context={context}
46 key={contentType}
47 />
48 ),
49 };
50 }
51 )}
52 />
53 );
54}

Callers

nothing calls this directly

Calls 3

checkIsReferenceFunction · 0.90
createStateKeyFunction · 0.90
tFunction · 0.90

Tested by

no test coverage detected