Skip to content

Commit

Permalink
Merge pull request #429 from antoine-mulet/fix/inspector-empty-params…
Browse files Browse the repository at this point in the history
…-default-by-name

fix: make empty params default to '{}' for methods with explicit by-name param structure in Inspector
  • Loading branch information
shanejonas authored Jun 19, 2020
2 parents 22d0b20 + 8f84e81 commit 9f55ed5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/plugins/InspectorPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const InspectorPlugin: React.FC<IMethodPluginProps> = (props) => {
const examplePosition = 0;
let example;
let exampleParams: any;
let emptyParams = [] as any;
if (method && method.examples && method.examples[examplePosition]) {
example = method.examples[examplePosition] as ExamplePairingObject;
const paramStructure: TParamStructure = method.paramStructure || "either";
Expand All @@ -24,6 +25,9 @@ const InspectorPlugin: React.FC<IMethodPluginProps> = (props) => {
}), {} as any)
: (example.params as ExampleObject[]).map(((p) => p.value));
}
if (method && method.paramStructure === "by-name") {
emptyParams = {};
}
return (
<Tooltip title="Open in Inspector">
<Button variant="contained" onClick={() => setInspectorContents({
Expand All @@ -32,7 +36,7 @@ const InspectorPlugin: React.FC<IMethodPluginProps> = (props) => {
request: {
jsonrpc: "2.0",
method: method.name,
params: exampleParams || [],
params: exampleParams || emptyParams,
id: 0,
},
})}><span role="img" aria-label="try-it-inspector">🕵️‍♂️</span>️️ Try It Now</Button>
Expand All @@ -42,5 +46,3 @@ const InspectorPlugin: React.FC<IMethodPluginProps> = (props) => {
};

export default InspectorPlugin;


0 comments on commit 9f55ed5

Please sign in to comment.