forked from getkin/kin-openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidation_issue409_test.go
50 lines (38 loc) · 1.19 KB
/
validation_issue409_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
48
49
50
package openapi3_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/getkin/kin-openapi/openapi3"
)
func TestIssue409PatternIgnored(t *testing.T) {
l := openapi3.NewLoader()
s, err := l.LoadFromFile("testdata/issue409.yml")
require.NoError(t, err)
err = s.Validate(l.Context, openapi3.DisableSchemaPatternValidation())
assert.NoError(t, err)
}
func TestIssue409PatternNotIgnored(t *testing.T) {
l := openapi3.NewLoader()
s, err := l.LoadFromFile("testdata/issue409.yml")
require.NoError(t, err)
err = s.Validate(l.Context)
assert.Error(t, err)
}
func TestIssue409HygienicUseOfCtx(t *testing.T) {
l := openapi3.NewLoader()
doc, err := l.LoadFromFile("testdata/issue409.yml")
require.NoError(t, err)
err = doc.Validate(l.Context, openapi3.DisableSchemaPatternValidation())
assert.NoError(t, err)
err = doc.Validate(l.Context)
assert.Error(t, err)
// and the other way
l = openapi3.NewLoader()
doc, err = l.LoadFromFile("testdata/issue409.yml")
require.NoError(t, err)
err = doc.Validate(l.Context)
assert.Error(t, err)
err = doc.Validate(l.Context, openapi3.DisableSchemaPatternValidation())
assert.NoError(t, err)
}