Documentation
¶
Overview ¶
Package specval validates incoming HTTP requests against a service's embedded OpenAPI spec and writes house RFC 9457 problem+json responses on schema failures, so every service enforces its contract the same way instead of hand-rolling per-handler checks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
Middleware validates requests against opts.Spec and writes a house problem+json response (invalid_param or invalid_body) on schema failures. Routes absent from the spec pass through, so the wrapped handler's own 404/405 handling still applies. Security requirements are accepted unconditionally here (kin-openapi requires an AuthenticationFunc or every secured operation 401s); authentication is jwtauth's job, earlier in the chain.
Types ¶
type Options ¶
type Options struct {
// Spec is the service's embedded OpenAPI document (e.g. the generated api package's
// GetSpec()). Middleware validates from a shallow copy with Servers cleared; Spec itself
// is never mutated.
Spec *openapi3.T
// MaxBodyBytes caps the request body size read during validation, via
// http.MaxBytesReader. A value <= 0 leaves the body size unbounded.
MaxBodyBytes int64
}
Options configures the request-validation middleware for one service.