api

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithServerURL

func WithServerURL(ctx context.Context, u *url.URL) context.Context

WithServerURL sets context key to override server URL.

Types

type Bird

type Bird struct {
	PetType string  `json:"petType"`
	Name    string  `json:"name"`
	Species string  `json:"species"`
	CanTalk OptBool `json:"canTalk"`
}

Ref: #/components/schemas/Bird

func (*Bird) Decode

func (s *Bird) Decode(d *jx.Decoder) error

Decode decodes Bird from json.

func (*Bird) Encode

func (s *Bird) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*Bird) GetCanTalk

func (s *Bird) GetCanTalk() OptBool

GetCanTalk returns the value of CanTalk.

func (*Bird) GetName

func (s *Bird) GetName() string

GetName returns the value of Name.

func (*Bird) GetPetType

func (s *Bird) GetPetType() string

GetPetType returns the value of PetType.

func (*Bird) GetSpecies

func (s *Bird) GetSpecies() string

GetSpecies returns the value of Species.

func (*Bird) MarshalJSON

func (s *Bird) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*Bird) SetCanTalk

func (s *Bird) SetCanTalk(val OptBool)

SetCanTalk sets the value of CanTalk.

func (*Bird) SetName

func (s *Bird) SetName(val string)

SetName sets the value of Name.

func (*Bird) SetPetType

func (s *Bird) SetPetType(val string)

SetPetType sets the value of PetType.

func (*Bird) SetSpecies

func (s *Bird) SetSpecies(val string)

SetSpecies sets the value of Species.

func (*Bird) UnmarshalJSON

func (s *Bird) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type Car

type Car struct {
	VehicleType string `json:"vehicleType"`
	Make        string `json:"make"`
	Model       string `json:"model"`
	Doors       OptInt `json:"doors"`
}

Ref: #/components/schemas/Car

func (*Car) Decode

func (s *Car) Decode(d *jx.Decoder) error

Decode decodes Car from json.

func (*Car) Encode

func (s *Car) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*Car) GetDoors

func (s *Car) GetDoors() OptInt

GetDoors returns the value of Doors.

func (*Car) GetMake

func (s *Car) GetMake() string

GetMake returns the value of Make.

func (*Car) GetModel

func (s *Car) GetModel() string

GetModel returns the value of Model.

func (*Car) GetVehicleType

func (s *Car) GetVehicleType() string

GetVehicleType returns the value of VehicleType.

func (*Car) MarshalJSON

func (s *Car) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*Car) SetDoors

func (s *Car) SetDoors(val OptInt)

SetDoors sets the value of Doors.

func (*Car) SetMake

func (s *Car) SetMake(val string)

SetMake sets the value of Make.

func (*Car) SetModel

func (s *Car) SetModel(val string)

SetModel sets the value of Model.

func (*Car) SetVehicleType

func (s *Car) SetVehicleType(val string)

SetVehicleType sets the value of VehicleType.

func (*Car) UnmarshalJSON

func (s *Car) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*Car) Validate

func (s *Car) Validate() error

type Cat

type Cat struct {
	PetType    string `json:"petType"`
	Name       string `json:"name"`
	Breed      string `json:"breed"`
	MeowVolume OptInt `json:"meowVolume"`
}

Ref: #/components/schemas/Cat

func (*Cat) Decode

func (s *Cat) Decode(d *jx.Decoder) error

Decode decodes Cat from json.

func (*Cat) Encode

func (s *Cat) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*Cat) GetBreed

func (s *Cat) GetBreed() string

GetBreed returns the value of Breed.

func (*Cat) GetMeowVolume

func (s *Cat) GetMeowVolume() OptInt

GetMeowVolume returns the value of MeowVolume.

func (*Cat) GetName

func (s *Cat) GetName() string

GetName returns the value of Name.

func (*Cat) GetPetType

func (s *Cat) GetPetType() string

GetPetType returns the value of PetType.

func (*Cat) MarshalJSON

func (s *Cat) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*Cat) SetBreed

func (s *Cat) SetBreed(val string)

SetBreed sets the value of Breed.

func (*Cat) SetMeowVolume

func (s *Cat) SetMeowVolume(val OptInt)

SetMeowVolume sets the value of MeowVolume.

func (*Cat) SetName

func (s *Cat) SetName(val string)

