Skip to content

Commit 5d081a5

Browse files
committed
Start JSON pointers at the root of the document per RFC6901
1 parent 0eb6dcf commit 5d081a5

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

error.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func InputError(attribute string, detail string) *Error {
118118
}
119119

120120
// Assign this after the fact, easier to do
121-
err.Source.Pointer = fmt.Sprintf("data/attributes/%s", strings.ToLower(attribute))
121+
err.Source.Pointer = fmt.Sprintf("/data/attributes/%s", strings.ToLower(attribute))
122122

123123
return err
124124
}

error_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func TestError(t *testing.T) {
3535
testError.Status = 422
3636

3737
Convey("should accept a properly formatted 422 error", func() {
38-
testError.Source.Pointer = "data/attributes/test"
38+
testError.Source.Pointer = "/data/attributes/test"
3939
err := validateError(testError)
4040
So(err, ShouldBeNil)
4141
})

object_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestObject(t *testing.T) {
7878

7979
e, ok := unmarshalErr.(*Error)
8080
So(ok, ShouldBeTrue)
81-
So(e.Source.Pointer, ShouldEqual, "data/attributes/foo")
81+
So(e.Source.Pointer, ShouldEqual, "/data/attributes/foo")
8282
})
8383

8484
Convey("should return a 422 Error correctly for multiple validation failures", func() {
@@ -99,8 +99,8 @@ func TestObject(t *testing.T) {
9999

100100
errorList, ok := unmarshalErr.(*ErrorList)
101101
So(ok, ShouldBeTrue)
102-
So(errorList.Errors[0].Source.Pointer, ShouldEqual, "data/attributes/foo")
103-
So(errorList.Errors[1].Source.Pointer, ShouldEqual, "data/attributes/baz")
102+
So(errorList.Errors[0].Source.Pointer, ShouldEqual, "/data/attributes/foo")
103+
So(errorList.Errors[1].Source.Pointer, ShouldEqual, "/data/attributes/baz")
104104
})
105105

106106
})

request_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestParsing(t *testing.T) {
6363
vErr, ok := err.(*Error)
6464
So(ok, ShouldBeTrue)
6565
So(vErr.Status, ShouldEqual, 422)
66-
So(vErr.Source.Pointer, ShouldEqual, "data/attributes/type")
66+
So(vErr.Source.Pointer, ShouldEqual, "/data/attributes/type")
6767
})
6868
})
6969

@@ -105,7 +105,7 @@ func TestParsing(t *testing.T) {
105105
vErr, ok := err.(*Error)
106106
So(ok, ShouldBeTrue)
107107
So(vErr.Status, ShouldEqual, 422)
108-
So(vErr.Source.Pointer, ShouldEqual, "data/attributes/id")
108+
So(vErr.Source.Pointer, ShouldEqual, "/data/attributes/id")
109109
})
110110
})
111111
})

0 commit comments

Comments
 (0)