Skip to content

Commit 4771c78

Browse files
authored
Fix Scalar ApiClient routing (#2561)
1 parent b7a5106 commit 4771c78

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

.changeset/large-months-hang.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+
Fixed scalar api client routing

packages/react-openapi/src/OpenAPICodeSample.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export function OpenAPICodeSample(props: {
119119
tabs={samples}
120120
overlay={
121121
data['x-hideTryItPanel'] || data.operation['x-hideTryItPanel'] ? null : (
122-
<ScalarApiButton />
122+
<ScalarApiButton method={data.method} path={data.path} />
123123
)
124124
}
125125
/>

packages/react-openapi/src/ScalarApiButton.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ import React from 'react';
66
/**
77
* Button which launches the Scalar API Client
88
*/
9-
export function ScalarApiButton() {
9+
export function ScalarApiButton({ method, path }: { method: string; path: string }) {
1010
const client = useApiClientModal();
1111

1212
return (
1313
<div className="scalar scalar-activate">
14-
<button className="scalar-activate-button" onClick={() => client?.open()}>
14+
<button
15+
className="scalar-activate-button"
16+
onClick={() => client?.open({ method, path })}
17+
>
1518
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="12" fill="none">
1619
<path
1720
stroke="currentColor"

0 commit comments

Comments
 (0)