SetName sets the value of Name.

func (*Cat) SetPetType

func (s *Cat) SetPetType(val string)

SetPetType sets the value of PetType.

func (*Cat) UnmarshalJSON

func (s *Cat) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*Cat) Validate

func (s *Cat) Validate() error

type Client

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

Client implements OAS client.

func NewClient

func NewClient(serverURL string, opts ...ClientOption) (*Client, error)

NewClient initializes new Client defined by OAS.

func (*Client) CreatePet

func (c *Client) CreatePet(ctx context.Context, request Pet) (Pet, error)

CreatePet invokes createPet operation.

Create a pet.

POST /pets

func (*Client) ListNotifications

func (c *Client) ListNotifications(ctx context.Context) ([]Notification, error)

ListNotifications invokes listNotifications operation.

List notifications.

GET /notifications

func (*Client) ListPets

func (c *Client) ListPets(ctx context.Context) ([]Pet, error)

ListPets invokes listPets operation.

List pets.

GET /pets

func (*Client) ListVehicles

func (c *Client) ListVehicles(ctx context.Context) ([]Vehicle, error)

ListVehicles invokes listVehicles operation.

List vehicles.

GET /vehicles

type ClientOption

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

ClientOption is client config option.

func WithClient

func WithClient(client ht.Client) ClientOption

WithClient specifies http client to use.

type Dog

type Dog struct {
	PetType      string `json:"petType"`
	Name         string `json:"name"`
	Breed        string `json:"breed"`
	BarkLoudness OptInt `json:"barkLoudness"`
}

Ref: #/components/schemas/Dog

func (*Dog) Decode

func (s *Dog) Decode(d *jx.Decoder) error

Decode decodes Dog from json.

func (*Dog) Encode

func (s *Dog) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*Dog) GetBarkLoudness

func (s *Dog) GetBarkLoudness() OptInt

GetBarkLoudness returns the value of BarkLoudness.

func (*Dog) GetBreed

func (s *Dog) GetBreed() string

GetBreed returns the value of Breed.

func (*Dog) GetName

func (s *Dog) GetName() string

GetName returns the value of Name.

func (*Dog) GetPetType

func (s *Dog) GetPetType() string

GetPetType returns the value of PetType.

func (*Dog) MarshalJSON

func (s *Dog) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*Dog) SetBarkLoudness

func (s *Dog) SetBarkLoudness(val OptInt)

SetBarkLoudness sets the value of BarkLoudness.

func (*Dog) SetBreed

func (s *Dog) SetBreed(val string)

SetBreed sets the value of Breed.

func (*Dog) SetName

func (s *Dog) SetName(val string)

SetName sets the value of Name.

func (*Dog) SetPetType

func (s *Dog) SetPetType(val string)

SetPetType sets the value of PetType.

func (*Dog) UnmarshalJSON

func (s *Dog) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*Dog) Validate

func (s *Dog) Validate() error

type EmailNotification

type EmailNotification struct {
	NotificationType string    `json:"notificationType"`
	Recipient        string    `json:"recipient"`
	Subject          string    `json:"subject"`
	Body             OptString `json:"body"`
}

Ref: #/components/schemas/EmailNotification

func (*EmailNotification) Decode

func (s *EmailNotification) Decode(d *jx.Decoder) error

Decode decodes EmailNotification from json.

func (*EmailNotification) Encode

func (s *EmailNotification) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*EmailNotification) GetBody

func (s *EmailNotification) GetBody() OptString

GetBody returns the value of Body.

func (*EmailNotification) GetNotificationType

func (s *EmailNotification) GetNotificationType() string

GetNotificationType returns the value of NotificationType.

func (*EmailNotification) GetRecipient

func (s *EmailNotification) GetRecipient() string

GetRecipient returns the value of Recipient.

func (*EmailNotification) GetSubject

func (s *EmailNotification) GetSubject() string

GetSubject returns the value of Subject.

func (*EmailNotification) MarshalJSON

func (s *EmailNotification) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*EmailNotification) SetBody

func (s *EmailNotification) SetBody(val OptString)

SetBody sets the value of Body.

func (*EmailNotification) SetNotificationType

func (s *EmailNotification) SetNotificationType(val string)

SetNotificationType sets the value of NotificationType.

