@@ -14,42 +14,53 @@ import (
1414//
1515// ValidateQueryParams will validate the query parameters for the request
1616// ValidateHeaderParams will validate the header parameters for the request
17- // ValidateCookieParams will validate the cookie parameters for the request
17+ // ValidateCookieParamsWithPathItem will validate the cookie parameters for the request
1818// ValidatePathParams will validate the path parameters for the request
1919//
2020// Each method accepts an *http.Request and returns true if validation passed,
2121// false if validation failed and a slice of ValidationError pointers.
2222type ParameterValidator interface {
23-
24- // SetPathItem will set the pathItem for the ParameterValidator, all validations will be performed against this pathItem
25- // otherwise if not set, each validation will perform a lookup for the pathItem based on the *http.Request
26- SetPathItem (path * v3.PathItem , pathValue string )
27-
2823 // ValidateQueryParams accepts an *http.Request and validates the query parameters against the OpenAPI specification.
2924 // The method will locate the correct path, and operation, based on the verb. The parameters for the operation
3025 // will be matched and validated against what has been supplied in the http.Request query string.
3126 ValidateQueryParams (request * http.Request ) (bool , []* errors.ValidationError )
3227
28+ // ValidateQueryParamsWithPathItem accepts an *http.Request and validates the query parameters against the OpenAPI specification.
29+ // The method will locate the correct path, and operation, based on the verb. The parameters for the operation
30+ // will be matched and validated against what has been supplied in the http.Request query string.
31+ ValidateQueryParamsWithPathItem (request * http.Request , pathItem * v3.PathItem , pathValue string ) (bool , []* errors.ValidationError )
32+
3333 // ValidateHeaderParams validates the header parameters contained within *http.Request. It returns a boolean
3434 // stating true if validation passed (false for failed), and a slice of errors if validation failed.
3535 ValidateHeaderParams (request * http.Request ) (bool , []* errors.ValidationError )
3636
37+ // ValidateHeaderParamsWithPathItem validates the header parameters contained within *http.Request. It returns a boolean
38+ // stating true if validation passed (false for failed), and a slice of errors if validation failed.
39+ ValidateHeaderParamsWithPathItem (request * http.Request , pathItem * v3.PathItem , pathValue string ) (bool , []* errors.ValidationError )
40+
3741 // ValidateCookieParams validates the cookie parameters contained within *http.Request.
3842 // It returns a boolean stating true if validation passed (false for failed), and a slice of errors if validation failed.
3943 ValidateCookieParams (request * http.Request ) (bool , []* errors.ValidationError )
4044
45+ // ValidateCookieParamsWithPathItem validates the cookie parameters contained within *http.Request.
46+ // It returns a boolean stating true if validation passed (false for failed), and a slice of errors if validation failed.
47+ ValidateCookieParamsWithPathItem (request * http.Request , pathItem * v3.PathItem , pathValue string ) (bool , []* errors.ValidationError )
48+
4149 // ValidatePathParams validates the path parameters contained within *http.Request. It returns a boolean stating true
4250 // if validation passed (false for failed), and a slice of errors if validation failed.
4351 ValidatePathParams (request * http.Request ) (bool , []* errors.ValidationError )
4452
53+ // ValidatePathParamsWithPathItem validates the path parameters contained within *http.Request. It returns a boolean stating true
54+ // if validation passed (false for failed), and a slice of errors if validation failed.
55+ ValidatePathParamsWithPathItem (request * http.Request , pathItem * v3.PathItem , pathValue string ) (bool , []* errors.ValidationError )
56+
4557 // ValidateSecurity validates the security requirements for the operation. It returns a boolean stating true
4658 // if validation passed (false for failed), and a slice of errors if validation failed.
4759 ValidateSecurity (request * http.Request ) (bool , []* errors.ValidationError )
48- }
4960
50- func ( v * paramValidator ) SetPathItem ( path * v3. PathItem , pathValue string ) {
51- v . pathItem = path
52- v . pathValue = pathValue
61+ // ValidateSecurityWithPathItem validates the security requirements for the operation. It returns a boolean stating true
62+ // if validation passed (false for failed), and a slice of errors if validation failed.
63+ ValidateSecurityWithPathItem ( request * http. Request , pathItem * v3. PathItem , pathValue string ) ( bool , [] * errors. ValidationError )
5364}
5465
5566// NewParameterValidator will create a new ParameterValidator from an OpenAPI 3+ document
@@ -58,8 +69,5 @@ func NewParameterValidator(document *v3.Document) ParameterValidator {
5869}
5970
6071type paramValidator struct {
61- document * v3.Document
62- pathItem * v3.PathItem
63- pathValue string
64- errors []* errors.ValidationError
72+ document * v3.Document
6573}
0 commit comments