mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 23:55:20 +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>
|
</OpenAPIDisclosure>
|
||||||
) : null}
|
) : null}
|
||||||
<div className="openapi-responsebody">
|
{mediaType.schema && (
|
||||||
<OpenAPISchemaProperties
|
<div className="openapi-responsebody">
|
||||||
id={`response-${context.blockKey}`}
|
<OpenAPISchemaProperties
|
||||||
properties={mediaType.schema ? [{ schema: mediaType.schema }] : []}
|
id={`response-${context.blockKey}`}
|
||||||
context={context}
|
properties={[{ schema: mediaType.schema }]}
|
||||||
/>
|
context={context}
|
||||||
</div>
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,42 @@ export function OpenAPIResponses(props: {
|
|||||||
icon={context.icons.chevronRight}
|
icon={context.icons.chevronRight}
|
||||||
groups={Object.entries(responses).map(
|
groups={Object.entries(responses).map(
|
||||||
([statusCode, response]: [string, OpenAPIV3.ResponseObject]) => {
|
([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;
|
const description = response.description;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -39,17 +74,7 @@ export function OpenAPIResponses(props: {
|
|||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
tabs: content.map(([contentType, mediaType]) => ({
|
tabs,
|
||||||
id: contentType,
|
|
||||||
label: contentType,
|
|
||||||
body: (
|
|
||||||
<OpenAPIResponse
|
|
||||||
response={response}
|
|
||||||
mediaType={mediaType}
|
|
||||||
context={context}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
})),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user