@@ -7,10 +7,11 @@ type ValidationOption func(options *ValidationOptions)
77
88// ValidationOptions provides configuration for validating OpenAPI documents.
99type ValidationOptions struct {
10- SchemaFormatValidationEnabled bool
11- SchemaPatternValidationDisabled bool
12- ExamplesValidationDisabled bool
1310 examplesValidationAsReq , examplesValidationAsRes bool
11+ examplesValidationDisabled bool
12+ schemaDefaultsValidationDisabled bool
13+ schemaFormatValidationEnabled bool
14+ schemaPatternValidationDisabled bool
1415}
1516
1617type validationOptionsKey struct {}
@@ -19,46 +20,62 @@ type validationOptionsKey struct{}
1920// By default, schema format validation is disabled.
2021func EnableSchemaFormatValidation () ValidationOption {
2122 return func (options * ValidationOptions ) {
22- options .SchemaFormatValidationEnabled = true
23+ options .schemaFormatValidationEnabled = true
2324 }
2425}
2526
2627// DisableSchemaFormatValidation does the opposite of EnableSchemaFormatValidation.
2728// By default, schema format validation is disabled.
2829func DisableSchemaFormatValidation () ValidationOption {
2930 return func (options * ValidationOptions ) {
30- options .SchemaFormatValidationEnabled = false
31+ options .schemaFormatValidationEnabled = false
3132 }
3233}
3334
3435// EnableSchemaPatternValidation does the opposite of DisableSchemaPatternValidation.
3536// By default, schema pattern validation is enabled.
3637func EnableSchemaPatternValidation () ValidationOption {
3738 return func (options * ValidationOptions ) {
38- options .SchemaPatternValidationDisabled = false
39+ options .schemaPatternValidationDisabled = false
3940 }
4041}
4142
4243// DisableSchemaPatternValidation makes Validate not return an error when validating patterns that are not supported by the Go regexp engine.
4344func DisableSchemaPatternValidation () ValidationOption {
4445 return func (options * ValidationOptions ) {
45- options .SchemaPatternValidationDisabled = true
46+ options .schemaPatternValidationDisabled = true
47+ }
48+ }
49+
50+ // EnableSchemaDefaultsValidation does the opposite of DisableSchemaDefaultsValidation.
51+ // By default, schema default values are validated against their schema.
52+ func EnableSchemaDefaultsValidation () ValidationOption {
53+ return func (options * ValidationOptions ) {
54+ options .schemaDefaultsValidationDisabled = false
55+ }
56+ }
57+
58+ // DisableSchemaDefaultsValidation disables schemas' default field validation.
59+ // By default, schema default values are validated against their schema.
60+ func DisableSchemaDefaultsValidation () ValidationOption {
61+ return func (options * ValidationOptions ) {
62+ options .schemaDefaultsValidationDisabled = true
4663 }
4764}
4865
4966// EnableExamplesValidation does the opposite of DisableExamplesValidation.
5067// By default, all schema examples are validated.
5168func EnableExamplesValidation () ValidationOption {
5269 return func (options * ValidationOptions ) {
53- options .ExamplesValidationDisabled = false
70+ options .examplesValidationDisabled = false
5471 }
5572}
5673
5774// DisableExamplesValidation disables all example schema validation.
5875// By default, all schema examples are validated.
5976func DisableExamplesValidation () ValidationOption {
6077 return func (options * ValidationOptions ) {
61- options .ExamplesValidationDisabled = true
78+ options .examplesValidationDisabled = true
6279 }
6380}
6481
0 commit comments