generated from PenaSide/GolangTemplate
509 lines
20 KiB
Go
509 lines
20 KiB
Go
![]() |
// Package swagger provides primitives to interact with the openapi HTTP API.
|
|||
|
//
|
|||
|
// Code generated by github.com/deepmap/oapi-codegen version v1.12.4 DO NOT EDIT.
|
|||
|
package swagger
|
|||
|
|
|||
|
import (
|
|||
|
"bytes"
|
|||
|
"compress/gzip"
|
|||
|
"encoding/base64"
|
|||
|
"fmt"
|
|||
|
"net/http"
|
|||
|
"net/url"
|
|||
|
"path"
|
|||
|
"strings"
|
|||
|
|
|||
|
"github.com/deepmap/oapi-codegen/pkg/runtime"
|
|||
|
"github.com/getkin/kin-openapi/openapi3"
|
|||
|
"github.com/labstack/echo/v4"
|
|||
|
)
|
|||
|
|
|||
|
// ServerInterface represents all server handlers.
|
|||
|
type ServerInterface interface {
|
|||
|
// удалить собственный аккаунт
|
|||
|
// (DELETE /account)
|
|||
|
DeleteAccount(ctx echo.Context) error
|
|||
|
// Получение текущего аккаунта юзера
|
|||
|
// (GET /account)
|
|||
|
GetAccount(ctx echo.Context) error
|
|||
|
// Отредактировать аккаунт
|
|||
|
// (PATCH /account)
|
|||
|
ChangeAccount(ctx echo.Context) error
|
|||
|
// Создать новый аккаунт
|
|||
|
// (POST /account)
|
|||
|
AddAccount(ctx echo.Context) error
|
|||
|
// Удалить аккаунт по айди
|
|||
|
// (DELETE /account/{userId})
|
|||
|
DeleteDirectAccount(ctx echo.Context, userId string) error
|
|||
|
// Получить аккаунт по ID пользователя системы единой авторизации
|
|||
|
// (GET /account/{userId})
|
|||
|
GetDirectAccount(ctx echo.Context, userId string) error
|
|||
|
// Выставление статуса верификации
|
|||
|
// (PATCH /account/{userId})
|
|||
|
SetAccountVerificationStatus(ctx echo.Context, userId string) error
|
|||
|
// списко аккаунтов с пагинацией
|
|||
|
// (GET /accounts)
|
|||
|
PaginationAccounts(ctx echo.Context, params PaginationAccountsParams) error
|
|||
|
// Удаляем из корзины тариф
|
|||
|
// (DELETE /cart)
|
|||
|
RemoveFromCart(ctx echo.Context, params RemoveFromCartParams) error
|
|||
|
// Добавляем в корзину тариф
|
|||
|
// (PATCH /cart)
|
|||
|
Add2cart(ctx echo.Context, params Add2cartParams) error
|
|||
|
// оплатить козину
|
|||
|
// (POST /cart/pay)
|
|||
|
PayCart(ctx echo.Context) error
|
|||
|
// получить список одобренных валют
|
|||
|
// (GET /currencies)
|
|||
|
GetCurrencies(ctx echo.Context) error
|
|||
|
// обновляет список одобренных валют
|
|||
|
// (PUT /currencies)
|
|||
|
UpdateCurrencies(ctx echo.Context) error
|
|||
|
// Получение лога событий связанных с аккаунтом
|
|||
|
// (GET /history)
|
|||
|
GetHistory(ctx echo.Context, params GetHistoryParams) error
|
|||
|
// Изменить валюту кошелька
|
|||
|
// (PATCH /wallet)
|
|||
|
ChangeCurrency(ctx echo.Context) error
|
|||
|
// Запрос на получение ссылки на оплату
|
|||
|
// (POST /wallet)
|
|||
|
RequestMoney(ctx echo.Context) error
|
|||
|
}
|
|||
|
|
|||
|
// ServerInterfaceWrapper converts echo contexts to parameters.
|
|||
|
type ServerInterfaceWrapper struct {
|
|||
|
Handler ServerInterface
|
|||
|
}
|
|||
|
|
|||
|
// DeleteAccount converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) DeleteAccount(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
|
|||
|
ctx.Set(BearerScopes, []string{""})
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.DeleteAccount(ctx)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// GetAccount converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) GetAccount(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
|
|||
|
ctx.Set(BearerScopes, []string{""})
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.GetAccount(ctx)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// ChangeAccount converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) ChangeAccount(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
|
|||
|
ctx.Set(BearerScopes, []string{""})
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.ChangeAccount(ctx)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// AddAccount converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) AddAccount(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
|
|||
|
ctx.Set(BearerScopes, []string{""})
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.AddAccount(ctx)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// DeleteDirectAccount converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) DeleteDirectAccount(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
// ------------- Path parameter "userId" -------------
|
|||
|
var userId string
|
|||
|
|
|||
|
err = runtime.BindStyledParameterWithLocation("simple", false, "userId", runtime.ParamLocationPath, ctx.Param("userId"), &userId)
|
|||
|
if err != nil {
|
|||
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter userId: %s", err))
|
|||
|
}
|
|||
|
|
|||
|
ctx.Set(BearerScopes, []string{""})
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.DeleteDirectAccount(ctx, userId)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// GetDirectAccount converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) GetDirectAccount(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
// ------------- Path parameter "userId" -------------
|
|||
|
var userId string
|
|||
|
|
|||
|
err = runtime.BindStyledParameterWithLocation("simple", false, "userId", runtime.ParamLocationPath, ctx.Param("userId"), &userId)
|
|||
|
if err != nil {
|
|||
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter userId: %s", err))
|
|||
|
}
|
|||
|
|
|||
|
ctx.Set(BearerScopes, []string{""})
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.GetDirectAccount(ctx, userId)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// SetAccountVerificationStatus converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) SetAccountVerificationStatus(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
// ------------- Path parameter "userId" -------------
|
|||
|
var userId string
|
|||
|
|
|||
|
err = runtime.BindStyledParameterWithLocation("simple", false, "userId", runtime.ParamLocationPath, ctx.Param("userId"), &userId)
|
|||
|
if err != nil {
|
|||
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter userId: %s", err))
|
|||
|
}
|
|||
|
|
|||
|
ctx.Set(BearerScopes, []string{""})
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.SetAccountVerificationStatus(ctx, userId)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// PaginationAccounts converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) PaginationAccounts(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
|
|||
|
// Parameter object where we will unmarshal all parameters from the context
|
|||
|
var params PaginationAccountsParams
|
|||
|
// ------------- Optional query parameter "page" -------------
|
|||
|
|
|||
|
err = runtime.BindQueryParameter("form", false, false, "page", ctx.QueryParams(), ¶ms.Page)
|
|||
|
if err != nil {
|
|||
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter page: %s", err))
|
|||
|
}
|
|||
|
|
|||
|
// ------------- Optional query parameter "limit" -------------
|
|||
|
|
|||
|
err = runtime.BindQueryParameter("form", false, false, "limit", ctx.QueryParams(), ¶ms.Limit)
|
|||
|
if err != nil {
|
|||
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter limit: %s", err))
|
|||
|
}
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.PaginationAccounts(ctx, params)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// RemoveFromCart converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) RemoveFromCart(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
|
|||
|
ctx.Set(BearerScopes, []string{""})
|
|||
|
|
|||
|
// Parameter object where we will unmarshal all parameters from the context
|
|||
|
var params RemoveFromCartParams
|
|||
|
// ------------- Required query parameter "id" -------------
|
|||
|
|
|||
|
err = runtime.BindQueryParameter("form", true, true, "id", ctx.QueryParams(), ¶ms.Id)
|
|||
|
if err != nil {
|
|||
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
|||
|
}
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.RemoveFromCart(ctx, params)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// Add2cart converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) Add2cart(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
|
|||
|
ctx.Set(BearerScopes, []string{""})
|
|||
|
|
|||
|
// Parameter object where we will unmarshal all parameters from the context
|
|||
|
var params Add2cartParams
|
|||
|
// ------------- Required query parameter "id" -------------
|
|||
|
|
|||
|
err = runtime.BindQueryParameter("form", true, true, "id", ctx.QueryParams(), ¶ms.Id)
|
|||
|
if err != nil {
|
|||
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
|||
|
}
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.Add2cart(ctx, params)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// PayCart converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) PayCart(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
|
|||
|
ctx.Set(BearerScopes, []string{""})
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.PayCart(ctx)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// GetCurrencies converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) GetCurrencies(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.GetCurrencies(ctx)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// UpdateCurrencies converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) UpdateCurrencies(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
|
|||
|
ctx.Set(BearerScopes, []string{""})
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.UpdateCurrencies(ctx)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// GetHistory converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) GetHistory(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
|
|||
|
ctx.Set(BearerScopes, []string{""})
|
|||
|
|
|||
|
// Parameter object where we will unmarshal all parameters from the context
|
|||
|
var params GetHistoryParams
|
|||
|
// ------------- Optional query parameter "page" -------------
|
|||
|
|
|||
|
err = runtime.BindQueryParameter("form", false, false, "page", ctx.QueryParams(), ¶ms.Page)
|
|||
|
if err != nil {
|
|||
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter page: %s", err))
|
|||
|
}
|
|||
|
|
|||
|
// ------------- Optional query parameter "limit" -------------
|
|||
|
|
|||
|
err = runtime.BindQueryParameter("form", false, false, "limit", ctx.QueryParams(), ¶ms.Limit)
|
|||
|
if err != nil {
|
|||
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter limit: %s", err))
|
|||
|
}
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.GetHistory(ctx, params)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// ChangeCurrency converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) ChangeCurrency(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
|
|||
|
ctx.Set(BearerScopes, []string{""})
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.ChangeCurrency(ctx)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// RequestMoney converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) RequestMoney(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
|
|||
|
ctx.Set(BearerScopes, []string{""})
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.RequestMoney(ctx)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// 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 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
|
|||
|
}
|
|||
|
|
|||
|
// RegisterHandlers adds each server route to the EchoRouter.
|
|||
|
func RegisterHandlers(router EchoRouter, si ServerInterface) {
|
|||
|
RegisterHandlersWithBaseURL(router, si, "")
|
|||
|
}
|
|||
|
|
|||
|
// Registers handlers, and prepends BaseURL to the paths, so that the paths
|
|||
|
// can be served under a prefix.
|
|||
|
func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
|
|||
|
|
|||
|
wrapper := ServerInterfaceWrapper{
|
|||
|
Handler: si,
|
|||
|
}
|
|||
|
|
|||
|
router.DELETE(baseURL+"/account", wrapper.DeleteAccount)
|
|||
|
router.GET(baseURL+"/account", wrapper.GetAccount)
|
|||
|
router.PATCH(baseURL+"/account", wrapper.ChangeAccount)
|
|||
|
router.POST(baseURL+"/account", wrapper.AddAccount)
|
|||
|
router.DELETE(baseURL+"/account/:userId", wrapper.DeleteDirectAccount)
|
|||
|
router.GET(baseURL+"/account/:userId", wrapper.GetDirectAccount)
|
|||
|
router.PATCH(baseURL+"/account/:userId", wrapper.SetAccountVerificationStatus)
|
|||
|
router.GET(baseURL+"/accounts", wrapper.PaginationAccounts)
|
|||
|
router.DELETE(baseURL+"/cart", wrapper.RemoveFromCart)
|
|||
|
router.PATCH(baseURL+"/cart", wrapper.Add2cart)
|
|||
|
router.POST(baseURL+"/cart/pay", wrapper.PayCart)
|
|||
|
router.GET(baseURL+"/currencies", wrapper.GetCurrencies)
|
|||
|
router.PUT(baseURL+"/currencies", wrapper.UpdateCurrencies)
|
|||
|
router.GET(baseURL+"/history", wrapper.GetHistory)
|
|||
|
router.PATCH(baseURL+"/wallet", wrapper.ChangeCurrency)
|
|||
|
router.POST(baseURL+"/wallet", wrapper.RequestMoney)
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// Base64 encoded, gzipped, json marshaled Swagger object
|
|||
|
var swaggerSpec = []string{
|
|||
|
|
|||
|
"H4sIAAAAAAAC/+xb/3MTx5L/V6b27oekbrFlY47g38Akd1wVJBUCKQq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Xav/bxNoPvUJVcZdsJ42y9NVnAfcD3YDasuvwK9Ed7HjY2XOF8H+6cR4P6p5z",
|
|||
|
"zaukRy0HQc2fnZz07YBPePVJVcUceY3zIFUl7+1lw4K6Ppm4c6M26/cIE2mrqNjOLf2il1x3qYLLHude",
|
|||
|
"4sFhRfYPpTw9ut6E+jvzWqLIz8krMKlanSx4D0QL9hjhWw82YFe0joCamhKh7iwrhJJeHkh0UEqall/m",
|
|||
|
"KHO2yVLlc1Z0fJcboe4giRbsh8w2fadRvSKyQ807ErVBQv9wCHrGiMcjQho/rhaoGZC4NE7t6GpAmE80",
|
|||
|
"Fhp/DwAA//8+Bz17tEYAAA==",
|
|||
|
}
|
|||
|
|
|||
|
// GetSwagger returns the content of the embedded swagger specification file
|
|||
|
// or error if failed to decode
|
|||
|
func decodeSpec() ([]byte, error) {
|
|||
|
zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
|
|||
|
if err != nil {
|
|||
|
return nil, fmt.Errorf("error base64 decoding spec: %s", err)
|
|||
|
}
|
|||
|
zr, err := gzip.NewReader(bytes.NewReader(zipped))
|
|||
|
if err != nil {
|
|||
|
return nil, fmt.Errorf("error decompressing spec: %s", err)
|
|||
|
}
|
|||
|
var buf bytes.Buffer
|
|||
|
_, err = buf.ReadFrom(zr)
|
|||
|
if err != nil {
|
|||
|
return nil, fmt.Errorf("error decompressing spec: %s", err)
|
|||
|
}
|
|||
|
|
|||
|
return buf.Bytes(), nil
|
|||
|
}
|
|||
|
|
|||
|
var rawSpec = decodeSpecCached()
|
|||
|
|
|||
|
// a naive cached of a decoded swagger spec
|
|||
|
func decodeSpecCached() func() ([]byte, error) {
|
|||
|
data, err := decodeSpec()
|
|||
|
return func() ([]byte, error) {
|
|||
|
return data, err
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
|
|||
|
func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
|
|||
|
var res = make(map[string]func() ([]byte, error))
|
|||
|
if len(pathToFile) > 0 {
|
|||
|
res[pathToFile] = rawSpec
|
|||
|
}
|
|||
|
|
|||
|
return res
|
|||
|
}
|
|||
|
|
|||
|
// 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 GetSwagger() (swagger *openapi3.T, err error) {
|
|||
|
var resolvePath = PathToRawSpec("")
|
|||
|
|
|||
|
loader := openapi3.NewLoader()
|
|||
|
loader.IsExternalRefsAllowed = true
|
|||
|
loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
|
|||
|
var pathToFile = url.String()
|
|||
|
pathToFile = path.Clean(pathToFile)
|
|||
|
getSpec, ok := resolvePath[pathToFile]
|
|||
|
if !ok {
|
|||
|
err1 := fmt.Errorf("path not found: %s", pathToFile)
|
|||
|
return nil, err1
|
|||
|
}
|
|||
|
return getSpec()
|
|||
|
}
|
|||
|
var specData []byte
|
|||
|
specData, err = rawSpec()
|
|||
|
if err != nil {
|
|||
|
return
|
|||
|
}
|
|||
|
swagger, err = loader.LoadFromData(specData)
|
|||
|
if err != nil {
|
|||
|
return
|
|||
|
}
|
|||
|
return
|
|||
|
}
|