func (*EmailNotification) SetRecipient

func (s *EmailNotification) SetRecipient(val string)

SetRecipient sets the value of Recipient.

func (*EmailNotification) SetSubject

func (s *EmailNotification) SetSubject(val string)

SetSubject sets the value of Subject.

func (*EmailNotification) UnmarshalJSON

func (s *EmailNotification) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*EmailNotification) Validate

func (s *EmailNotification) Validate() error

type ErrorHandler

type ErrorHandler = ogenerrors.ErrorHandler

ErrorHandler is error handler.

type Handler

type Handler interface {
	// CreatePet implements createPet operation.
	//
	// Create a pet.
	//
	// POST /pets
	CreatePet(ctx context.Context, req Pet) (Pet, error)
	// ListNotifications implements listNotifications operation.
	//
	// List notifications.
	//
	// GET /notifications
	ListNotifications(ctx context.Context) ([]Notification, error)
	// ListPets implements listPets operation.
	//
	// List pets.
	//
	// GET /pets
	ListPets(ctx context.Context) ([]Pet, error)
	// ListVehicles implements listVehicles operation.
	//
	// List vehicles.
	//
	// GET /vehicles
	ListVehicles(ctx context.Context) ([]Vehicle, error)
}

Handler handles operations described by OpenAPI v3 specification.

type Invoker

type Invoker interface {
	// CreatePet invokes createPet operation.
	//
	// Create a pet.
	//
	// POST /pets
	CreatePet(ctx context.Context, request Pet) (Pet, error)
	// ListNotifications invokes listNotifications operation.
	//
	// List notifications.
	//
	// GET /notifications
	ListNotifications(ctx context.Context) ([]Notification, error)
	// ListPets invokes listPets operation.
	//
	// List pets.
	//
	// GET /pets
	ListPets(ctx context.Context) ([]Pet, error)
	// ListVehicles invokes listVehicles operation.
	//
	// List vehicles.
	//
	// GET /vehicles
	ListVehicles(ctx context.Context) ([]Vehicle, error)
}

Invoker invokes operations described by OpenAPI v3 specification.

type Labeler

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

Labeler is used to allow adding custom attributes to the server request metrics.

func LabelerFromContext

func LabelerFromContext(ctx context.Context) (*Labeler, bool)

LabelerFromContext retrieves the Labeler from the provided context, if present.

If no Labeler was found in the provided context a new, empty Labeler is returned and the second return value is false. In this case it is safe to use the Labeler but any attributes added to it will not be used.

func (*Labeler) Add

func (l *Labeler) Add(attrs ...attribute.KeyValue)

Add attributes to the Labeler.

func (*Labeler) AttributeSet

func (l *Labeler) AttributeSet() attribute.Set

AttributeSet returns the attributes added to the Labeler as an attribute.Set.

type Middleware

type Middleware = middleware.Middleware

Middleware is middleware type.

type Motorcycle

type Motorcycle struct {
	VehicleType string     `json:"vehicleType"`
	Make        string     `json:"make"`
	Model       string     `json:"model"`
	EngineSize  OptFloat64 `json:"engineSize"`
}

Ref: #/components/schemas/Motorcycle

func (*Motorcycle) Decode

func (s *Motorcycle) Decode(d *jx.Decoder) error

Decode decodes Motorcycle from json.

func (*Motorcycle) Encode

func (s *Motorcycle) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*Motorcycle) GetEngineSize

func (s *Motorcycle) GetEngineSize() OptFloat64

GetEngineSize returns the value of EngineSize.

func (*Motorcycle) GetMake

func (s *Motorcycle) GetMake() string

GetMake returns the value of Make.

func (*Motorcycle) GetModel

func (s *Motorcycle) GetModel() string

GetModel returns the value of Model.

func (*Motorcycle) GetVehicleType

func (s *Motorcycle) GetVehicleType() string

GetVehicleType returns the value of VehicleType.

func (*Motorcycle) MarshalJSON

func (s *Motorcycle) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*Motorcycle) SetEngineSize

func (s *Motorcycle) SetEngineSize(val OptFloat64)

SetEngineSize sets the value of EngineSize.

func (*Motorcycle) SetMake

func (s *Motorcycle) SetMake(val string)

SetMake sets the value of Make.

func (*Motorcycle) SetModel

