schema

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package schema provides a HTTP schema definition.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {
	validation.Validatable `json:"-"`
	Name                   string            `json:"name"`
	Method                 http.Method       `json:"method"`
	Path                   string            `json:"path"`
	Description            string            `json:"description"`
	Documentation          string            `json:"documentation"`
	Deprecated             string            `json:"deprecated"`
	Labels                 types.Map[string] `json:"labels"`
	Headers                http.Headers      `json:"headers"`
	Payload                any               `json:"payload"`
	Expect                 *Expect           `json:"expect"`
}

Endpoint is an HTTP client endpoint.

func NewEndpoint

func NewEndpoint(name string, method http.Method, path string) *Endpoint

func (*Endpoint) Validate

func (e *Endpoint) Validate() error

Validate makes Endpoint validatable by implementing validation.Validatable interface.

type Endpoints

type Endpoints []*Endpoint

Endpoints represents the http client endpoints.

type Expect

type Expect struct {
	Status  http.Status  `json:"status"`
	Headers http.Headers `json:"headers"`
}

Expect is an HTTP response expectation.

func NewExpect

func NewExpect() *Expect

NewExpect creates a new Expect.

func (*Expect) Validate

func (e *Expect) Validate(status http.Status, headers http.Headers) error

Validate validates the given response.

func (*Expect) ValidateHeader

func (e *Expect) ValidateHeader(headers http.Headers) error

ValidateHeader validates the headers of the given response.

func (*Expect) ValidateStatus

func (e *Expect) ValidateStatus(status http.Status) error

ValidateStatus validates the status code of the given response.

Jump to

Keyboard shortcuts

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