ogent

package
v0.0.0-...-c71f34e Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Code generated by ogen, DO NOT EDIT.

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 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) CreateTodo

func (c *Client) CreateTodo(ctx context.Context, request *CreateTodoReq) (CreateTodoRes, error)

CreateTodo invokes createTodo operation.

Creates a new Todo and persists it to storage.

POST /todos

func (*Client) DeleteTodo

func (c *Client) DeleteTodo(ctx context.Context, params DeleteTodoParams) (DeleteTodoRes, error)

DeleteTodo invokes deleteTodo operation.

Deletes the Todo with the requested ID.

DELETE /todos/{id}

func (*Client) ListTodo

func (c *Client) ListTodo(ctx context.Context, params ListTodoParams) (ListTodoRes, error)

ListTodo invokes listTodo operation.

List Todos.

GET /todos

func (*Client) MarkDone

func (c *Client) MarkDone(ctx context.Context, params MarkDoneParams) error

MarkDone invokes markDone operation.

Marks a todo item as done.

PATCH /todos/{id}/done

func (*Client) ReadTodo

func (c *Client) ReadTodo(ctx context.Context, params ReadTodoParams) (ReadTodoRes, error)

ReadTodo invokes readTodo operation.

Finds the Todo with the requested ID and returns it.

GET /todos/{id}

func (*Client) UpdateTodo

func (c *Client) UpdateTodo(ctx context.Context, request *UpdateTodoReq, params UpdateTodoParams) (UpdateTodoRes, error)

UpdateTodo invokes updateTodo operation.

Updates a Todo and persists changes to storage.

PATCH /todos/{id}

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 CreateTodoReq

type CreateTodoReq struct {
	Title string  `json:"title"`
	Done  OptBool `json:"done"`
}

func (*CreateTodoReq) Decode

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

Decode decodes CreateTodoReq from json.

func (*CreateTodoReq) Encode

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

Encode implements json.Marshaler.

func (*CreateTodoReq) GetDone

func (s *CreateTodoReq) GetDone() OptBool

GetDone returns the value of Done.

func (*CreateTodoReq) GetTitle

func (s *CreateTodoReq) GetTitle() string

GetTitle returns the value of Title.

func (*CreateTodoReq) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*CreateTodoReq) SetDone

func (s *CreateTodoReq) SetDone(val OptBool)

SetDone sets the value of Done.

func (*CreateTodoReq) SetTitle

func (s *CreateTodoReq) SetTitle(val string)

SetTitle sets the value of Title.

func (*CreateTodoReq) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type CreateTodoRes

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

type DeleteTodoNoContent

type DeleteTodoNoContent struct{}

DeleteTodoNoContent is response for DeleteTodo operation.

type DeleteTodoParams

type DeleteTodoParams struct {
	// ID of the Todo.
	ID int
}

DeleteTodoParams is parameters of deleteTodo operation.

type DeleteTodoRes

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

type ErrorHandler

type ErrorHandler = ogenerrors.ErrorHandler

ErrorHandler is error handler.

type Handler

type Handler interface {
	// CreateTodo implements createTodo operation.
	//
	// Creates a new Todo and persists it to storage.
	//
	// POST /todos
	CreateTodo(ctx context.Context, req *CreateTodoReq) (CreateTodoRes, error)
	// DeleteTodo implements deleteTodo operation.
	//
	// Deletes the Todo with the requested ID.
	//
	// DELETE /todos/{id}
	DeleteTodo(ctx context.Context, params DeleteTodoParams) (DeleteTodoRes, error)
	// ListTodo implements listTodo operation.
	//
	// List Todos.
	//
	// GET /todos
	ListTodo(ctx context.Context, params ListTodoParams) (ListTodoRes, error)
	// MarkDone implements markDone operation.
	//
	// Marks a todo item as done.
	//
	// PATCH /todos/{id}/done
	MarkDone(ctx context.Context, params MarkDoneParams) error
	// ReadTodo implements readTodo operation.
	//
	// Finds the Todo with the requested ID and returns it.
	//
	// GET /todos/{id}
	ReadTodo(ctx context.Context, params ReadTodoParams) (ReadTodoRes, error)
	// UpdateTodo implements updateTodo operation.
	//
	// Updates a Todo and persists changes to storage.
	//
	// PATCH /todos/{id}
	UpdateTodo(ctx context.Context, req *UpdateTodoReq, params UpdateTodoParams) (UpdateTodoRes, error)
}