func (s *Motorcycle) SetModel(val string)

SetModel sets the value of Model.

func (*Motorcycle) SetVehicleType

func (s *Motorcycle) SetVehicleType(val string)

SetVehicleType sets the value of VehicleType.

func (*Motorcycle) UnmarshalJSON

func (s *Motorcycle) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*Motorcycle) Validate

func (s *Motorcycle) Validate() error

type Notification

type Notification struct {
	Type              NotificationType // switch on this field
	EmailNotification EmailNotification
	SMSNotification   SMSNotification
	PushNotification  PushNotification
}

Ref: #/components/schemas/Notification Notification represents sum type.

func NewNotificationEmailNotification

func NewNotificationEmailNotification(v EmailNotification) Notification

NewNotificationEmailNotification returns new Notification from EmailNotification.

func NewNotificationMailNotification

func NewNotificationMailNotification(v EmailNotification) Notification

NewNotificationMailNotification returns new Notification from EmailNotification.

func NewNotificationMobileNotification

func NewNotificationMobileNotification(v PushNotification) Notification

NewNotificationMobileNotification returns new Notification from PushNotification.

func NewNotificationPushNotification

func NewNotificationPushNotification(v PushNotification) Notification

NewNotificationPushNotification returns new Notification from PushNotification.

func NewNotificationSMSNotification

func NewNotificationSMSNotification(v SMSNotification) Notification

NewNotificationSMSNotification returns new Notification from SMSNotification.

func NewNotificationTextNotification

func NewNotificationTextNotification(v SMSNotification) Notification

NewNotificationTextNotification returns new Notification from SMSNotification.

func (*Notification) Decode

func (s *Notification) Decode(d *jx.Decoder) error

Decode decodes Notification from json.

func (Notification) Encode

func (s Notification) Encode(e *jx.Encoder)

Encode encodes Notification as json.

func (Notification) GetEmailNotification

func (s Notification) GetEmailNotification() (v EmailNotification, ok bool)

GetEmailNotification returns EmailNotification and true boolean if Notification is EmailNotification.

func (Notification) GetPushNotification

func (s Notification) GetPushNotification() (v PushNotification, ok bool)

GetPushNotification returns PushNotification and true boolean if Notification is PushNotification.

func (Notification) GetSMSNotification

func (s Notification) GetSMSNotification() (v SMSNotification, ok bool)

GetSMSNotification returns SMSNotification and true boolean if Notification is SMSNotification.

func (Notification) IsEmailNotification

func (s Notification) IsEmailNotification() bool

IsEmailNotification reports whether Notification is EmailNotification.

func (Notification) IsPushNotification

func (s Notification) IsPushNotification() bool

IsPushNotification reports whether Notification is PushNotification.

func (Notification) IsSMSNotification

func (s Notification) IsSMSNotification() bool

IsSMSNotification reports whether Notification is SMSNotification.

func (Notification) MarshalJSON

func (s Notification) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*Notification) SetEmailNotification

func (s *Notification) SetEmailNotification(t NotificationType, v EmailNotification)

SetEmailNotification sets Notification to EmailNotification. panics if `t` is not associated with EmailNotification

func (*Notification) SetPushNotification

func (s *Notification) SetPushNotification(t NotificationType, v PushNotification)

SetPushNotification sets Notification to PushNotification. panics if `t` is not associated with PushNotification

func (*Notification) SetSMSNotification

func (s *Notification) SetSMSNotification(t NotificationType, v SMSNotification)

SetSMSNotification sets Notification to SMSNotification. panics if `t` is not associated with SMSNotification

func (*Notification) UnmarshalJSON

func (s *Notification) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (Notification) Validate

func (s Notification) Validate() error

type NotificationType

type NotificationType string

NotificationType is oneOf type of Notification.

const (
	NotificationEmailNotification  NotificationType = "email"
	NotificationMailNotification   NotificationType = "mail"
	NotificationSMSNotification    NotificationType = "sms"
	NotificationTextNotification   NotificationType = "text"
	NotificationMobileNotification NotificationType = "mobile"
	NotificationPushNotification   NotificationType = "push"
)

Possible values for NotificationType.

type OperationName

type OperationName = string

OperationName is the ogen operation name

