-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpaths_test.go
47 lines (33 loc) · 1.48 KB
/
paths_test.go
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
35
36
37
38
39
40
41
42
43
44
45
46
47
package oas
import (
"net/http"
"testing"
)
func TestPaths(t *testing.T) {
g := NewCaseGroup("Paths")
g.It("get", `{"/pets":{"get":{"tags":["pets"],"summary":"List all pets","operationId":"listPets","parameters":[{"name":"limit","in":"query","description":"How many items to return at one time (max 100)","schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"An paged array of pets","headers":{"x-next":{"schema":{"type":"string","description":"A link to the next page of responses"}}},"content":{"application/json":{"schema":{"type":"string"}}}},"default":{"description":"unexpected error","content":{"application/json":{"schema":{"type":"string"}}}}}}}}`, func() *Paths {
paths := &Paths{}
op := NewOperation("listPets")
op.Summary = "List all pets"
op.Tags = []string{"pets"}
parameterLimit := QueryParameter("limit", Integer(), false).
WithDesc("How many items to return at one time (max 100)")
op.AddParameter(parameterLimit)
{
resp := NewResponse("An paged array of pets")
s := String()
s.Description = "A link to the next page of responses"
resp.AddHeader("x-next", NewHeaderWithSchema(s))
resp.AddContent("application/json", NewMediaTypeWithSchema(String()))
op.AddResponse(http.StatusOK, resp)
}
{
resp := NewResponse("unexpected error")
resp.AddContent("application/json", NewMediaTypeWithSchema(String()))
op.SetDefaultResponse(resp)
}
paths.AddOperation(GET, "/pets", op)
return paths
}())
g.Run(t)
}