@@ -32,7 +32,7 @@ type ValidationOptions struct {
3232 Formats map [string ]func (v any ) error
3333 SchemaCache cache.SchemaCache // Optional cache for compiled schemas
3434 PathTree radix.PathLookup // O(k) path lookup via radix tree (built automatically)
35- pathTreeSet bool // Internal: true if PathTree was explicitly set via WithPathTree
35+ pathTreeDisabled bool // Internal: true if radix tree auto-build was disabled via DisablePathTree
3636 Logger * slog.Logger // Logger for debug/error output (nil = silent)
3737 AllowXMLBodyValidation bool // Allows to convert XML to JSON for validating a request/response body.
3838 AllowURLEncodedBodyValidation bool // Allows to convert URL Encoded to JSON for validating a request/response body.
@@ -80,7 +80,7 @@ func WithExistingOpts(options *ValidationOptions) Option {
8080 o .Formats = options .Formats
8181 o .SchemaCache = options .SchemaCache
8282 o .PathTree = options .PathTree
83- o .pathTreeSet = options .pathTreeSet
83+ o .pathTreeDisabled = options .pathTreeDisabled
8484 o .Logger = options .Logger
8585 o .AllowXMLBodyValidation = options .AllowXMLBodyValidation
8686 o .AllowURLEncodedBodyValidation = options .AllowURLEncodedBodyValidation
@@ -197,11 +197,17 @@ func WithSchemaCache(schemaCache cache.SchemaCache) Option {
197197
198198// WithPathTree sets a custom radix tree for path matching.
199199// The default is built automatically from the OpenAPI specification.
200- // Pass nil to disable the radix tree and use regex-based matching only.
201200func WithPathTree (pathTree radix.PathLookup ) Option {
202201 return func (o * ValidationOptions ) {
203202 o .PathTree = pathTree
204- o .pathTreeSet = true
203+ }
204+ }
205+
206+ // DisablePathTree prevents automatic radix tree construction.
207+ // Use this to fall back to regex-based path matching only.
208+ func DisablePathTree () Option {
209+ return func (o * ValidationOptions ) {
210+ o .pathTreeDisabled = true
205211 }
206212}
207213
@@ -268,9 +274,9 @@ var defaultIgnoredHeaders = []string{
268274 "request-start-time" , // Added by some API clients for timing
269275}
270276
271- // IsPathTreeSet returns true if PathTree was explicitly configured via WithPathTree .
272- func (o * ValidationOptions ) IsPathTreeSet () bool {
273- return o .pathTreeSet
277+ // IsPathTreeDisabled returns true if radix tree auto-build was disabled via DisablePathTree .
278+ func (o * ValidationOptions ) IsPathTreeDisabled () bool {
279+ return o .pathTreeDisabled
274280}
275281
276282// GetEffectiveStrictIgnoredHeaders returns the list of headers to ignore
0 commit comments