const (
	CreatePetOperation         OperationName = "CreatePet"
	ListNotificationsOperation OperationName = "ListNotifications"
	ListPetsOperation          OperationName = "ListPets"
	ListVehiclesOperation      OperationName = "ListVehicles"
)

type OptBool

type OptBool struct {
	Value bool
	Set   bool
}

OptBool is optional bool.

func NewOptBool

func NewOptBool(v bool) OptBool

NewOptBool returns new OptBool with value set to v.

func (*OptBool) Decode

func (o *OptBool) Decode(d *jx.Decoder) error

Decode decodes bool from json.

func (OptBool) Encode

func (o OptBool) Encode(e *jx.Encoder)

Encode encodes bool as json.

func (OptBool) Get

func (o OptBool) Get() (v bool, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptBool) IsSet

func (o OptBool) IsSet() bool

IsSet returns true if OptBool was set.

func (OptBool) MarshalJSON

func (s OptBool) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptBool) Or

func (o OptBool) Or(d bool) bool

Or returns value if set, or given parameter if does not.

func (*OptBool) Reset

func (o *OptBool) Reset()

Reset unsets value.

func (*OptBool) SetTo

func (o *OptBool) SetTo(v bool)

SetTo sets value to v.

func (*OptBool) UnmarshalJSON

func (s *OptBool) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type OptFloat64

type OptFloat64 struct {
	Value float64
	Set   bool
}

OptFloat64 is optional float64.

func NewOptFloat64

func NewOptFloat64(v float64) OptFloat64

NewOptFloat64 returns new OptFloat64 with value set to v.

func (*OptFloat64) Decode

func (o *OptFloat64) Decode(d *jx.Decoder) error

Decode decodes float64 from json.

func (OptFloat64) Encode

func (o OptFloat64) Encode(e *jx.Encoder)

Encode encodes float64 as json.

func (OptFloat64) Get

func (o OptFloat64) Get() (v float64, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptFloat64) IsSet

func (o OptFloat64) IsSet() bool

IsSet returns true if OptFloat64 was set.

func (OptFloat64) MarshalJSON

func (s OptFloat64) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptFloat64) Or

func (o OptFloat64) Or(d float64) float64

Or returns value if set, or given parameter if does not.

func (*OptFloat64) Reset

func (o *OptFloat64) Reset()

Reset unsets value.

func (*OptFloat64) SetTo

func (o *OptFloat64) SetTo(v float64)

SetTo sets value to v.

func (*OptFloat64) UnmarshalJSON

func (s *OptFloat64) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type OptInt

type OptInt struct {
	Value int
	Set   bool
}

OptInt is optional int.

func NewOptInt

func NewOptInt(v int) OptInt

NewOptInt returns new OptInt with value set to v.

func (*OptInt) Decode

func (o *OptInt) Decode(d *jx.Decoder) error

Decode decodes int from json.

func (OptInt) Encode

func (o OptInt) Encode(e *jx.Encoder)

Encode encodes int as json.

func (OptInt) Get

func (o OptInt) Get() (v int, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptInt) IsSet

func (o OptInt) IsSet() bool

IsSet returns true if OptInt was set.

func (OptInt) MarshalJSON

func (s OptInt) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptInt) Or

func (o OptInt) Or(d int) int

Or returns value if set, or given parameter if does not.

func (*OptInt) Reset

func (o *OptInt) Reset()

Reset unsets value.

func (*OptInt) SetTo

func (o *OptInt) SetTo(v int)

SetTo sets value to v.

func (*OptInt) UnmarshalJSON

func (s *OptInt) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type OptString

type OptString struct {
	Value string
	Set   bool
}

OptString is optional string.

func NewOptString

func NewOptString(v string) OptString

NewOptString returns new OptString with value set to v.

func (*OptString) Decode

func (o *OptString) Decode(d *jx.Decoder) error

Decode decodes string from json.

func (OptString) Encode

func (o OptString) Encode(e *jx.Encoder)

Encode encodes string as json.

func (OptString) Get

func (o OptString) Get() (v string, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptString) IsSet

func (o OptString) IsSet() bool

IsSet returns true if OptString was set.

func (OptString) MarshalJSON

func (s OptString) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptString) Or

func (o OptString) Or(d string) string

Or returns value if set, or given parameter if does not.

func (*OptString) Reset

func (o *OptString) Reset()