Handler handles operations described by OpenAPI v3 specification.

type ListTodoOKApplicationJSON

type ListTodoOKApplicationJSON []TodoList

func (*ListTodoOKApplicationJSON) Decode

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

Decode decodes ListTodoOKApplicationJSON from json.

func (ListTodoOKApplicationJSON) Encode

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

Encode encodes ListTodoOKApplicationJSON as json.

func (ListTodoOKApplicationJSON) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*ListTodoOKApplicationJSON) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (ListTodoOKApplicationJSON) Validate

func (s ListTodoOKApplicationJSON) Validate() error

type ListTodoParams

type ListTodoParams struct {
	// What page to render.
	Page OptInt
	// Item count to render per page.
	ItemsPerPage OptInt
}

ListTodoParams is parameters of listTodo operation.

type ListTodoRes

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

type MarkDoneNoContent

type MarkDoneNoContent struct{}

MarkDoneNoContent is response for MarkDone operation.

type MarkDoneParams

type MarkDoneParams struct {
	ID int
}

MarkDoneParams is parameters of markDone operation.

type Middleware

type Middleware = middleware.Middleware

Middleware is middleware type.

type OgentHandler

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

OgentHandler implements the ogen generated Handler interface and uses Ent as data layer.

func NewOgentHandler

func NewOgentHandler(c *ent.Client) *OgentHandler

NewOgentHandler returns a new OgentHandler.

func (*OgentHandler) CreateTodo

func (h *OgentHandler) CreateTodo(ctx context.Context, req *CreateTodoReq) (CreateTodoRes, error)

CreateTodo handles POST /todos requests.

func (*OgentHandler) DeleteTodo

func (h *OgentHandler) DeleteTodo(ctx context.Context, params DeleteTodoParams) (DeleteTodoRes, error)

DeleteTodo handles DELETE /todos/{id} requests.

func (*OgentHandler) ListTodo

func (h *OgentHandler) ListTodo(ctx context.Context, params ListTodoParams) (ListTodoRes, error)

ListTodo handles GET /todos requests.

func (*OgentHandler) ReadTodo

func (h *OgentHandler) ReadTodo(ctx context.Context, params ReadTodoParams) (ReadTodoRes, error)

ReadTodo handles GET /todos/{id} requests.

func (*OgentHandler) UpdateTodo

func (h *OgentHandler) UpdateTodo(ctx context.Context, req *UpdateTodoReq, params UpdateTodoParams) (UpdateTodoRes, error)

UpdateTodo handles PATCH /todos/{id} requests.

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 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) 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) 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.

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 WithMeterProvider

func WithMeterProvider(provider metric.MeterProvider) Option

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

If none is specified, the metric.NewNoopMeterProvider 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 R400

type R400 struct {
	Code   int    `json:"code"`
	Status string `json:"status"`
	Errors jx.Raw `json:"errors"`
}

func (*R400) Decode

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

Decode decodes R400 from json.

func (*R400) Encode

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

Encode implements json.Marshaler.

func (*R400) GetCode

func (s *R400) GetCode() int

GetCode returns the value of Code.

func (*R400) GetErrors

func (s *R400) GetErrors() jx.Raw

GetErrors returns the value of Errors.

func (*R400) GetStatus

func (s *R400) GetStatus() string

GetStatus returns the value of Status.

