...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package spec
16
17 import (
18 "encoding/json"
19 "testing"
20
21 "github.com/stretchr/testify/assert"
22 "github.com/stretchr/testify/require"
23 )
24
25 var pathItem = PathItem{
26 Refable: Refable{Ref: MustCreateRef("Dog")},
27 VendorExtensible: VendorExtensible{
28 Extensions: map[string]interface{}{
29 "x-framework": "go-swagger",
30 },
31 },
32 PathItemProps: PathItemProps{
33 Get: &Operation{
34 OperationProps: OperationProps{Description: "get operation description"},
35 },
36 Put: &Operation{
37 OperationProps: OperationProps{Description: "put operation description"},
38 },
39 Post: &Operation{
40 OperationProps: OperationProps{Description: "post operation description"},
41 },
42 Delete: &Operation{
43 OperationProps: OperationProps{Description: "delete operation description"},
44 },
45 Options: &Operation{
46 OperationProps: OperationProps{Description: "options operation description"},
47 },
48 Head: &Operation{
49 OperationProps: OperationProps{Description: "head operation description"},
50 },
51 Patch: &Operation{
52 OperationProps: OperationProps{Description: "patch operation description"},
53 },
54 Parameters: []Parameter{
55 {
56 ParamProps: ParamProps{In: "path"},
57 },
58 },
59 },
60 }
61
62 const pathItemJSON = `{
63 "$ref": "Dog",
64 "x-framework": "go-swagger",
65 "get": { "description": "get operation description" },
66 "put": { "description": "put operation description" },
67 "post": { "description": "post operation description" },
68 "delete": { "description": "delete operation description" },
69 "options": { "description": "options operation description" },
70 "head": { "description": "head operation description" },
71 "patch": { "description": "patch operation description" },
72 "parameters": [{"in":"path"}]
73 }`
74
75 func TestIntegrationPathItem(t *testing.T) {
76 var actual PathItem
77 require.NoError(t, json.Unmarshal([]byte(pathItemJSON), &actual))
78 assert.EqualValues(t, actual, pathItem)
79
80 assertParsesJSON(t, pathItemJSON, pathItem)
81 }
82
View as plain text