Reset unsets value.

func (*OptString) SetTo

func (o *OptString) SetTo(v string)

SetTo sets value to v.

func (*OptString) UnmarshalJSON

func (s *OptString) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type Option

type Option interface {
	ServerOption
	ClientOption
}

Option is config option.

func WithAttributes added in v1.15.0

func WithAttributes(attributes ...attribute.KeyValue) Option

WithAttributes specifies default otel attributes.

func WithMeterProvider

func WithMeterProvider(provider metric.MeterProvider) Option

WithMeterProvider specifies a meter provider to use for creating a meter.

If none is specified, the otel.GetMeterProvider() is used.

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) Option

WithTracerProvider specifies a tracer provider to use for creating a tracer.

If none is specified, the global provider is used.

type Pet

type Pet struct {
	Type PetType // switch on this field
	Dog  Dog
	Cat  Cat
	Bird Bird
}

Ref: #/components/schemas/Pet Pet represents sum type.

func NewPetAvianPet

func NewPetAvianPet(v Bird) Pet

NewPetAvianPet returns new Pet from Bird.

func NewPetBirdPet

func NewPetBirdPet(v Bird) Pet

NewPetBirdPet returns new Pet from Bird.

func NewPetCaninePet

func NewPetCaninePet(v Dog) Pet

NewPetCaninePet returns new Pet from Dog.

func NewPetCatPet

func NewPetCatPet(v Cat) Pet

NewPetCatPet returns new Pet from Cat.

func NewPetDogPet

func NewPetDogPet(v Dog) Pet

NewPetDogPet returns new Pet from Dog.

func NewPetFelinePet

func NewPetFelinePet(v Cat) Pet

NewPetFelinePet returns new Pet from Cat.

func (*Pet) Decode

func (s *Pet) Decode(d *jx.Decoder) error

Decode decodes Pet from json.

func (Pet) Encode

func (s Pet) Encode(e *jx.Encoder)

Encode encodes Pet as json.

func (Pet) GetBird

func (s Pet) GetBird() (v Bird, ok bool)

GetBird returns Bird and true boolean if Pet is Bird.

func (Pet) GetCat

func (s Pet) GetCat() (v Cat, ok bool)

GetCat returns Cat and true boolean if Pet is Cat.

func (Pet) GetDog

func (s Pet) GetDog() (v Dog, ok bool)

GetDog returns Dog and true boolean if Pet is Dog.

func (Pet) IsBird

func (s Pet) IsBird() bool

IsBird reports whether Pet is Bird.

func (Pet) IsCat

func (s Pet) IsCat() bool

IsCat reports whether Pet is Cat.

func (Pet) IsDog

func (s Pet) IsDog() bool

IsDog reports whether Pet is Dog.

func (Pet) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*Pet) SetBird

func (s *Pet) SetBird(t PetType, v Bird)

SetBird sets Pet to Bird. panics if `t` is not associated with Bird

func (*Pet) SetCat

func (s *Pet) SetCat(t PetType, v Cat)

SetCat sets Pet to Cat. panics if `t` is not associated with Cat

func (*Pet) SetDog

func (s *Pet) SetDog(t PetType, v Dog)

SetDog sets Pet to Dog. panics if `t` is not associated with Dog

func (*Pet) UnmarshalJSON

func (s *Pet) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (Pet) Validate

func (s Pet) Validate() error

type PetType

type PetType string

PetType is oneOf type of Pet.

const (
	PetCaninePet PetType = "canine"
	PetDogPet    PetType = "dog"
	PetCatPet    PetType = "cat"
	PetFelinePet PetType = "feline"
	PetAvianPet  PetType = "avian"
	PetBirdPet   PetType = "bird"
)

Possible values for PetType.

type PushNotification

type PushNotification struct {
	NotificationType string    `json:"notificationType"`
	DeviceId         string    `json:"deviceId"`
	Title            string    `json:"title"`
	Body             OptString `json:"body"`
	Badge            OptInt    `json:"badge"`
}

Ref: #/components/schemas/PushNotification

func (*PushNotification) Decode

func (s *PushNotification) Decode(d *jx.Decoder) error

Decode decodes PushNotification from json.

func (*PushNotification) Encode

func (s *PushNotification) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*PushNotification) GetBadge

