Documentation
¶
Overview ¶
Package openapicheck validates live HTTP responses against the canonical OpenAPI contract.
Static contract tests prove the document is internally consistent and that every route is declared. They cannot prove the server actually emits what the document promises: a required property the handler stopped serializing, or a property the handler emits that the document never declared, passes every static check while breaking any strict client. This package closes that gap by validating real responses as the integration suite produces them.
It implements only the JSON Schema vocabulary the canonical contract uses. An unknown keyword is a deliberate failure rather than a silent pass, so the validator cannot rot into a no-op as the contract grows.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document is a loaded OpenAPI contract prepared for response validation.
func (*Document) Handler ¶
Handler wraps inner so that every JSON response it produces is validated against the contract before the test observes it. Streaming upgrades are passed through untouched: a hijacked connection is no longer an HTTP response the contract describes.
func (*Document) ValidateAgainstSchema ¶
ValidateAgainstSchema checks one decoded value against one schema. It exists so the validator's own coverage can be exercised directly.
func (*Document) ValidateResponse ¶
func (document *Document) ValidateResponse( method string, urlPath string, status int, contentType string, body []byte, ) error
ValidateResponse checks one live response against the contract. It reports nil when the contract declares no JSON body for the matched operation.