From 1518d673da9074d42343549991e8ff9e5736b43a Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Sun, 28 Jan 2024 21:51:12 +0100 Subject: [PATCH] cmd/speccheck: disable error check --- cmd/speccheck/check.go | 10 +++++++--- cmd/speccheck/roundtrips.go | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/speccheck/check.go b/cmd/speccheck/check.go index 438cb28..586442f 100644 --- a/cmd/speccheck/check.go +++ b/cmd/speccheck/check.go @@ -37,14 +37,18 @@ func checkSpec(methods map[string]*methodSchema, rts []*roundTrip, re *regexp.Re return fmt.Errorf("missing required parameter %s.param[%d]", rt.method, i) } if err := validate(&method.params[i].schema, rt.params[i], fmt.Sprintf("%s.param[%d]", rt.method, i)); err != nil { - return fmt.Errorf("unable to validate parameter: %s", err) + return fmt.Errorf("unable to validate parameter in %s: %s", rt.name, err) } } - if err := validate(&method.result.schema, rt.response, fmt.Sprintf("%s.result", rt.method)); err != nil { + if rt.response.Result == nil && rt.response.Error != nil { + // skip validation of errors, they haven't been standardized + continue + } + if err := validate(&method.result.schema, rt.response.Result, fmt.Sprintf("%s.result", rt.method)); err != nil { // Print out the value and schema if there is an error to further debug. buf, _ := json.Marshal(method.result.schema) fmt.Println(string(buf)) - fmt.Println(string(rt.response)) + fmt.Println(string(rt.response.Result)) fmt.Println() return fmt.Errorf("invalid result %s\n%#v", rt.name, err) } diff --git a/cmd/speccheck/roundtrips.go b/cmd/speccheck/roundtrips.go index 57f1d39..eb7b473 100644 --- a/cmd/speccheck/roundtrips.go +++ b/cmd/speccheck/roundtrips.go @@ -30,7 +30,7 @@ type roundTrip struct { method string name string params [][]byte - response []byte + response *jsonrpcMessage } // readRtts walks a root directory and parses round trip HTTP exchanges @@ -99,7 +99,7 @@ func readTest(testname string, filename string) ([]*roundTrip, error) { if err != nil { return nil, fmt.Errorf("unable to parse params: %s %v", err, req.Params) } - rts = append(rts, &roundTrip{req.Method, testname, params, resp.Result}) + rts = append(rts, &roundTrip{req.Method, testname, params, &resp}) req = nil default: return nil, fmt.Errorf("invalid line in test: %s", line)