func (s *PushNotification) GetBadge() OptInt

GetBadge returns the value of Badge.

func (*PushNotification) GetBody

func (s *PushNotification) GetBody() OptString

GetBody returns the value of Body.

func (*PushNotification) GetDeviceId

func (s *PushNotification) GetDeviceId() string

GetDeviceId returns the value of DeviceId.

func (*PushNotification) GetNotificationType

func (s *PushNotification) GetNotificationType() string

GetNotificationType returns the value of NotificationType.

func (*PushNotification) GetTitle

func (s *PushNotification) GetTitle() string

GetTitle returns the value of Title.

func (*PushNotification) MarshalJSON

func (s *PushNotification) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*PushNotification) SetBadge

func (s *PushNotification) SetBadge(val OptInt)

SetBadge sets the value of Badge.

func (*PushNotification) SetBody

func (s *PushNotification) SetBody(val OptString)

SetBody sets the value of Body.

func (*PushNotification) SetDeviceId

func (s *PushNotification) SetDeviceId(val string)

SetDeviceId sets the value of DeviceId.

func (*PushNotification) SetNotificationType

func (s *PushNotification) SetNotificationType(val string)

SetNotificationType sets the value of NotificationType.

func (*PushNotification) SetTitle

func (s *PushNotification) SetTitle(val string)

SetTitle sets the value of Title.

func (*PushNotification) UnmarshalJSON

func (s *PushNotification) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*PushNotification) Validate

func (s *PushNotification) Validate() error

type Route

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

Route is route object.

func (Route) Args

func (r Route) Args() []string

Args returns parsed arguments.

func (Route) Name

func (r Route) Name() string

Name returns ogen operation name.

It is guaranteed to be unique and not empty.

func (Route) OperationGroup added in v1.17.0

func (r Route) OperationGroup() string

OperationGroup returns the x-ogen-operation-group value.

func (Route) OperationID

func (r Route) OperationID() string

OperationID returns OpenAPI operationId.

func (Route) PathPattern

func (r Route) PathPattern() string

PathPattern returns OpenAPI path.

func (Route) Summary

func (r Route) Summary() string

Summary returns OpenAPI summary.

type SMSNotification

type SMSNotification struct {
	NotificationType string `json:"notificationType"`
	PhoneNumber      string `json:"phoneNumber"`
	Message          string `json:"message"`
}

Ref: #/components/schemas/SMSNotification

func (*SMSNotification) Decode

func (s *SMSNotification) Decode(d *jx.Decoder) error

Decode decodes SMSNotification from json.

func (*SMSNotification) Encode

func (s *SMSNotification) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*SMSNotification) GetMessage

func (s *SMSNotification) GetMessage() string

GetMessage returns the value of Message.

func (*SMSNotification) GetNotificationType

func (s *SMSNotification) GetNotificationType() string

GetNotificationType returns the value of NotificationType.

func (*SMSNotification) GetPhoneNumber

func (s *SMSNotification) GetPhoneNumber() string

GetPhoneNumber returns the value of PhoneNumber.

func (*SMSNotification) MarshalJSON

func (s *SMSNotification) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*SMSNotification) SetMessage

func (s *SMSNotification) SetMessage(val string)

SetMessage sets the value of Message.

func (*SMSNotification) SetNotificationType

func (s *SMSNotification) SetNotificationType(val string)

SetNotificationType sets the value of NotificationType.

func (*SMSNotification) SetPhoneNumber

func (s *SMSNotification) SetPhoneNumber(val string)

SetPhoneNumber sets the value of PhoneNumber.

func (*SMSNotification) UnmarshalJSON

func (s *SMSNotification) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*SMSNotification) Validate

func (s *SMSNotification) Validate() error

type Server

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

Server implements http server based on OpenAPI v3 specification and calls Handler to handle requests.

func NewServer

func NewServer(h Handler, opts ...ServerOption) (*Server, error)

NewServer creates new Server.

func (*Server) FindPath

func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool)

FindPath finds Route for given method and URL.

func (*Server) FindRoute

func (s *Server) FindRoute(method, path string) (Route, bool)

FindRoute finds Route for given method and path.

Note: this method does not unescape path or handle reserved characters in path properly. Use FindPath instead.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves http request as defined by OpenAPI v3 specification, calling handler that matches the path or returning not found error.

