openapi

package
v0.0.0-...-786563c Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package openapi provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen version v1.8.2 DO NOT EDIT.

Package openapi provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen version v1.8.2 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

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 Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

func NewCreateItemParams

func NewCreateItemParams(r PostItemsRequest) db.CreateItemParams

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

Types

type ChiServerOptions

type ChiServerOptions struct {
	BaseURL     string
	BaseRouter  chi.Router
	Middlewares []MiddlewareFunc
}

type ErrorResponse

type ErrorResponse struct {
	// HTTP status code
	Code int64 `json:"code"`

	// Error message
	Message string `json:"message"`
}

ErrorResponse defines model for errorResponse.

type GetItemResponse

type GetItemResponse Item

商品モデル

type GetItemsParams

type GetItemsParams struct {
	// ページ数
	Limit *Limit `json:"limit,omitempty"`

	// 閲覧ページ
	Page *Page `json:"page,omitempty"`
}

GetItemsParams defines parameters for GetItems.

func (GetItemsParams) ToDbParams

func (p GetItemsParams) ToDbParams() db.ListItemsParams

type GetItemsResponse

type GetItemsResponse struct {
	Items []Item `json:"items"`
}

GetItemsResponse defines model for getItemsResponse.

type Id

type Id uint64

主キー型

type Item

type Item struct {
	// 商品コード
	Code string `json:"code"`

	// 原価
	Cost float32 `json:"cost"`

	// 作成日時
	CreatedAt time.Time `json:"created_at"`

	// 主キー型
	Id Id `json:"id"`

	// 商品名
	Name string `json:"name"`

	// 単位
	Unit string `json:"unit"`

	// 更新日時
	UpdatedAt time.Time `json:"updated_at"`
}

商品モデル

func NewItemFromDbItem

func NewItemFromDbItem(dbitem db.Item) (Item, error)

type ItemId

type ItemId Id

主キー型

type Limit

type Limit int

Limit defines model for limit.

type MiddlewareFunc

type MiddlewareFunc func(http.HandlerFunc) http.HandlerFunc

type Page

type Page int

Page defines model for page.

type PatchItemJSONRequestBody

type PatchItemJSONRequestBody PatchItemRequest

PatchItemJSONRequestBody defines body for PatchItem for application/json ContentType.

type PatchItemRequest

type PatchItemRequest struct {
	// 商品モデル
	Value Item `json:"value"`
}

PatchItemRequest defines model for patchItemRequest.

type PostItemsJSONRequestBody

type PostItemsJSONRequestBody PostItemsRequest

PostItemsJSONRequestBody defines body for PostItems for application/json ContentType.

type PostItemsRequest

type PostItemsRequest struct {
	Value *struct {
		Code string  `json:"code"`
		Cost float32 `json:"cost"`
		Name string  `json:"name"`
		Unit string  `json:"unit"`
	} `json:"value,omitempty"`
}

商品登録時の商品情報

type ServerInterface

type ServerInterface interface {
	// Get item list
	// (GET /items)
	GetItems(w http.ResponseWriter, r *http.Request, params GetItemsParams)
	// Create Item
	// (POST /items)
	PostItems(w http.ResponseWriter, r *http.Request)
	// Delete item
	// (DELETE /items/{item_id})
	DeleteItem(w http.ResponseWriter, r *http.Request, itemId ItemId)
	// Get Item
	// (GET /items/{item_id})
	GetItemById(w http.ResponseWriter, r *http.Request, itemId ItemId)
	// Update item
	// (PATCH /items/{item_id})
	PatchItem(w http.ResponseWriter, r *http.Request, itemId ItemId)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) DeleteItem

func (siw *ServerInterfaceWrapper) DeleteItem(w http.ResponseWriter, r *http.Request)

DeleteItem operation middleware

func (*ServerInterfaceWrapper) GetItemById

func (siw *ServerInterfaceWrapper) GetItemById(w http.ResponseWriter, r *http.Request)

GetItemById operation middleware

func (*ServerInterfaceWrapper) GetItems

func (siw *ServerInterfaceWrapper) GetItems(w http.ResponseWriter, r *http.Request)

GetItems operation middleware

func (*ServerInterfaceWrapper) PatchItem

func (siw *ServerInterfaceWrapper) PatchItem(w http.ResponseWriter, r *http.Request)

PatchItem operation middleware

func (*ServerInterfaceWrapper) PostItems

func (siw *ServerInterfaceWrapper) PostItems(w http.ResponseWriter, r *http.Request)

PostItems operation middleware

Jump to

Keyboard shortcuts

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