test

package
v0.1.32 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const SpecFile string = `` /* 2383-byte string literal not displayed */

Variables

View Source
var LogError = func(err error) {
	log.Println(fmt.Sprintf("Error: %v", err))
}

Functions

func SchemaPath

func SchemaPath(r *http.Request) (string, bool)

func SpecFileHandler

func SpecFileHandler() http.Handler

Types

type API

type API struct {
	GetPetHandler  GetPetHandlerFunc
	GetPet2Handler GetPet2HandlerFunc

	// not found
	NotFoundHandler http.Handler
	// spec file
	SpecFileHandler http.Handler

	Middlewares []func(h http.Handler) http.Handler
}

func (*API) ServeHTTP

func (rt *API) ServeHTTP(rw http.ResponseWriter, r *http.Request)

func (API) TestClient

func (a API) TestClient() *Client

type Cat

type Cat struct {
	Label string
}

func (Cat) MarshalJSON

func (c Cat) MarshalJSON() ([]byte, error)

func (*Cat) UnmarshalJSON

func (c *Cat) UnmarshalJSON(bs []byte) error

type Cat2

type Cat2 struct {
	Name    pkg.Maybe[string]
	PetType string
}

func (Cat2) MarshalJSON

func (c Cat2) MarshalJSON() ([]byte, error)

func (*Cat2) UnmarshalJSON

func (c *Cat2) UnmarshalJSON(bs []byte) error

type Client

type Client struct {
	BaseURL    string
	HTTPClient HTTPClient
}

func NewClient

func NewClient(baseURL string, httpClient HTTPClient) *Client

func (*Client) GetPet

func (c *Client) GetPet(ctx context.Context, request GetPetParams) (GetPetResponse, error)

GetPet GET /pet

func (*Client) GetPet2

func (c *Client) GetPet2(ctx context.Context, request GetPet2Params) (GetPet2Response, error)

GetPet2 GET /pet2

type Dog

type Dog struct {
	Name string
	Tag  pkg.Maybe[string]
}

func (Dog) MarshalJSON

func (c Dog) MarshalJSON() ([]byte, error)

func (*Dog) UnmarshalJSON

func (c *Dog) UnmarshalJSON(bs []byte) error

type Dog2

type Dog2 struct {
	Name    pkg.Maybe[string]
	PetType string
	Tag     pkg.Maybe[string]
}

func (Dog2) MarshalJSON

func (c Dog2) MarshalJSON() ([]byte, error)

func (*Dog2) UnmarshalJSON

func (c *Dog2) UnmarshalJSON(bs []byte) error

type Dog2_Schema

type Dog2_Schema struct {
	Name    pkg.Maybe[string]
	PetType string
	Tag     pkg.Maybe[string]
}

func (Dog2_Schema) MarshalJSON

func (c Dog2_Schema) MarshalJSON() ([]byte, error)

func (*Dog2_Schema) UnmarshalJSON

func (c *Dog2_Schema) UnmarshalJSON(bs []byte) error

type Dog_Schema

type Dog_Schema struct {
	Name string
	Tag  pkg.Maybe[string]
}

func (Dog_Schema) MarshalJSON

func (c Dog_Schema) MarshalJSON() ([]byte, error)

func (*Dog_Schema) UnmarshalJSON

func (c *Dog_Schema) UnmarshalJSON(bs []byte) error

type ErrParseParam

type ErrParseParam struct {
	In        string
	Parameter string
	Reason    string
	Err       error
}

func (ErrParseParam) Error

func (e ErrParseParam) Error() string

func (ErrParseParam) Unwrap

func (e ErrParseParam) Unwrap() error

type GetPet2HandlerFunc

type GetPet2HandlerFunc func(ctx context.Context, r GetPet2Request) GetPet2Response

func (GetPet2HandlerFunc) ServeHTTP

func (f GetPet2HandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request)

type GetPet2Params

type GetPet2Params struct {
	Body Pet2
}

func (GetPet2Params) HTTP

func (r GetPet2Params) HTTP() *http.Request

func (GetPet2Params) Parse

func (r GetPet2Params) Parse() (GetPet2Params, error)