func (*R400) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*R400) SetCode

func (s *R400) SetCode(val int)

SetCode sets the value of Code.

func (*R400) SetErrors

func (s *R400) SetErrors(val jx.Raw)

SetErrors sets the value of Errors.

func (*R400) SetStatus

func (s *R400) SetStatus(val string)

SetStatus sets the value of Status.

func (*R400) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type R404

type R404 struct {
	Code   int    `json:"code"`
	Status string `json:"status"`
	Errors jx.Raw `json:"errors"`
}

func (*R404) Decode

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

Decode decodes R404 from json.

func (*R404) Encode

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

Encode implements json.Marshaler.

func (*R404) GetCode

func (s *R404) GetCode() int

GetCode returns the value of Code.

func (*R404) GetErrors

func (s *R404) GetErrors() jx.Raw

GetErrors returns the value of Errors.

func (*R404) GetStatus

func (s *R404) GetStatus() string

GetStatus returns the value of Status.

func (*R404) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*R404) SetCode

func (s *R404) SetCode(val int)

SetCode sets the value of Code.

func (*R404) SetErrors

func (s *R404) SetErrors(val jx.Raw)

SetErrors sets the value of Errors.

func (*R404) SetStatus

func (s *R404) SetStatus(val string)

SetStatus sets the value of Status.

func (*R404) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type R409

type R409 struct {
	Code   int    `json:"code"`
	Status string `json:"status"`
	Errors jx.Raw `json:"errors"`
}

func (*R409) Decode

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

Decode decodes R409 from json.

func (*R409) Encode

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

Encode implements json.Marshaler.

func (*R409) GetCode

func (s *R409) GetCode() int

GetCode returns the value of Code.

func (*R409) GetErrors

func (s *R409) GetErrors() jx.Raw

GetErrors returns the value of Errors.

func (*R409) GetStatus

func (s *R409) GetStatus() string

GetStatus returns the value of Status.

func (*R409) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*R409) SetCode

func (s *R409) SetCode(val int)

SetCode sets the value of Code.

func (*R409) SetErrors

func (s *R409) SetErrors(val jx.Raw)

SetErrors sets the value of Errors.

func (*R409) SetStatus

func (s *R409) SetStatus(val string)

SetStatus sets the value of Status.

func (*R409) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type R500

type R500 struct {
	Code   int    `json:"code"`
	Status string `json:"status"`
	Errors jx.Raw `json:"errors"`
}

func (*R500) Decode

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

Decode decodes R500 from json.

func (*R500) Encode

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

Encode implements json.Marshaler.

func (*R500) GetCode

func (s *R500) GetCode() int

GetCode returns the value of Code.

func (*R500) GetErrors

func (s *R500) GetErrors() jx.Raw

GetErrors returns the value of Errors.

func (*R500) GetStatus

func (s *R500) GetStatus() string

GetStatus returns the value of Status.

func (*R500) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*R500) SetCode

func (s *R500) SetCode(val int)

SetCode sets the value of Code.

func (*R500) SetErrors

func (s *R500) SetErrors(val jx.Raw)

SetErrors sets the value of Errors.

func (*R500) SetStatus

func (s *R500) SetStatus(val string)

SetStatus sets the value of Status.

func (*R500) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type ReadTodoParams

type ReadTodoParams struct {
	// ID of the Todo.
	ID int
}

ReadTodoParams is parameters of readTodo operation.

type ReadTodoRes

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

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) OperationID

func (r Route) OperationID() string

OperationID returns OpenAPI operationId.

func (Route) PathPattern

func (r Route) PathPattern() string

PathPattern returns OpenAPI path.

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 TodoCreate

type TodoCreate struct {
	ID    int     `json:"id"`
	Title string  `json:"title"`
	Done  OptBool `json:"done"`
}

Ref: #/components/schemas/TodoCreate

func NewTodoCreate

