Skip to content

Commit 803b1dd

Browse files
committed
Fix schema for JSON-RPC response bodies
Previously we treated the spec-defined schema as the root, but actually it needs to be inside a 'result' wrapper.
1 parent 7bc5c32 commit 803b1dd

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/model/api/jsonrpc.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,22 @@ export class JsonRpcApiResponse implements ApiResponse {
208208
const resultSpec = rpcMethod.methodSpec.result as ContentDescriptorObject;
209209

210210
this.description = fromMarkdown(resultSpec.description);
211-
this.bodySchema = resultSpec.schema as SchemaObject;
211+
this.bodySchema = {
212+
type: 'object',
213+
properties: {
214+
id: { type: 'number' },
215+
jsonrpc: { type: 'string', enum: ['2.0'] },
216+
result: resultSpec.schema as SchemaObject,
217+
error: {
218+
type: 'object',
219+
properties: {
220+
code: { type: 'number' },
221+
message: { type: 'string' }
222+
}
223+
}
224+
},
225+
required: ['id', 'jsonrpc']
226+
};
212227
}
213228

214229
description?: Html;

0 commit comments

Comments
 (0)