contracts

package
v0.0.0-...-46646b9 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateContract

func ValidateContract(contract *ContractTest) error

ValidateContract validates a contract

Types

type ContractRequest

type ContractRequest struct {
	Method  string            `json:"method"`
	Path    string            `json:"path"`
	Headers map[string]string `json:"headers"`
	Query   map[string]string `json:"query"`
	Body    interface{}       `json:"body"`
	Timeout time.Duration     `json:"timeout"`
}

ContractRequest defines the expected request

type ContractResponse

type ContractResponse struct {
	StatusCode int                    `json:"status_code"`
	Headers    map[string]string      `json:"headers"`
	Body       interface{}            `json:"body"`
	Schema     map[string]interface{} `json:"schema"`
}

ContractResponse defines the expected response

type ContractTest

type ContractTest struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Provider    string                 `json:"provider"`
	Consumer    string                 `json:"consumer"`
	Request     *ContractRequest       `json:"request"`
	Response    *ContractResponse      `json:"response"`
	Metadata    map[string]interface{} `json:"metadata"`
}

ContractTest defines a contract test

type ContractVerifier

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

ContractVerifier verifies API contracts

func NewContractVerifier

func NewContractVerifier(baseURL string, logger *slog.Logger) *ContractVerifier

NewContractVerifier creates a new contract verifier

func (*ContractVerifier) VerifyContract

func (cv *ContractVerifier) VerifyContract(ctx context.Context, contract *ContractTest) error

VerifyContract verifies a single contract

Jump to

Keyboard shortcuts

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