validate

package
v1.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package validate exposes spec validation as a public library API. Validate runs kin-openapi's spec validator and returns a structured list of findings (rule IDs, severities, source locations) so any caller can surface validation results in the same shape as `oasdiff validate` does on the command line.

Index

Constants

View Source
const AmbiguousParameterSerializationID = "ambiguous-parameter-serialization"

AmbiguousParameterSerializationID flags a parameter whose schema type union mixes a structured type (array or object) with a scalar. Style serialization is defined per type and arrays/objects serialize differently from scalars, so for `type: [array, integer]` a server cannot tell whether ?token=5 is the array ["5"] or the integer 5. Valid JSON Schema, under-specified for OpenAPI serialization: an oasdiff-native SHOULD-level lint. See oasdiff/oasdiff#1055.

View Source
const DuplicateEnumValueID = "duplicate-enum-value"

DuplicateEnumValueID flags an enum array that contains the same value more than once. JSON Schema says enum elements SHOULD be unique (a recommendation, not a MUST), so kin-openapi does not reject them; this is an oasdiff-native SHOULD-level lint. See oasdiff/oasdiff#980.

Variables

This section is empty.

Functions

func RuleIDs added in v1.24.0

func RuleIDs() []string

RuleIDs returns every rule ID validate can emit, sorted.

func Validate

func Validate(spec *openapi3.T, source string) formatters.Findings

Validate validates the spec against the OpenAPI and JSON Schema rules (kin-openapi's validator), returning a flat list of findings. Each finding carries a stable rule ID, severity, source location (when origin tracking is enabled on the loader), and a fingerprint for cross-spec matching.

source is the display name for the spec (typically its file path). It appears in each finding's Source.File so callers can render file:line:column anchors. Pass an empty string when there is no meaningful source name (e.g. specs loaded from memory).

A valid spec yields a non-nil empty Findings (nil only for the nil-spec guard), so the formatters' nil guard doesn't collapse `[]` to empty bytes.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL