mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-12 05:48:57 +00:00
Fix missing headers in OpenAPIResponses (#3074)
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@gitbook/react-openapi': patch
|
||||
'gitbook': patch
|
||||
---
|
||||
|
||||
Fix missing headers in OpenAPIResponses
|
||||
@@ -36,13 +36,15 @@ export function OpenAPIResponse(props: {
|
||||
/>
|
||||
</OpenAPIDisclosure>
|
||||
) : null}
|
||||
<div className="openapi-responsebody">
|
||||
<OpenAPISchemaProperties
|
||||
id={`response-${context.blockKey}`}
|
||||
properties={mediaType.schema ? [{ schema: mediaType.schema }] : []}
|
||||
context={context}
|
||||
/>
|
||||
</div>
|
||||
{mediaType.schema && (
|
||||
<div className="openapi-responsebody">
|
||||
<OpenAPISchemaProperties
|
||||
id={`response-${context.blockKey}`}
|
||||
properties={[{ schema: mediaType.schema }]}
|
||||
context={context}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,42 @@ export function OpenAPIResponses(props: {
|
||||
icon={context.icons.chevronRight}
|
||||
groups={Object.entries(responses).map(
|
||||
([statusCode, response]: [string, OpenAPIV3.ResponseObject]) => {
|
||||
const content = Object.entries(response.content ?? {});
|
||||
const tabs = (() => {
|
||||
// If there is no content, but there are headers, we need to show the headers
|
||||
if (
|
||||
(!response.content || !Object.keys(response.content).length) &&
|
||||
response.headers &&
|
||||
Object.keys(response.headers).length
|
||||
) {
|
||||
return [
|
||||
{
|
||||
id: 'default',
|
||||
body: (
|
||||
<OpenAPIResponse
|
||||
response={response}
|
||||
mediaType={{}}
|
||||
context={context}
|
||||
/>
|
||||
),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return Object.entries(response.content ?? {}).map(
|
||||
([contentType, mediaType]) => ({
|
||||
id: contentType,
|
||||
label: contentType,
|
||||
body: (
|
||||
<OpenAPIResponse
|
||||
response={response}
|
||||
mediaType={mediaType}
|
||||
context={context}
|
||||
/>
|
||||
),
|
||||
})
|
||||
);
|
||||
})();
|
||||
|
||||
const description = response.description;
|
||||
|
||||
return {
|
||||
@@ -39,17 +74,7 @@ export function OpenAPIResponses(props: {
|
||||
) : null}
|
||||
</div>
|
||||
),
|
||||
tabs: content.map(([contentType, mediaType]) => ({
|
||||
id: contentType,
|
||||
label: contentType,
|
||||
body: (
|
||||
<OpenAPIResponse
|
||||
response={response}
|
||||
mediaType={mediaType}
|
||||
context={context}
|
||||
/>
|
||||
),
|
||||
})),
|
||||
tabs,
|
||||
};
|
||||
}
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user