marshal

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArraySchema

func ArraySchema(items spec.SchemaOrRef, minLength uint32, maxLength uint32, unique bool) spec.Schema

func ArraySchemaFor

func ArraySchemaFor[T ~[]I, I any](m SchemaTypeMapping, minLength uint32, maxLength uint32, unique bool) spec.Schema

func EnumOptionsString

func EnumOptionsString[T any](items []T, format func(item T) string) string

func EnumSchema

func EnumSchema[T comparable](items ...T) spec.Schema

func FloatSchema

func FloatSchema[T float](format spec.Format, min T, max T, multipleOf T) spec.Schema

func IntSchema

func IntSchema[T integer](format spec.Format, min T, max T, multipleOf T) spec.Schema

func MarshalArrayJSON

func MarshalArrayJSON[T ~[]I, I any](items T) ([]byte, error)

func MarshalFloat

func MarshalFloat[T float](value T) ([]byte, error)

func MarshalFloatEnum

func MarshalFloatEnum[T integer](value T) ([]byte, error)

func MarshalInt

func MarshalInt[T integer](value T) ([]byte, error)

func MarshalIntEnum

func MarshalIntEnum[T integer](value T) ([]byte, error)

func MarshalString

func MarshalString[T ~string](value T) ([]byte, error)

func MarshalStringEnum

func MarshalStringEnum[T ~string](value T) ([]byte, error)

func MarshalText

func MarshalText(value any) ([]byte, error)

func MarshalUint

func MarshalUint[T uinteger](value T) ([]byte, error)

func MarshalUintEnum

func MarshalUintEnum[T uinteger](value T) ([]byte, error)

func ReflectRequest

func ReflectRequest(t reflect.Type, param func(fld reflect.StructField, in spec.ParameterIn, name string), body func(fld reflect.StructField))

func StringSchema

func StringSchema(format spec.Format, minLength uint32, maxLength uint32, regex *regexp.Regexp) spec.Schema

func StructSchemaFor

func StructSchemaFor[T any](m SchemaTypeMapping) spec.Schema

func StructSchemaOf

func StructSchemaOf(t reflect.Type, m SchemaTypeMapping) spec.Schema

func UintSchema

func UintSchema[T uinteger](format spec.Format, min T, max T, multipleOf T) spec.Schema

func UnmarshalArrayJSON

func UnmarshalArrayJSON[T ~[]I, I any](dest *T, raw []byte, minLength uint32, maxLength uint32) error

func UnmarshalArrayUniqueJSON

func UnmarshalArrayUniqueJSON[T ~[]I, I comparable](dest *T, raw []byte, minLength uint32, maxLength uint32) error

func UnmarshalFloat

func UnmarshalFloat[T float](dest *T, raw []byte, min T, max T, multipleOf T) error

func UnmarshalFloatEnum

func UnmarshalFloatEnum[T float](dest *T, raw []byte, items ...T) error

func UnmarshalInt

func UnmarshalInt[T integer](dest *T, raw []byte, min T, max T, multipleOf T) error

func UnmarshalIntEnum

func UnmarshalIntEnum[T integer](dest *T, raw []byte, items ...T) error

func UnmarshalRequest

func UnmarshalRequest[T any](dest *T, req *http.Request) error

func UnmarshalString

func UnmarshalString[T ~string](dest *T, raw []byte, minLength uint32, maxLength uint32, regex *regexp.Regexp) error

func UnmarshalStringEnum

func UnmarshalStringEnum[T ~string](dest *T, raw []byte, items ...T) error

func UnmarshalStruct

func UnmarshalStruct[T any](dest *T, raw []byte, extra *map[string]json.RawMessage) error

func UnmarshalText

func UnmarshalText(dest any, text []byte) error

func UnmarshalUint

func UnmarshalUint[T uinteger](dest *T, raw []byte, min T, max T, multipleOf T) error

func UnmarshalUintEnum

func UnmarshalUintEnum[T uinteger](dest *T, raw []byte, items ...T) error

Types

type Bool

type Bool bool

func (Bool) MarshalJSON

func (v Bool) MarshalJSON() ([]byte, error)

func (Bool) MarshalText

func (v Bool) MarshalText() ([]byte, error)

func (Bool) Schema

func (Bool) Schema() spec.Schema

func (*Bool) UnmarshalJSON

func (v *Bool) UnmarshalJSON(raw []byte) error

func (*Bool) UnmarshalText

func (v *Bool) UnmarshalText(raw []byte) error

type Date

type Date time.Time

func ParseDate

func ParseDate(str string) (Date, error)

func (Date) MarshalText

func (v Date) MarshalText() ([]byte, error)

func (Date) Schema

func (Date) Schema() spec.Schema

func (Date) String

func (v Date) String() string

func (*Date) UnmarshalText

func (v *Date) UnmarshalText(raw []byte) error

type DateTime

type DateTime time.Time

func ParseDateTime

func ParseDateTime(str string) (DateTime, error)

func (DateTime) MarshalText

func (v DateTime) MarshalText() ([]byte, error)

func (DateTime) Schema

func (DateTime) Schema() spec.Schema

func (DateTime) String

func (v DateTime) String() string

func (*DateTime) UnmarshalText

func (v *DateTime) UnmarshalText(raw []byte) error

type IPAddr

type IPAddr netip.Addr

func ParseIPAddr

func ParseIPAddr(str string) (IPAddr, error)

func (IPAddr) MarshalText

func (v IPAddr) MarshalText() ([]byte, error)

func (IPAddr) Schema

func (IPAddr) Schema() spec.Schema

func (IPAddr) String

func (v IPAddr) String() string

func (*IPAddr) UnmarshalText

func (v *IPAddr) UnmarshalText(raw []byte) error

type Path

type Path []PathItem

func (Path) String

func (m Path) String() string

type PathError

type PathError struct {
	Path Path
	Err  error
}

func (PathError) Error

func (e PathError) Error() string

type PathErrors

type PathErrors []PathError

func NewPathErrors

func NewPathErrors(item PathItem, err error) PathErrors

func (PathErrors) Error

func (e PathErrors) Error() string

type PathIndex

type PathIndex int

func (PathIndex) String

func (m PathIndex) String() string

type PathItem

type PathItem interface {
	fmt.Stringer
	// contains filtered or unexported methods
}

type PathMember

type PathMember string

func (PathMember) String

func (m PathMember) String() string

type SchemaTypeMapping

type SchemaTypeMapping interface {
	SchemaOrRefOf(t reflect.Type) spec.SchemaOrRef
}

type Time

type Time time.Time

func ParseTime

func ParseTime(str string) (Time, error)

func (Time) MarshalText

func (v Time) MarshalText() ([]byte, error)

func (Time) Schema

func (Time) Schema() spec.Schema

func (Time) String

func (v Time) String() string

func (*Time) UnmarshalText

func (v *Time) UnmarshalText(raw []byte) error

Jump to

Keyboard shortcuts

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