Skip to content

Commit b45feaf

Browse files
authored
Disable OpenAPI "Try it" when no servers are defined (#3791)
1 parent 3876f70 commit b45feaf

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.changeset/huge-worms-follow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@gitbook/react-openapi': patch
3+
---
4+
5+
Disable OpenAPI "Try it" when no servers are defined

packages/react-openapi/src/OpenAPICodeSample.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ function OpenAPICodeSampleFooter(props: {
220220
return null;
221221
}
222222

223-
if (!validateHttpMethod(method)) {
223+
if (!validateHttpMethod(method) || (!hasMultipleMediaTypes && servers.length === 0)) {
224224
return null;
225225
}
226226

@@ -237,7 +237,7 @@ function OpenAPICodeSampleFooter(props: {
237237
) : (
238238
<span />
239239
)}
240-
{!hideTryItPanel && (
240+
{!hideTryItPanel && servers.length > 0 && (
241241
<ScalarApiButton
242242
context={getOpenAPIClientContext(context)}
243243
method={method}

0 commit comments

Comments
 (0)