fix(httputil): rename error body field platformCode → platform_code (#2)
errorBody() map key corrected from "platformCode" to "platform_code" to match the OpenAPI spec snake_case convention. All HTTP error responses produced by Error(w, err) now emit "platform_code" in the JSON body. PR.md added to .gitignore. Depends on xerrors v1.0.2 (go.mod bumped in follow-up commit after xerrors tag). Reviewed-on: #2 Co-authored-by: Rene Nochebuena Guerrero <rene@nochebuena.dev> Co-committed-by: Rene Nochebuena Guerrero <rene@nochebuena.dev>
This commit was merged in pull request #2.
This commit is contained in:
@@ -248,8 +248,8 @@ func TestError_PlatformCode_IncludedWhenSet(t *testing.T) {
|
||||
t.Errorf("want 404, got %d", rec.Code)
|
||||
}
|
||||
m := decodeMap(t, rec)
|
||||
if m["platformCode"] != "EMPLOYEE_NOT_FOUND" {
|
||||
t.Errorf("platformCode: want EMPLOYEE_NOT_FOUND, got %v", m["platformCode"])
|
||||
if m["platform_code"] != "EMPLOYEE_NOT_FOUND" {
|
||||
t.Errorf("platform_code: want EMPLOYEE_NOT_FOUND, got %v", m["platform_code"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,8 +257,8 @@ func TestError_PlatformCode_OmittedWhenNotSet(t *testing.T) {
|
||||
rec := httptest.NewRecorder()
|
||||
Error(rec, xerrors.New(xerrors.ErrInternal, "unexpected error"))
|
||||
m := decodeMap(t, rec)
|
||||
if _, ok := m["platformCode"]; ok {
|
||||
t.Errorf("platformCode should be absent for errors without a platform code, got %v", m["platformCode"])
|
||||
if _, ok := m["platform_code"]; ok {
|
||||
t.Errorf("platform_code should be absent for errors without a platform code, got %v", m["platform_code"])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user