Skip to content

Commit

Permalink
fix(gatsby docs): add x-transport on servers to default inspector tra…
Browse files Browse the repository at this point in the history
…nsport
  • Loading branch information
shanejonas committed Jul 22, 2020
1 parent dee2d77 commit 128a24d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion templates/docs/gatsby/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"version": "0.0.0-development",
"dependencies": {
"@open-rpc/inspector": "^1.4.2",
"@open-rpc/inspector": "^1.4.7",
"react-split-pane": "^0.1.87",
"monaco-editor": "0.18.1",
"@apidevtools/json-schema-ref-parser": "^9.0.1",
Expand Down
10 changes: 9 additions & 1 deletion templates/docs/gatsby/src/pages/api-documentation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const ApiDocumentation: React.FC = () => {
`);
const [openrpcDocument, setOpenrpcDocument] = useState<OpenrpcDocument>();
const [inspectorUrl, setInspectorUrl] = useState<string>();
const [inspectorTransport, setInspectorTransport] = useState<string>();

useEffect(() => {
if (openrpcQueryData.openrpcDocument) {
Expand All @@ -70,8 +71,14 @@ const ApiDocumentation: React.FC = () => {
}, [openrpcQueryData]);

useEffect(() => {
if (openrpcDocument && openrpcDocument.servers && openrpcDocument.servers[0]) {
if (!openrpcDocument) {
return;
}
if (openrpcDocument.servers && openrpcDocument.servers[0]) {
setInspectorUrl(openrpcDocument.servers[0].url);
if (openrpcDocument.servers[0]["x-transport"]) {
setInspectorTransport(openrpcDocument.servers[0]["x-transport"]);
}
}
}, [openrpcDocument])

Expand All @@ -93,6 +100,7 @@ const ApiDocumentation: React.FC = () => {
right={
<Inspector
url={inspectorUrl}
transport={inspectorTransport}
hideToggleTheme={true}
openrpcDocument={openrpcDocument}
darkMode={darkmode.value}
Expand Down

0 comments on commit 128a24d

Please sign in to comment.