forked from getkin/kin-openapi
/
options.go
41 lines (30 loc) · 1.34 KB
/
options.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
package openapi3filter
import "github.com/jhannah/kin-openapi/openapi3"
// DefaultOptions do not set an AuthenticationFunc.
// A spec with security schemes defined will not pass validation
// unless an AuthenticationFunc is defined.
var DefaultOptions = &Options{}
// Options used by ValidateRequest and ValidateResponse
type Options struct {
// Set ExcludeRequestBody so ValidateRequest skips request body validation
ExcludeRequestBody bool
// Set ExcludeResponseBody so ValidateResponse skips response body validation
ExcludeResponseBody bool
// Set IncludeResponseStatus so ValidateResponse fails on response
// status not defined in OpenAPI spec
IncludeResponseStatus bool
MultiError bool
// See NoopAuthenticationFunc
AuthenticationFunc AuthenticationFunc
// Indicates whether default values are set in the
// request. If true, then they are not set
SkipSettingDefaults bool
customSchemaErrorFunc CustomSchemaErrorFunc
}
// CustomSchemaErrorFunc allows for custom the schema error message.
type CustomSchemaErrorFunc func(err *openapi3.SchemaError) string
// WithCustomSchemaErrorFunc sets a function to override the schema error message.
// If the passed function returns an empty string, it returns to the previous Error() implementation.
func (o *Options) WithCustomSchemaErrorFunc(f CustomSchemaErrorFunc) {
o.customSchemaErrorFunc = f
}