HTTP API: Change error JSON format 53/189953/6
authorMaciej Wereski <m.wereski@partner.samsung.com>
Tue, 2 Oct 2018 11:03:21 +0000 (13:03 +0200)
committerMaciej Wereski <m.wereski@partner.samsung.com>
Thu, 4 Oct 2018 14:40:06 +0000 (16:40 +0200)
Swagger in case of error passes its details in "message" field in JSON.
Change "error" to "message" in Boruta error JSONs to comply with Swagger
(which is used in Weles).

Change-Id: I6bcbd3355392467696044f304d5b83ccc410c354
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
31 files changed:
http/client/client_test.go
http/error.go
http/server/api/v1/testdata/acquire-worker-bad-id-POST.json
http/server/api/v1/testdata/acquire-worker-missing-POST.json
http/server/api/v1/testdata/close-req-bad-id-POST.json
http/server/api/v1/testdata/close-req-missing-POST.json
http/server/api/v1/testdata/filter-reqs-bad-filter-POST.json
http/server/api/v1/testdata/filter-reqs-malformed-json-POST.json
http/server/api/v1/testdata/filter-workers-bad-filter-POST.json
http/server/api/v1/testdata/filter-workers-malformed-json-POST.json
http/server/api/v1/testdata/new-req-bad-prio-POST.json
http/server/api/v1/testdata/new-req-malformed-json-POST.json
http/server/api/v1/testdata/prolong-access-bad-id-POST.json
http/server/api/v1/testdata/prolong-access-missing-POST.json
http/server/api/v1/testdata/req-info-bad-id-GET.json
http/server/api/v1/testdata/req-info-missing-GET.json
http/server/api/v1/testdata/update-req-bad-id-POST.json
http/server/api/v1/testdata/update-req-empty-POST.json
http/server/api/v1/testdata/update-req-malformed-json-POST.json
http/server/api/v1/testdata/update-req-mismatch-POST.json
http/server/api/v1/testdata/update-req-missing-POST.json
http/server/api/v1/testdata/worker-deregister-bad-uuid-POST.json
http/server/api/v1/testdata/worker-deregister-missing-POST.json
http/server/api/v1/testdata/worker-info-bad-uuid-GET.json
http/server/api/v1/testdata/worker-info-missing-GET.json
http/server/api/v1/testdata/worker-set-groups-bad-uuid-POST.json
http/server/api/v1/testdata/worker-set-groups-malformed-json-POST.json
http/server/api/v1/testdata/worker-set-groups-missing-POST.json
http/server/api/v1/testdata/worker-set-state-bad-uuid-POST.json
http/server/api/v1/testdata/worker-set-state-malformed-json-POST.json
http/server/api/v1/testdata/worker-set-state-missing-POST.json

