Documentation
¶
Overview ¶
Package compare implements stage 2 (schema) and stage 3 (example) of the response checks (FR-CMP).
Index ¶
Constants ¶
const Missing = "(missing)"
Missing marks an absent value in a Diff.
Variables ¶
This section is empty.
Functions ¶
func Equal ¶
Equal compares two primitive values; numbers are compared numerically without loss of precision (FR-CMP-06).
func Response ¶
func Response(v *spec.Validator, r *openapi3.Response, header http.Header, body []byte) (errs []spec.SchemaError, decoded any, isJSON bool)
Response checks headers and body of a response against the documented response (stage 2, FR-CMP-01). For JSON bodies it also returns the decoded body, so stage 3 can use it.
Types ¶
type Diff ¶
type Diff struct {
Pointer string
Expected string
Actual string
Note string // optional explanation
}
Diff is one difference between expected and actual value (FR-CMP-08).
type Mode ¶
type Mode string
Mode is the comparison mode (FR-CMP-02).
type Options ¶
type Options struct {
Mode Mode
// Ignore contains field names (matched at every level) and JSON pointers
// (starting with "/"; "*" matches any array index or key).
Ignore []string
// Schema of the actual value. Fields with format uuid, date-time, date or
// readOnly are only checked for presence (FR-CMP-05).
Schema *openapi3.Schema
// Unordered compares all arrays independent of order (FR-CMP-07). Single
// arrays can be marked with x-apitest-compare-unordered in the schema.
Unordered bool
// IgnoreCase compares strings and field names without regard to case:
// "Nord" matches "nord", a field "Name" matches "name". An exact match of
// a field name wins.
IgnoreCase bool
}
Options control Values.