Documentation ¶
Index ¶
- Constants
- type Validator
- func (Validator) CaddyModule() caddy.ModuleInfo
- func (v *Validator) Provision(ctx caddy.Context) error
- func (v *Validator) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error
- func (v *Validator) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- func (v *Validator) Validate() error
Constants ¶
View Source
const ( // TKOpenAPIValidator is token for the main directive TKOpenAPIValidator = "openapi_validator" // TKFilepath is token for the subdirective that points to the OpenAPI filepath TKFilepath = "filepath" // TKValidateRoutes is token for the subdirective that sets route validation on or off TKValidateRoutes = "routes" // TKValidateRequests is token for the subdirective that sets requests validation on or off TKValidateRequests = "requests" // TKValidateResponses is token for the subdirective that sets response validation on or off TKValidateResponses = "responses" )
View Source
const ( // ReplacerOpenAPIValidatorErrorMessage is a Caddy Replacer key for storing OpenAPI validation error messages ReplacerOpenAPIValidatorErrorMessage = "openapi_validator.error_message" // ReplacerOpenAPIValidatorStatusCode is a Caddy Replacer key for storing a status code ReplacerOpenAPIValidatorStatusCode = "openapi_validator.status_code" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Validator ¶
type Validator struct { // The filepath to the OpenAPI (v3) specification to use Filepath string `json:"filepath,omitempty"` // Indicates whether routes should be validated // When ValidateRequests or ValidateResponses is true, ValidateRoutes should also be true // Default is true ValidateRoutes *bool `json:"validate_routes,omitempty"` // Indicates whether request validation should be enabled // Default is true ValidateRequests *bool `json:"validate_requests,omitempty"` // Indicates whether request validation should be enabled // Default is true ValidateResponses *bool `json:"validate_responses,omitempty"` // Indicates whether request validation should be enabled // Default is true ValidateServers *bool `json:"validate_servers,omitempty"` // Indicates whether request validation should be enabled // Default is true ValidateSecurity *bool `json:"validate_security,omitempty"` // URL path prefix that is trimmed from the URL path. // It can be of use when server validation is turned off // and the paths in an OpenAPI spec do not match the // implementation directly, i.e. are missing an /api prefix, // for example. // Default is empty string, resulting in no prefix trimming. PathPrefixToBeTrimmed string `json:"path_prefix_to_be_trimmed,omitempty"` // A list of additional servers to be considered valid when // when performing the request validation. The additional servers // are added to the servers in the OpenAPI specification. // Default is empty list AdditionalServers []string `json:"additional_servers,omitempty"` // Indicates whether the OpenAPI specification should be enforced, meaning that invalid // requests and responses will be filtered and an (appropriate) status is returned // Default is true Enforce *bool `json:"enforce,omitempty"` // To log or not to log // Default is true Log *bool `json:"log,omitempty"` // contains filtered or unexported fields }
Validator is used to validate OpenAPI requests and responses against an OpenAPI specification
func (Validator) CaddyModule ¶
func (Validator) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (*Validator) UnmarshalCaddyfile ¶
UnmarshalCaddyfile parses (part of) the Caddyfile and configures a Validator
Click to show internal directories.
Click to hide internal directories.