func NewTodoCreate(e *ent.Todo) *TodoCreate

func NewTodoCreates

func NewTodoCreates(es []*ent.Todo) []TodoCreate

func (*TodoCreate) Decode

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

Decode decodes TodoCreate from json.

func (*TodoCreate) Elem

func (t *TodoCreate) Elem() TodoCreate

func (*TodoCreate) Encode

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

Encode implements json.Marshaler.

func (*TodoCreate) GetDone

func (s *TodoCreate) GetDone() OptBool

GetDone returns the value of Done.

func (*TodoCreate) GetID

func (s *TodoCreate) GetID() int

GetID returns the value of ID.

func (*TodoCreate) GetTitle

func (s *TodoCreate) GetTitle() string

GetTitle returns the value of Title.

func (*TodoCreate) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*TodoCreate) SetDone

func (s *TodoCreate) SetDone(val OptBool)

SetDone sets the value of Done.

func (*TodoCreate) SetID

func (s *TodoCreate) SetID(val int)

SetID sets the value of ID.

func (*TodoCreate) SetTitle

func (s *TodoCreate) SetTitle(val string)

SetTitle sets the value of Title.

func (*TodoCreate) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type TodoList

type TodoList struct {
	ID    int     `json:"id"`
	Title string  `json:"title"`
	Done  OptBool `json:"done"`
}

Ref: #/components/schemas/TodoList

func NewTodoList

func NewTodoList(e *ent.Todo) *TodoList

func NewTodoLists

func NewTodoLists(es []*ent.Todo) []TodoList

func (*TodoList) Decode

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

Decode decodes TodoList from json.

func (*TodoList) Elem

func (t *TodoList) Elem() TodoList

func (*TodoList) Encode

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

Encode implements json.Marshaler.

func (*TodoList) GetDone

func (s *TodoList) GetDone() OptBool

GetDone returns the value of Done.

func (*TodoList) GetID

func (s *TodoList) GetID() int

GetID returns the value of ID.

func (*TodoList) GetTitle

func (s *TodoList) GetTitle() string

GetTitle returns the value of Title.

func (*TodoList) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*TodoList) SetDone

func (s *TodoList) SetDone(val OptBool)

SetDone sets the value of Done.

func (*TodoList) SetID

func (s *TodoList) SetID(val int)

SetID sets the value of ID.

func (*TodoList) SetTitle

func (s *TodoList) SetTitle(val string)

SetTitle sets the value of Title.

func (*TodoList) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type TodoRead

type TodoRead struct {
	ID    int     `json:"id"`
	Title string  `json:"title"`
	Done  OptBool `json:"done"`
}

Ref: #/components/schemas/TodoRead

func NewTodoRead

func NewTodoRead(e *ent.Todo) *TodoRead

func NewTodoReads

func NewTodoReads(es []*ent.Todo) []TodoRead

func (*TodoRead) Decode

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

Decode decodes TodoRead from json.

func (*TodoRead) Elem

func (t *TodoRead) Elem() TodoRead

func (*TodoRead) Encode

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

Encode implements json.Marshaler.

func (*TodoRead) GetDone

func (s *TodoRead) GetDone() OptBool

GetDone returns the value of Done.

func (*TodoRead) GetID

func (s *TodoRead) GetID() int

GetID returns the value of ID.

func (*TodoRead) GetTitle

func (s *TodoRead) GetTitle() string

GetTitle returns the value of Title.

func (*TodoRead) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*TodoRead) SetDone

func (s *TodoRead) SetDone(val OptBool)

SetDone sets the value of Done.

func (*TodoRead) SetID

func (s *TodoRead) SetID(val int)

SetID sets the value of ID.

func (*TodoRead) SetTitle

func (s *TodoRead) SetTitle(val string)

SetTitle sets the value of Title.

func (*TodoRead) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type TodoUpdate