type ServerOption

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

ServerOption is server config option.

func WithErrorHandler

func WithErrorHandler(h ErrorHandler) ServerOption

WithErrorHandler specifies error handler to use.

func WithMaxMultipartMemory

func WithMaxMultipartMemory(max int64) ServerOption

WithMaxMultipartMemory specifies limit of memory for storing file parts. File parts which can't be stored in memory will be stored on disk in temporary files.

func WithMethodNotAllowed

func WithMethodNotAllowed(methodNotAllowed func(w http.ResponseWriter, r *http.Request, allowed string)) ServerOption

WithMethodNotAllowed specifies Method Not Allowed handler to use.

func WithMiddleware

func WithMiddleware(m ...Middleware) ServerOption

WithMiddleware specifies middlewares to use.

func WithNotFound

func WithNotFound(notFound http.HandlerFunc) ServerOption

WithNotFound specifies Not Found handler to use.

func WithPathPrefix

func WithPathPrefix(prefix string) ServerOption

WithPathPrefix specifies server path prefix.

type UnimplementedHandler

type UnimplementedHandler struct{}

UnimplementedHandler is no-op Handler which returns http.ErrNotImplemented.

func (UnimplementedHandler) CreatePet

func (UnimplementedHandler) CreatePet(ctx context.Context, req Pet) (r Pet, _ error)

CreatePet implements createPet operation.

Create a pet.

POST /pets

func (UnimplementedHandler) ListNotifications

func (UnimplementedHandler) ListNotifications(ctx context.Context) (r []Notification, _ error)

ListNotifications implements listNotifications operation.

List notifications.

GET /notifications

func (UnimplementedHandler) ListPets

func (UnimplementedHandler) ListPets(ctx context.Context) (r []Pet, _ error)

ListPets implements listPets operation.

List pets.

GET /pets

func (UnimplementedHandler) ListVehicles

func (UnimplementedHandler) ListVehicles(ctx context.Context) (r []Vehicle, _ error)

ListVehicles implements listVehicles operation.

List vehicles.

GET /vehicles

type Vehicle

type Vehicle struct {
	Type       VehicleType // switch on this field
	Car        Car
	Motorcycle Motorcycle
}

Ref: #/components/schemas/Vehicle Vehicle represents sum type.

func NewCarVehicle

func NewCarVehicle(v Car) Vehicle

NewCarVehicle returns new Vehicle from Car.

func NewMotorcycleVehicle

func NewMotorcycleVehicle(v Motorcycle) Vehicle

NewMotorcycleVehicle returns new Vehicle from Motorcycle.

func (*Vehicle) Decode

func (s *Vehicle) Decode(d *jx.Decoder) error

Decode decodes Vehicle from json.

func (Vehicle) Encode

func (s Vehicle) Encode(e *jx.Encoder)

Encode encodes Vehicle as json.

func (Vehicle) GetCar

func (s Vehicle) GetCar() (v Car, ok bool)

GetCar returns Car and true boolean if Vehicle is Car.

func (Vehicle) GetMotorcycle

func (s Vehicle) GetMotorcycle() (v Motorcycle, ok bool)

GetMotorcycle returns Motorcycle and true boolean if Vehicle is Motorcycle.

func (Vehicle) IsCar

func (s Vehicle) IsCar() bool

IsCar reports whether Vehicle is Car.

func (Vehicle) IsMotorcycle

func (s Vehicle) IsMotorcycle() bool

IsMotorcycle reports whether Vehicle is Motorcycle.

func (Vehicle) MarshalJSON

func (s Vehicle) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*Vehicle) SetCar

func (s *Vehicle) SetCar(v Car)

SetCar sets Vehicle to Car.

func (*Vehicle) SetMotorcycle

func (s *Vehicle) SetMotorcycle(v Motorcycle)

SetMotorcycle sets Vehicle to Motorcycle.

func (*Vehicle) UnmarshalJSON

func (s *Vehicle) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (Vehicle) Validate

func (s Vehicle) Validate() error

type VehicleType

type VehicleType string

VehicleType is oneOf type of Vehicle.

const (
	CarVehicle        VehicleType = "Car"
	MotorcycleVehicle VehicleType = "Motorcycle"
)

Possible values for VehicleType.

Jump to

Keyboard shortcuts

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