index 8cd76f7..71cdb63 100644 (file)
@@ -293,7 +293,7 @@ func TestGetServerError(t *testing.T) {
 
        missing := `
        {
-                 "error": "Request not found"
+                 "message": "Request not found"
        }
        `
        resp.Body = ioutil.NopCloser(strings.NewReader(missing))
@@ -323,7 +323,7 @@ func TestProcessResponse(t *testing.T) {
        var srvErr *util.ServerError
        missing := `
        {
-               "error": "Request not found"
+               "message": "Request not found"
        }
        `
 
index 9d1c139..f69b8c2 100644 (file)
@@ -30,7 +30,7 @@ import (
 // ServerError represents error that occured while creating response.
 type ServerError struct {
        // Err contains general error string.
-       Err string `json:"error"`
+       Err string `json:"message"`
        // Status contains HTTP error code that should be returned with the error.
        Status int `json:"-"`
 }
index 9a1b539..1d4a5f6 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: ID provided in URL isn't valid"}
\ No newline at end of file
+{"message":"invalid request: ID provided in URL isn't valid"}
\ No newline at end of file
index bb60840..9c592e3 100644 (file)
@@ -1 +1 @@
-{"error":"Request not found"}
\ No newline at end of file
+{"message":"Request not found"}
\ No newline at end of file
index 9a1b539..1d4a5f6 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: ID provided in URL isn't valid"}
\ No newline at end of file
+{"message":"invalid request: ID provided in URL isn't valid"}
\ No newline at end of file
index bb60840..9c592e3 100644 (file)
@@ -1 +1 @@
-{"error":"Request not found"}
\ No newline at end of file
+{"message":"Request not found"}
\ No newline at end of file
index f6dd9fd..9161a8a 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: foo bar: pizza failed"}
\ No newline at end of file
+{"message":"invalid request: foo bar: pizza failed"}
\ No newline at end of file
index c59dde1..131375f 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: unexpected EOF"}
\ No newline at end of file
+{"message":"invalid request: unexpected EOF"}
\ No newline at end of file
index f6dd9fd..9161a8a 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: foo bar: pizza failed"}
\ No newline at end of file
+{"message":"invalid request: foo bar: pizza failed"}
\ No newline at end of file
index c59dde1..131375f 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: unexpected EOF"}
\ No newline at end of file
+{"message":"invalid request: unexpected EOF"}
\ No newline at end of file
index f97a9e1..69f5382 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: requested priority out of bounds"}
\ No newline at end of file
+{"message":"invalid request: requested priority out of bounds"}
\ No newline at end of file
index c59dde1..131375f 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: unexpected EOF"}
\ No newline at end of file
+{"message":"invalid request: unexpected EOF"}
\ No newline at end of file
index 9a1b539..1d4a5f6 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: ID provided in URL isn't valid"}
\ No newline at end of file
+{"message":"invalid request: ID provided in URL isn't valid"}
\ No newline at end of file
index bb60840..9c592e3 100644 (file)
@@ -1 +1 @@
-{"error":"Request not found"}
\ No newline at end of file
+{"message":"Request not found"}
\ No newline at end of file
index 9a1b539..1d4a5f6 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: ID provided in URL isn't valid"}
\ No newline at end of file
+{"message":"invalid request: ID provided in URL isn't valid"}
\ No newline at end of file
index bb60840..9c592e3 100644 (file)
@@ -1 +1 @@
-{"error":"Request not found"}
\ No newline at end of file
+{"message":"Request not found"}
\ No newline at end of file
index 9a1b539..1d4a5f6 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: ID provided in URL isn't valid"}
\ No newline at end of file
+{"message":"invalid request: ID provided in URL isn't valid"}
\ No newline at end of file
index 6bf6e01..905220f 100644 (file)
@@ -1 +1 @@
-{"error":"no body provided in HTTP request"}
\ No newline at end of file
+{"message":"no body provided in HTTP request"}
\ No newline at end of file
index c59dde1..131375f 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: unexpected EOF"}
\ No newline at end of file
+{"message":"invalid request: unexpected EOF"}
\ No newline at end of file
index 7c2784c..5b306ea 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: request ID set in JSON doesn't match ID from URL"}
\ No newline at end of file
+{"message":"invalid request: request ID set in JSON doesn't match ID from URL"}
\ No newline at end of file
index bb60840..9c592e3 100644 (file)
@@ -1 +1 @@
-{"error":"Request not found"}
\ No newline at end of file
+{"message":"Request not found"}
\ No newline at end of file
index 4145754..b89337c 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: ID provided in URL isn't valid UUID"}
\ No newline at end of file
+{"message":"invalid request: ID provided in URL isn't valid UUID"}
\ No newline at end of file
index 533be90..aae0bad 100644 (file)
@@ -1 +1 @@
-{"error":"Worker not found"}
\ No newline at end of file
+{"message":"Worker not found"}
\ No newline at end of file
index 4145754..b89337c 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: ID provided in URL isn't valid UUID"}
\ No newline at end of file
+{"message":"invalid request: ID provided in URL isn't valid UUID"}
\ No newline at end of file
index 533be90..aae0bad 100644 (file)
@@ -1 +1 @@
-{"error":"Worker not found"}
\ No newline at end of file
+{"message":"Worker not found"}
\ No newline at end of file
index 4145754..b89337c 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: ID provided in URL isn't valid UUID"}
\ No newline at end of file
+{"message":"invalid request: ID provided in URL isn't valid UUID"}
\ No newline at end of file
index c59dde1..131375f 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: unexpected EOF"}
\ No newline at end of file
+{"message":"invalid request: unexpected EOF"}
\ No newline at end of file
index 533be90..aae0bad 100644 (file)
@@ -1 +1 @@
-{"error":"Worker not found"}
\ No newline at end of file
+{"message":"Worker not found"}
\ No newline at end of file
index 4145754..b89337c 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: ID provided in URL isn't valid UUID"}
\ No newline at end of file
+{"message":"invalid request: ID provided in URL isn't valid UUID"}
\ No newline at end of file
index c59dde1..131375f 100644 (file)
@@ -1 +1 @@
-{"error":"invalid request: unexpected EOF"}
\ No newline at end of file
+{"message":"invalid request: unexpected EOF"}
\ No newline at end of file
index 533be90..aae0bad 100644 (file)
@@ -1 +1 @@
-{"error":"Worker not found"}
\ No newline at end of file
+{"message":"Worker not found"}
\ No newline at end of file