type GetPet2Request

type GetPet2Request interface {
	HTTP() *http.Request
	Parse() (GetPet2Params, error)
}

func GetPet2HTTPRequest

func GetPet2HTTPRequest(r *http.Request) GetPet2Request

type GetPet2Response

type GetPet2Response interface {
	// contains filtered or unexported methods
}

func NewGetPet2Response200JSON

func NewGetPet2Response200JSON(body Resp2) GetPet2Response

type GetPet2Response200JSON

type GetPet2Response200JSON struct {
	Body Resp2
}

GetPet2Response200JSON - OK

func (GetPet2Response200JSON) Write

type GetPetHandlerFunc

type GetPetHandlerFunc func(ctx context.Context, r GetPetRequest) GetPetResponse

func (GetPetHandlerFunc) ServeHTTP

func (f GetPetHandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request)

type GetPetParams

type GetPetParams struct {
	Body Pet
}

func (GetPetParams) HTTP

func (r GetPetParams) HTTP() *http.Request

func (GetPetParams) Parse

func (r GetPetParams) Parse() (GetPetParams, error)

type GetPetRequest

type GetPetRequest interface {
	HTTP() *http.Request
	Parse() (GetPetParams, error)
}

func GetPetHTTPRequest

func GetPetHTTPRequest(r *http.Request) GetPetRequest

type GetPetResponse

type GetPetResponse interface {
	// contains filtered or unexported methods
}

func NewGetPetResponse200JSON

func NewGetPetResponse200JSON(body Resp) GetPetResponse

type GetPetResponse200JSON

type GetPetResponse200JSON struct {
	Body Resp
}

GetPetResponse200JSON - OK

func (GetPetResponse200JSON) Write

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

type HTTPClientFunc

type HTTPClientFunc func(*http.Request) (*http.Response, error)

func (HTTPClientFunc) Do

type Pet

type Pet struct {
	Cat    pkg.Maybe[Cat]
	Dog    pkg.Maybe[pkg.Dog]
	OneOf2 pkg.Maybe[PetOneOf2]
	OneOf3 pkg.Maybe[int64]
	OneOf4 pkg.Maybe[string]
}

func NewPetCat

func NewPetCat(v Cat) Pet

func NewPetDog

func NewPetDog(v pkg.Dog) Pet

func NewPetOneOf2

func NewPetOneOf2(v PetOneOf2) Pet

func NewPetOneOf3

func NewPetOneOf3(v int64) Pet

func NewPetOneOf4

func NewPetOneOf4(v string) Pet

func (Pet) MarshalJSON

func (c Pet) MarshalJSON() ([]byte, error)

func (*Pet) UnmarshalJSON

func (c *Pet) UnmarshalJSON(bs []byte) error

type Pet2

type Pet2 struct {
	Cat2 pkg.Maybe[Cat2]
	Dog2 pkg.Maybe[pkg.Dog2]
}

func NewPet2Cat2

func NewPet2Cat2(v Cat2) Pet2

func NewPet2Dog2

func NewPet2Dog2(v pkg.Dog2) Pet2

func (Pet2) MarshalJSON

func (c Pet2) MarshalJSON() ([]byte, error)

func (*Pet2) UnmarshalJSON

func (c *Pet2) UnmarshalJSON(bs []byte) error

type PetOneOf2

type PetOneOf2 struct {
	ID int64
}

func (PetOneOf2) MarshalJSON

func (c PetOneOf2) MarshalJSON() ([]byte, error)

func (*PetOneOf2) UnmarshalJSON

func (c *PetOneOf2) UnmarshalJSON(bs []byte) error

type Resp

type Resp struct {
	Pet Pet
}

func (Resp) MarshalJSON

func (c Resp) MarshalJSON() ([]byte, error)

func (*Resp) UnmarshalJSON

func (c *Resp) UnmarshalJSON(bs []byte) error

type Resp2

type Resp2 struct {
	Pet Pet2
}

func (Resp2) MarshalJSON

func (c Resp2) MarshalJSON() ([]byte, error)

func (*Resp2) UnmarshalJSON

func (c *Resp2) UnmarshalJSON(bs []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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