Fix Scalar ApiClient routing (#2561)

This commit is contained in:
Amrit Kahlon
2024-10-28 12:38:18 -07:00
committed by GitHub
parent b7a5106f36
commit 4771c78001
3 changed files with 11 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@gitbook/react-openapi': patch
---
Fixed scalar api client routing
@@ -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} />
)
}
/>
@@ -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"