Skip to content

Commit b6704fb

Browse files
authored
fix: openrpc has json rpc wrapper even if no params (#2631)
1 parent 52b1aa3 commit b6704fb

File tree

1 file changed

+12
-5
lines changed
  • packages/fdr-sdk/src/api-definition/snippets

1 file changed

+12
-5
lines changed

packages/fdr-sdk/src/api-definition/snippets/curl.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ function getBodyJsonString(
9090
value: unknown | null | undefined,
9191
protocol?: Latest.Protocol
9292
): string[] {
93-
if (value == null) {
94-
return [];
95-
}
96-
9793
if (protocol?.type === "openrpc") {
9894
const payload = {
9995
id: 1,
@@ -108,6 +104,10 @@ function getBodyJsonString(
108104
return [`-d '${stringifiedValue}'`];
109105
}
110106

107+
if (value == null) {
108+
return [];
109+
}
110+
111111
if (typeof value === "string") {
112112
return [`-d "${value.replace(/"/g, '\\"')}"`];
113113
}
@@ -211,7 +211,14 @@ function getBodyDataString(
211211
usesApplicationJsonInFormDataValue: boolean,
212212
protocol: Latest.Protocol | undefined
213213
): string[] {
214-
if (method === "GET" || body == null) {
214+
if (method === "GET") {
215+
return [];
216+
}
217+
218+
if (body == null) {
219+
if (protocol?.type === "openrpc") {
220+
getBodyJsonString(undefined, protocol);
221+
}
215222
return [];
216223
}
217224

0 commit comments

Comments
 (0)