Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1f7af50

Browse files
Handle OpenAPI ignored responses
1 parent 262a9b1 commit 1f7af50

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

‎.changeset/shaggy-crabs-return.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@gitbook/openapi-parser': patch
3+
'@gitbook/react-openapi': patch
4+
---
5+
6+
Handle OpenAPI ignored responses

‎packages/openapi-parser/src/helpers/shouldIgnoreEntity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { OpenAPIV3 } from '@scalar/openapi-types';
44
* Check if an entity should be ignored
55
*/
66
export function shouldIgnoreEntity(
7-
data: undefined | OpenAPIV3.TagObject | OpenAPIV3.OperationObject
7+
data: undefined | OpenAPIV3.TagObject | OpenAPIV3.OperationObject|OpenAPIV3.ResponseObject
88
) {
99
return data?.['x-internal'] === true || data?.['x-gitbook-ignore'] === true;
1010
}

‎packages/react-openapi/src/OpenAPIResponseExample.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type{OpenAPIV3 } from '@gitbook/openapi-parser';
1+
import {typeOpenAPIV3,shouldIgnoreEntity } from '@gitbook/openapi-parser';
22
import { Markdown } from './Markdown';
33
import { OpenAPIEmptyExample, OpenAPIExample } from './OpenAPIExample';
44
import { OpenAPIMediaTypeContent } from './OpenAPIMediaType';
@@ -42,7 +42,12 @@ export function OpenAPIResponseExample(props: {
4242
});
4343

4444
const tabs = responses
45-
.filter(([_, responseObject]) => responseObject && typeof responseObject === 'object')
45+
.filter(
46+
([_, responseObject]) =>
47+
responseObject &&
48+
typeof responseObject === 'object' &&
49+
!shouldIgnoreEntity(responseObject)
50+
)
4651
.map(([key, responseObject]) => {
4752
const description = resolveDescription(responseObject);
4853
const label = description ? (

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /