Skip to content

Commit 6e67d51

Browse files
committed
fix: add parseOpenRpcDocument
1 parent 7e6b7b5 commit 6e67d51

File tree

6 files changed

+65
-31
lines changed

6 files changed

+65
-31
lines changed

package-lock.json

+52-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
"@material-ui/icons": "^4.5.1",
5454
"@monaco-editor/react": "^2.3.0",
5555
"@open-rpc/client-js": "^1.2.1",
56-
"@open-rpc/meta-schema": "^1.5.3",
56+
"@open-rpc/meta-schema": "^1.7.0",
57+
"@open-rpc/schema-utils-js": "^1.12.0",
5758
"@rehooks/window-size": "^1.0.2",
5859
"acorn-dynamic-import": "^4.0.0",
5960
"monaco-editor": "^0.18.1",

src/containers/Inspector.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import MonacoEditor from "@etclabscore/react-monaco-editor";
1515
import useTabs from "../hooks/useTabs";
1616
import { useDebounce } from "use-debounce";
1717
import { green } from "@material-ui/core/colors";
18+
import { parseOpenRPCDocument } from "@open-rpc/schema-utils-js";
1819

1920
const errorToJSON = (error: JSONRPCError | undefined): any => {
2021
if (!error) {
@@ -189,8 +190,9 @@ const Inspector: React.FC<IProps> = (props) => {
189190
if (url) {
190191
try {
191192
const d = await client.request("rpc.discover", []);
192-
setOpenRpcDocument(d);
193-
setTabOpenRPCDocument(tabIndex, d);
193+
const doc = await parseOpenRPCDocument(d);
194+
setOpenRpcDocument(doc);
195+
setTabOpenRPCDocument(tabIndex, doc);
194196
} catch (e) {
195197
setOpenRpcDocument(undefined);
196198
setTabOpenRPCDocument(tabIndex, undefined);

src/containers/JSONRPCRequestEditor.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React, { useRef, useEffect } from "react";
22
import MonacoEditor from "@etclabscore/react-monaco-editor";
33
import * as monaco from "monaco-editor";
4-
import { MethodObject, ContentDescriptorObject, OpenRPC } from "@open-rpc/meta-schema";
4+
import { MethodObject, ContentDescriptorObject, OpenrpcDocument } from "@open-rpc/meta-schema";
55
import useWindowSize from "@rehooks/window-size";
66
import { addDiagnostics } from "@etclabscore/monaco-add-json-schema-diagnostics";
77
import openrpcDocumentToJSONRPCSchema from "../helpers/openrpcDocumentToJSONRPCSchema";
88

99
interface IProps {
1010
onChange?: (newValue: any) => void;
1111
openrpcMethodObject?: MethodObject;
12-
openrpcDocument?: OpenRPC;
12+
openrpcDocument?: OpenrpcDocument;
1313
value: any;
1414
}
1515

src/helpers/openrpcDocumentToJSONRPCSchema.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MethodObject, ContentDescriptorObject, OpenRPC, ExampleObject } from "@open-rpc/meta-schema";
1+
import { MethodObject, ContentDescriptorObject, OpenrpcDocument, ExampleObject } from "@open-rpc/meta-schema";
22

33
const schema: any = {
44
type: "object",
@@ -23,7 +23,7 @@ const schema: any = {
2323
},
2424
};
2525

26-
const openrpcDocumentToJSONRPCSchema = (openrpcDocument: OpenRPC) => {
26+
const openrpcDocumentToJSONRPCSchema = (openrpcDocument: OpenrpcDocument) => {
2727
return {
2828
type: "object",
2929
properties: {

src/hooks/useTabs.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { useState, Dispatch, useEffect } from "react";
2-
import { OpenRPC } from "@open-rpc/meta-schema";
2+
import { OpenrpcDocument } from "@open-rpc/meta-schema";
33

44
interface ITab {
55
name: string;
66
content?: any;
77
results?: string;
88
editing?: boolean;
99
url?: string;
10-
openrpcDocument?: OpenRPC;
10+
openrpcDocument?: OpenrpcDocument;
1111
}
1212

1313
const emptyJSONRPC = {
@@ -63,7 +63,7 @@ const useTabs = (defaultTabs?: ITab[]) => {
6363
setTabs(newTabs);
6464
};
6565

66-
const setTabOpenRPCDocument = (ti: number, openrpcDocument: OpenRPC | undefined) => {
66+
const setTabOpenRPCDocument = (ti: number, openrpcDocument: OpenrpcDocument | undefined) => {
6767
const newTabs = tabs.map((innerTab, i) => {
6868
if (i === ti) {
6969
if (!openrpcDocument) {

0 commit comments

Comments
 (0)