contract

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OpenAPIDoc

type OpenAPIDoc struct {
	OpenAPI string `json:"openapi" yaml:"openapi"`
	Swagger string `json:"swagger" yaml:"swagger"`
	Info    struct {
		Title       string `json:"title" yaml:"title"`
		Version     string `json:"version" yaml:"version"`
		Description string `json:"description" yaml:"description"`
	} `json:"info" yaml:"info"`
	Paths map[string]PathItem `json:"paths" yaml:"paths"`
}

OpenAPIDoc represents a parsed OpenAPI v3 or Swagger v2 document.

type Operation

type Operation struct {
	Summary     string              `json:"summary" yaml:"summary"`
	Description string              `json:"description" yaml:"description"`
	Parameters  []Parameter         `json:"parameters" yaml:"parameters"`
	Responses   map[string]Response `json:"responses" yaml:"responses"`
}

Operation defines an HTTP operation for a path in OpenAPI.

type Parameter

type Parameter struct {
	Name     string `json:"name" yaml:"name"`
	In       string `json:"in" yaml:"in"` // "query", "header", "path"
	Required bool   `json:"required" yaml:"required"`
}

Parameter defines a parameter in an OpenAPI operation.

type PathItem

type PathItem struct {
	Get     *Operation `json:"get" yaml:"get"`
	Post    *Operation `json:"post" yaml:"post"`
	Put     *Operation `json:"put" yaml:"put"`
	Delete  *Operation `json:"delete" yaml:"delete"`
	Patch   *Operation `json:"patch" yaml:"patch"`
	Options *Operation `json:"options" yaml:"options"`
	Head    *Operation `json:"head" yaml:"head"`
}

PathItem defines the operations for an OpenAPI path template.

func (*PathItem) GetOperation

func (p *PathItem) GetOperation(method string) *Operation

type Response

type Response struct {
	Description string `json:"description" yaml:"description"`
}

Response defines an expected HTTP response.

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator validates intercepted HTTP traffic against an OpenAPI / Swagger contract.

func NewValidator

func NewValidator() *Validator

NewValidator initializes a new OpenAPI contract validator.

func (*Validator) ClearSpec

func (v *Validator) ClearSpec()

ClearSpec unloads current spec.

func (*Validator) Evaluate

func (v *Validator) Evaluate(event *ringbuffer.TrafficEvent) []*analysis.Finding

Evaluate implements analysis.Rule for automated contract drift detection.

func (*Validator) GetInfo

func (v *Validator) GetInfo() map[string]interface{}

GetInfo returns metadata about the currently loaded specification.

func (*Validator) IsLoaded

func (v *Validator) IsLoaded() bool

IsLoaded reports whether an active specification is loaded.

func (*Validator) LoadSpec

func (v *Validator) LoadSpec(content []byte) error

LoadSpec parses and compiles an OpenAPI 3.0 or Swagger 2.0 spec (JSON or YAML).

func (*Validator) Name

func (v *Validator) Name() string

Name implements analysis.Rule

Jump to

Keyboard shortcuts

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