Skip to content

Commit

Permalink
feat(MethodCallValidator): allow rpc discover
Browse files Browse the repository at this point in the history
fixes #155
  • Loading branch information
BelfordZ committed Jun 25, 2019
1 parent 2e64de6 commit ad5b7b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index-web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ export {
OpenRPCDocumentValidationError,
OpenRPCDocumentDereferencingError,
ContentDescriptorNotFoundInMethodError,
};
};
6 changes: 6 additions & 0 deletions src/method-call-validator/method-call-validator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,10 @@ describe("MethodCallValidator", () => {
expect(result).toEqual([]);
});

it("rpc.discover is allowed", () => {
const example = getExampleSchema() as any;
const methodCallValidator = new MethodCallValidator(example);
const result = methodCallValidator.validate("rpc.discover", []);
expect(result).toEqual([]);
});
});
1 change: 1 addition & 0 deletions src/method-call-validator/method-call-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default class MethodCallValidator {
*
*/
public validate(methodName: string, params: any[]): MethodCallParameterValidationError[] {
if (methodName === "rpc.discover") { return []; }
const method = _.find(this.document.methods, { name: methodName }) as MethodObject;

if (method.params === undefined) {
Expand Down

0 comments on commit ad5b7b8

Please # to comment.