Documentation ¶
Overview ¶
Package rest provides primitives to interact with the openapi HTTP API.
Code generated by github.com/deepmap/oapi-codegen/v2 version v2.1.0 DO NOT EDIT.
Index ¶
- func GetSwagger() (swagger *openapi3.T, err error)
- func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)
- func RegisterHandlers(router EchoRouter, si ServerInterface)
- func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string)
- type Book
- type BookItem
- type BookList
- type EchoRouter
- type Error
- type GetBooksParams
- type GetBooksSearchParams
- type PostBooksJSONRequestBody
- type Server
- func (s *Server) DeleteBookByID(c echo.Context, id string) error
- func (s *Server) GetBookByID(c echo.Context, id string) error
- func (s *Server) GetBooks(c echo.Context, params GetBooksParams) error
- func (s *Server) GetBooksSearch(c echo.Context, params GetBooksSearchParams) error
- func (s *Server) PostBooks(c echo.Context) error
- func (s *Server) RegisterWith(e *echo.Echo)
- func (s *Server) UpdateBookByID(c echo.Context, id string) error
- type ServerInterface
- type ServerInterfaceWrapper
- func (w *ServerInterfaceWrapper) DeleteBookByID(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) GetBookByID(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) GetBooks(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) GetBooksSearch(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) PostBooks(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) UpdateBookByID(ctx echo.Context) error
- type UpdateBookByIDJSONRequestBody
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSwagger ¶
GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.
func PathToRawSpec ¶
Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
func RegisterHandlers ¶
func RegisterHandlers(router EchoRouter, si ServerInterface)
RegisterHandlers adds each server route to the EchoRouter.
func RegisterHandlersWithBaseURL ¶
func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string)
Registers handlers, and prepends BaseURL to the paths, so that the paths can be served under a prefix.
Types ¶
type Book ¶
type Book struct { // Author Author of the book Author string `json:"author"` // Category Category of the book Category string `json:"category"` // Description Description of the book Description string `json:"description"` // Featured Indicates whether the book is featured or not Featured bool `json:"featured"` // Id Unique identifier for the book Id *string `json:"id,omitempty"` // ImageLink Link to the image of the book cover ImageLink string `json:"image_link"` // Summary Summary of the book Summary string `json:"summary"` // Title Title of the book Title string `json:"title"` }
Book defines model for Book.
type BookItem ¶
type BookItem struct { // Author Author of the book Author string `json:"author"` // Id Unique identifier for the book Id string `json:"id"` // ImageLink Link to the image of the book cover ImageLink string `json:"image_link"` // Summary Summary of the book Summary string `json:"summary"` // Title Title of the book Title string `json:"title"` }
BookItem defines model for BookItem.
type BookList ¶
type BookList struct { Items []BookItem `json:"items"` // Total Total number of results Total int `json:"total"` }
BookList defines model for BookList.
type EchoRouter ¶
type EchoRouter interface { CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route }
This is a simple interface which specifies echo.Route addition functions which are present on both echo.Echo and echo.Group, since we want to allow using either of them for path registration
type Error ¶
type Error struct { // Code Error code Code string `json:"code"` // Msg Description of the error Msg string `json:"msg"` }
Error defines model for Error.
type GetBooksParams ¶
type GetBooksParams struct { // Offset Number of items to skip Offset *int `form:"offset,omitempty" json:"offset,omitempty"` // Limit Maximum number of items to return Limit *int `form:"limit,omitempty" json:"limit,omitempty"` }
GetBooksParams defines parameters for GetBooks.
type GetBooksSearchParams ¶
type GetBooksSearchParams struct { // Q Search query term Q *string `form:"q,omitempty" json:"q,omitempty"` // Offset Number of items to skip Offset *int `form:"offset,omitempty" json:"offset,omitempty"` // Limit Maximum number of items to return Limit *int `form:"limit,omitempty" json:"limit,omitempty"` }
GetBooksSearchParams defines parameters for GetBooksSearch.
type PostBooksJSONRequestBody ¶
type PostBooksJSONRequestBody = Book
PostBooksJSONRequestBody defines body for PostBooks for application/json ContentType.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(repo *core.Repository) *Server
func (*Server) DeleteBookByID ¶
func (*Server) GetBookByID ¶
func (*Server) GetBooks ¶
func (s *Server) GetBooks(c echo.Context, params GetBooksParams) error
func (*Server) GetBooksSearch ¶
func (s *Server) GetBooksSearch(c echo.Context, params GetBooksSearchParams) error
func (*Server) RegisterWith ¶
func (s *Server) RegisterWith(e *echo.Echo)
func (*Server) UpdateBookByID ¶
type ServerInterface ¶
type ServerInterface interface { // Get all books // (GET /books) GetBooks(ctx echo.Context, params GetBooksParams) error // Create a new book // (POST /books) PostBooks(ctx echo.Context) error // Search books by title, author, or other attributes // (GET /books/search) GetBooksSearch(ctx echo.Context, params GetBooksSearchParams) error // Delete a book by ID // (DELETE /books/{id}) DeleteBookByID(ctx echo.Context, id string) error // Get a book by ID // (GET /books/{id}) GetBookByID(ctx echo.Context, id string) error // Update a book by ID // (PUT /books/{id}) UpdateBookByID(ctx echo.Context, id string) error }
ServerInterface represents all server handlers.
type ServerInterfaceWrapper ¶
type ServerInterfaceWrapper struct {
Handler ServerInterface
}
ServerInterfaceWrapper converts echo contexts to parameters.
func (*ServerInterfaceWrapper) DeleteBookByID ¶
func (w *ServerInterfaceWrapper) DeleteBookByID(ctx echo.Context) error
DeleteBookByID converts echo context to params.
func (*ServerInterfaceWrapper) GetBookByID ¶
func (w *ServerInterfaceWrapper) GetBookByID(ctx echo.Context) error
GetBookByID converts echo context to params.
func (*ServerInterfaceWrapper) GetBooks ¶
func (w *ServerInterfaceWrapper) GetBooks(ctx echo.Context) error
GetBooks converts echo context to params.
func (*ServerInterfaceWrapper) GetBooksSearch ¶
func (w *ServerInterfaceWrapper) GetBooksSearch(ctx echo.Context) error
GetBooksSearch converts echo context to params.
func (*ServerInterfaceWrapper) PostBooks ¶
func (w *ServerInterfaceWrapper) PostBooks(ctx echo.Context) error
PostBooks converts echo context to params.
func (*ServerInterfaceWrapper) UpdateBookByID ¶
func (w *ServerInterfaceWrapper) UpdateBookByID(ctx echo.Context) error
UpdateBookByID converts echo context to params.
type UpdateBookByIDJSONRequestBody ¶
type UpdateBookByIDJSONRequestBody = Book
UpdateBookByIDJSONRequestBody defines body for UpdateBookByID for application/json ContentType.