Skip to content

Commit 651ddf8

Browse files
authored
Changing media type should dynamically change examples (#57029)
1 parent d13b1f0 commit 651ddf8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/rest/components/get-rest-code-samples.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,11 @@ function getRequiredQueryParamsPath(operation: Operation, codeSample: CodeSample
498498
}
499499

500500
function getAcceptHeader(codeSample: CodeSample) {
501-
// This allows us to display custom media types like application/sarif+json
502-
return codeSample?.response?.contentType?.includes('+json')
503-
? codeSample.response.contentType
504-
: 'application/vnd.github+json'
501+
const contentType = codeSample?.response?.contentType
502+
503+
if (!contentType || contentType === 'application/json') {
504+
return 'application/vnd.github+json'
505+
}
506+
507+
return contentType
505508
}

0 commit comments

Comments
 (0)