-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathref_test.go
More file actions
34 lines (27 loc) · 732 Bytes
/
ref_test.go
File metadata and controls
34 lines (27 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package openapi_test
import (
"testing"
"github.com/MarkRosemaker/openapi"
)
func TestReference_JSON(t *testing.T) {
t.Parallel()
// Reference Object Example
testJSON(t, []byte(`{
"$ref": "#/components/schemas/Pet"
}`), &openapi.Reference{})
// Relative Schema Document Example
testJSON(t, []byte(`{
"$ref": "Pet.json"
}`), &openapi.Reference{})
// Relative Documents With Embedded Schema Example
testJSON(t, []byte(`{
"$ref": "definitions.json#/Pet"
}`), &openapi.Reference{})
}
func TestReference(t *testing.T) {
if err := (&openapi.Reference{}).Validate(); err == nil {
t.Fatal("expected error")
} else if want := `$ref is required`; err.Error() != want {
t.Fatalf("want: %s, got: %s", want, err)
}
}