Skip to content

Commit

Permalink
Fix Scalar ApiClient routing (#2561)
Browse files Browse the repository at this point in the history
  • Loading branch information
amritk authored Oct 28, 2024
1 parent b7a5106 commit 4771c78
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/large-months-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@gitbook/react-openapi': patch
---

Fixed scalar api client routing
2 changes: 1 addition & 1 deletion packages/react-openapi/src/OpenAPICodeSample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export function OpenAPICodeSample(props: {
tabs={samples}
overlay={
data['x-hideTryItPanel'] || data.operation['x-hideTryItPanel'] ? null : (
<ScalarApiButton />
<ScalarApiButton method={data.method} path={data.path} />
)
}
/>
Expand Down
7 changes: 5 additions & 2 deletions packages/react-openapi/src/ScalarApiButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ import React from 'react';
/**
* Button which launches the Scalar API Client
*/
export function ScalarApiButton() {
export function ScalarApiButton({ method, path }: { method: string; path: string }) {
const client = useApiClientModal();

return (
<div className="scalar scalar-activate">
<button className="scalar-activate-button" onClick={() => client?.open()}>
<button
className="scalar-activate-button"
onClick={() => client?.open({ method, path })}
>
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="12" fill="none">
<path
stroke="currentColor"
Expand Down

0 comments on commit 4771c78

Please sign in to comment.