diff options
author | Maciej Wereski <m.wereski@partner.samsung.com> | 2018-10-02 13:03:21 +0200 |
---|---|---|
committer | Maciej Wereski <m.wereski@partner.samsung.com> | 2018-10-04 16:40:06 +0200 |
commit | 3bcb507ed6160c2bf47186be52a41c66a30893a0 (patch) | |
tree | 767065ae9d8cd196043462eb6393858cc24205fd | |
parent | d194d9cb4180cdf8799ca1213f33c8803002c7d9 (diff) | |
download | boruta-3bcb507ed6160c2bf47186be52a41c66a30893a0.tar.gz boruta-3bcb507ed6160c2bf47186be52a41c66a30893a0.tar.bz2 boruta-3bcb507ed6160c2bf47186be52a41c66a30893a0.zip |
HTTP API: Change error JSON format
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, 32 insertions, 32 deletions
diff --git a/http/client/client_test.go b/http/client/client_test.go index 8cd76f7..71cdb63 100644 --- a/http/client/client_test.go +++ b/http/client/client_test.go @@ -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" } ` diff --git a/http/error.go b/http/error.go index 9d1c139..f69b8c2 100644 --- a/http/error.go +++ b/http/error.go @@ -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:"-"` } diff --git a/http/server/api/v1/testdata/acquire-worker-bad-id-POST.json b/http/server/api/v1/testdata/acquire-worker-bad-id-POST.json index 9a1b539..1d4a5f6 100644 --- a/http/server/api/v1/testdata/acquire-worker-bad-id-POST.json +++ b/http/server/api/v1/testdata/acquire-worker-bad-id-POST.json @@ -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 diff --git a/http/server/api/v1/testdata/acquire-worker-missing-POST.json b/http/server/api/v1/testdata/acquire-worker-missing-POST.json index bb60840..9c592e3 100644 --- a/http/server/api/v1/testdata/acquire-worker-missing-POST.json +++ b/http/server/api/v1/testdata/acquire-worker-missing-POST.json @@ -1 +1 @@ -{"error":"Request not found"}
\ No newline at end of file +{"message":"Request not found"}
\ No newline at end of file diff --git a/http/server/api/v1/testdata/close-req-bad-id-POST.json b/http/server/api/v1/testdata/close-req-bad-id-POST.json index 9a1b539..1d4a5f6 100644 --- a/http/server/api/v1/testdata/close-req-bad-id-POST.json +++ b/http/server/api/v1/testdata/close-req-bad-id-POST.json @@ -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 diff --git a/http/server/api/v1/testdata/close-req-missing-POST.json b/http/server/api/v1/testdata/close-req-missing-POST.json index bb60840..9c592e3 100644 --- a/http/server/api/v1/testdata/close-req-missing-POST.json +++ b/http/server/api/v1/testdata/close-req-missing-POST.json @@ -1 +1 @@ -{"error":"Request not found"}
\ No newline at end of file +{"message":"Request not found"}
\ No newline at end of file diff --git a/http/server/api/v1/testdata/filter-reqs-bad-filter-POST.json b/http/server/api/v1/testdata/filter-reqs-bad-filter-POST.json index f6dd9fd..9161a8a 100644 --- a/http/server/api/v1/testdata/filter-reqs-bad-filter-POST.json +++ b/http/server/api/v1/testdata/filter-reqs-bad-filter-POST.json @@ -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 diff --git a/http/server/api/v1/testdata/filter-reqs-malformed-json-POST.json b/http/server/api/v1/testdata/filter-reqs-malformed-json-POST.json index c59dde1..131375f 100644 --- a/http/server/api/v1/testdata/filter-reqs-malformed-json-POST.json +++ b/http/server/api/v1/testdata/filter-reqs-malformed-json-POST.json @@ -1 +1 @@ -{"error":"invalid request: unexpected EOF"}
\ No newline at end of file +{"message":"invalid request: unexpected EOF"}
\ No newline at end of file diff --git a/http/server/api/v1/testdata/filter-workers-bad-filter-POST.json b/http/server/api/v1/testdata/filter-workers-bad-filter-POST.json index f6dd9fd..9161a8a 100644 --- a/http/server/api/v1/testdata/filter-workers-bad-filter-POST.json +++ b/http/server/api/v1/testdata/filter-workers-bad-filter-POST.json @@ -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 diff --git a/http/server/api/v1/testdata/filter-workers-malformed-json-POST.json b/http/server/api/v1/testdata/filter-workers-malformed-json-POST.json index c59dde1..131375f 100644 --- a/http/server/api/v1/testdata/filter-workers-malformed-json-POST.json +++ b/http/server/api/v1/testdata/filter-workers-malformed-json-POST.json @@ -1 +1 @@ -{"error":"invalid request: unexpected EOF"}
\ No newline at end of file +{"message":"invalid request: unexpected EOF"}
\ No newline at end of file diff --git a/http/server/api/v1/testdata/new-req-bad-prio-POST.json b/http/server/api/v1/testdata/new-req-bad-prio-POST.json index f97a9e1..69f5382 100644 --- a/http/server/api/v1/testdata/new-req-bad-prio-POST.json +++ b/http/server/api/v1/testdata/new-req-bad-prio-POST.json @@ -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 diff --git a/http/server/api/v1/testdata/new-req-malformed-json-POST.json b/http/server/api/v1/testdata/new-req-malformed-json-POST.json index c59dde1..131375f 100644 --- a/http/server/api/v1/testdata/new-req-malformed-json-POST.json +++ b/http/server/api/v1/testdata/new-req-malformed-json-POST.json @@ -1 +1 @@ -{"error":"invalid request: unexpected EOF"}
\ No newline at end of file +{"message":"invalid request: unexpected EOF"}
\ No newline at end of file diff --git a/http/server/api/v1/testdata/prolong-access-bad-id-POST.json b/http/server/api/v1/testdata/prolong-access-bad-id-POST.json index 9a1b539..1d4a5f6 100644 --- a/http/server/api/v1/testdata/prolong-access-bad-id-POST.json +++ b/http/server/api/v1/testdata/prolong-access-bad-id-POST.json @@ -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 diff --git a/http/server/api/v1/testdata/prolong-access-missing-POST.json b/http/server/api/v1/testdata/prolong-access-missing-POST.json index bb60840..9c592e3 100644 --- a/http/server/api/v1/testdata/prolong-access-missing-POST.json +++ b/http/server/api/v1/testdata/prolong-access-missing-POST.json @@ -1 +1 @@ -{"error":"Request not found"}
\ No newline at end of file +{"message":"Request not found"}
\ No newline at end of file diff --git a/http/server/api/v1/testdata/req-info-bad-id-GET.json b/http/server/api/v1/testdata/req-info-bad-id-GET.json index 9a1b539..1d4a5f6 100644 --- a/http/server/api/v1/testdata/req-info-bad-id-GET.json +++ b/http/server/api/v1/testdata/req-info-bad-id-GET.json @@ -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 diff --git a/http/server/api/v1/testdata/req-info-missing-GET.json b/http/server/api/v1/testdata/req-info-missing-GET.json index bb60840..9c592e3 100644 --- a/http/server/api/v1/testdata/req-info-missing-GET.json +++ b/http/server/api/v1/testdata/req-info-missing-GET.json @@ -1 +1 @@ -{"error":"Request not found"}
\ No newline at end of file +{"message":"Request not found"}
\ No newline at end of file diff --git a/http/server/api/v1/testdata/update-req-bad-id-POST.json b/http/server/api/v1/testdata/update-req-bad-id-POST.json index 9a1b539..1d4a5f6 100644 --- a/http/server/api/v1/testdata/update-req-bad-id-POST.json +++ b/http/server/api/v1/testdata/update-req-bad-id-POST.json @@ -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 diff --git a/http/server/api/v1/testdata/update-req-empty-POST.json b/http/server/api/v1/testdata/update-req-empty-POST.json index 6bf6e01..905220f 100644 --- a/http/server/api/v1/testdata/update-req-empty-POST.json +++ b/http/server/api/v1/testdata/update-req-empty-POST.json @@ -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 diff --git a/http/server/api/v1/testdata/update-req-malformed-json-POST.json b/http/server/api/v1/testdata/update-req-malformed-json-POST.json index c59dde1..131375f 100644 --- a/http/server/api/v1/testdata/update-req-malformed-json-POST.json +++ b/http/server/api/v1/testdata/update-req-malformed-json-POST.json @@ -1 +1 @@ -{"error":"invalid request: unexpected EOF"}
\ No newline at end of file +{"message":"invalid request: unexpected EOF"}
\ No newline at end of file diff --git a/http/server/api/v1/testdata/update-req-mismatch-POST.json b/http/server/api/v1/testdata/update-req-mismatch-POST.json index 7c2784c..5b306ea 100644 --- a/http/server/api/v1/testdata/update-req-mismatch-POST.json +++ b/http/server/api/v1/testdata/update-req-mismatch-POST.json @@ -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 diff --git a/http/server/api/v1/testdata/update-req-missing-POST.json b/http/server/api/v1/testdata/update-req-missing-POST.json index bb60840..9c592e3 100644 --- a/http/server/api/v1/testdata/update-req-missing-POST.json +++ b/http/server/api/v1/testdata/update-req-missing-POST.json @@ -1 +1 @@ -{"error":"Request not found"}
\ No newline at end of file +{"message":"Request not found"}
\ No newline at end of file diff --git a/http/server/api/v1/testdata/worker-deregister-bad-uuid-POST.json b/http/server/api/v1/testdata/worker-deregister-bad-uuid-POST.json index 4145754..b89337c 100644 --- a/http/server/api/v1/testdata/worker-deregister-bad-uuid-POST.json +++ b/http/server/api/v1/testdata/worker-deregister-bad-uuid-POST.json @@ -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 diff --git a/http/server/api/v1/testdata/worker-deregister-missing-POST.json b/http/server/api/v1/testdata/worker-deregister-missing-POST.json index 533be90..aae0bad 100644 --- a/http/server/api/v1/testdata/worker-deregister-missing-POST.json +++ b/http/server/api/v1/testdata/worker-deregister-missing-POST.json @@ -1 +1 @@ -{"error":"Worker not found"}
\ No newline at end of file +{"message":"Worker not found"}
\ No newline at end of file diff --git a/http/server/api/v1/testdata/worker-info-bad-uuid-GET.json b/http/server/api/v1/testdata/worker-info-bad-uuid-GET.json index 4145754..b89337c 100644 --- a/http/server/api/v1/testdata/worker-info-bad-uuid-GET.json +++ b/http/server/api/v1/testdata/worker-info-bad-uuid-GET.json @@ -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 diff --git a/http/server/api/v1/testdata/worker-info-missing-GET.json b/http/server/api/v1/testdata/worker-info-missing-GET.json index 533be90..aae0bad 100644 --- a/http/server/api/v1/testdata/worker-info-missing-GET.json +++ b/http/server/api/v1/testdata/worker-info-missing-GET.json @@ -1 +1 @@ -{"error":"Worker not found"}
\ No newline at end of file +{"message":"Worker not found"}
\ No newline at end of file diff --git a/http/server/api/v1/testdata/worker-set-groups-bad-uuid-POST.json b/http/server/api/v1/testdata/worker-set-groups-bad-uuid-POST.json index 4145754..b89337c 100644 --- a/http/server/api/v1/testdata/worker-set-groups-bad-uuid-POST.json +++ b/http/server/api/v1/testdata/worker-set-groups-bad-uuid-POST.json @@ -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 diff --git a/http/server/api/v1/testdata/worker-set-groups-malformed-json-POST.json b/http/server/api/v1/testdata/worker-set-groups-malformed-json-POST.json index c59dde1..131375f 100644 --- a/http/server/api/v1/testdata/worker-set-groups-malformed-json-POST.json +++ b/http/server/api/v1/testdata/worker-set-groups-malformed-json-POST.json @@ -1 +1 @@ -{"error":"invalid request: unexpected EOF"}
\ No newline at end of file +{"message":"invalid request: unexpected EOF"}
\ No newline at end of file diff --git a/http/server/api/v1/testdata/worker-set-groups-missing-POST.json b/http/server/api/v1/testdata/worker-set-groups-missing-POST.json index 533be90..aae0bad 100644 --- a/http/server/api/v1/testdata/worker-set-groups-missing-POST.json +++ b/http/server/api/v1/testdata/worker-set-groups-missing-POST.json @@ -1 +1 @@ -{"error":"Worker not found"}
\ No newline at end of file +{"message":"Worker not found"}
\ No newline at end of file diff --git a/http/server/api/v1/testdata/worker-set-state-bad-uuid-POST.json b/http/server/api/v1/testdata/worker-set-state-bad-uuid-POST.json index 4145754..b89337c 100644 --- a/http/server/api/v1/testdata/worker-set-state-bad-uuid-POST.json +++ b/http/server/api/v1/testdata/worker-set-state-bad-uuid-POST.json @@ -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 diff --git a/http/server/api/v1/testdata/worker-set-state-malformed-json-POST.json b/http/server/api/v1/testdata/worker-set-state-malformed-json-POST.json index c59dde1..131375f 100644 --- a/http/server/api/v1/testdata/worker-set-state-malformed-json-POST.json +++ b/http/server/api/v1/testdata/worker-set-state-malformed-json-POST.json @@ -1 +1 @@ -{"error":"invalid request: unexpected EOF"}
\ No newline at end of file +{"message":"invalid request: unexpected EOF"}
\ No newline at end of file diff --git a/http/server/api/v1/testdata/worker-set-state-missing-POST.json b/http/server/api/v1/testdata/worker-set-state-missing-POST.json index 533be90..aae0bad 100644 --- a/http/server/api/v1/testdata/worker-set-state-missing-POST.json +++ b/http/server/api/v1/testdata/worker-set-state-missing-POST.json @@ -1 +1 @@ -{"error":"Worker not found"}
\ No newline at end of file +{"message":"Worker not found"}
\ No newline at end of file |