type TodoUpdate struct {
	ID    int     `json:"id"`
	Title string  `json:"title"`
	Done  OptBool `json:"done"`
}

Ref: #/components/schemas/TodoUpdate

func NewTodoUpdate

func NewTodoUpdate(e *ent.Todo) *TodoUpdate

func NewTodoUpdates

func NewTodoUpdates(es []*ent.Todo) []TodoUpdate

func (*TodoUpdate) Decode

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

Decode decodes TodoUpdate from json.

func (*TodoUpdate) Elem

func (t *TodoUpdate) Elem() TodoUpdate

func (*TodoUpdate) Encode

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

Encode implements json.Marshaler.

func (*TodoUpdate) GetDone

func (s *TodoUpdate) GetDone() OptBool

GetDone returns the value of Done.

func (*TodoUpdate) GetID

func (s *TodoUpdate) GetID() int

GetID returns the value of ID.

func (*TodoUpdate) GetTitle

func (s *TodoUpdate) GetTitle() string

GetTitle returns the value of Title.

func (*TodoUpdate) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*TodoUpdate) SetDone

func (s *TodoUpdate) SetDone(val OptBool)

SetDone sets the value of Done.

func (*TodoUpdate) SetID

func (s *TodoUpdate) SetID(val int)

SetID sets the value of ID.

func (*TodoUpdate) SetTitle

func (s *TodoUpdate) SetTitle(val string)

SetTitle sets the value of Title.

func (*TodoUpdate) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type UnimplementedHandler

type UnimplementedHandler struct{}

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

func (UnimplementedHandler) CreateTodo

CreateTodo implements createTodo operation.

Creates a new Todo and persists it to storage.

POST /todos

func (UnimplementedHandler) DeleteTodo

DeleteTodo implements deleteTodo operation.

Deletes the Todo with the requested ID.

DELETE /todos/{id}

func (UnimplementedHandler) ListTodo

func (UnimplementedHandler) ListTodo(ctx context.Context, params ListTodoParams) (r ListTodoRes, _ error)

ListTodo implements listTodo operation.

List Todos.

GET /todos

func (UnimplementedHandler) MarkDone

MarkDone implements markDone operation.

Marks a todo item as done.

PATCH /todos/{id}/done

func (UnimplementedHandler) ReadTodo

func (UnimplementedHandler) ReadTodo(ctx context.Context, params ReadTodoParams) (r ReadTodoRes, _ error)

ReadTodo implements readTodo operation.

Finds the Todo with the requested ID and returns it.

GET /todos/{id}

func (UnimplementedHandler) UpdateTodo

UpdateTodo implements updateTodo operation.

Updates a Todo and persists changes to storage.

PATCH /todos/{id}

type UpdateTodoParams

type UpdateTodoParams struct {
	// ID of the Todo.
	ID int
}

UpdateTodoParams is parameters of updateTodo operation.

type UpdateTodoReq

type UpdateTodoReq struct {
	Title OptString `json:"title"`
	Done  OptBool   `json:"done"`
}

func (*UpdateTodoReq) Decode

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

Decode decodes UpdateTodoReq from json.

func (*UpdateTodoReq) Encode

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

Encode implements json.Marshaler.

func (*UpdateTodoReq) GetDone

func (s *UpdateTodoReq) GetDone() OptBool

GetDone returns the value of Done.

func (*UpdateTodoReq) GetTitle

func (s *UpdateTodoReq) GetTitle() OptString

GetTitle returns the value of Title.

func (*UpdateTodoReq) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*UpdateTodoReq) SetDone

func (s *UpdateTodoReq) SetDone(val OptBool)

SetDone sets the value of Done.

func (*UpdateTodoReq) SetTitle

func (s *UpdateTodoReq) SetTitle(val OptString)

SetTitle sets the value of Title.

func (*UpdateTodoReq) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type UpdateTodoRes

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

Jump to

Keyboard shortcuts

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