generated from PenaSide/GolangTemplate
573 lines
22 KiB
Go
573 lines
22 KiB
Go
![]() |
// Package api 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"
|
|||
|
"time"
|
|||
|
|
|||
|
"github.com/deepmap/oapi-codegen/pkg/runtime"
|
|||
|
"github.com/getkin/kin-openapi/openapi3"
|
|||
|
"github.com/labstack/echo/v4"
|
|||
|
)
|
|||
|
|
|||
|
// Defines values for RecordType.
|
|||
|
const (
|
|||
|
BuyCart RecordType = "buyCart"
|
|||
|
DeclinedPayment RecordType = "declinedPayment"
|
|||
|
SubsriptionEnd RecordType = "subsriptionEnd"
|
|||
|
SuccessfulPayment RecordType = "successfulPayment"
|
|||
|
TimeoutPayment RecordType = "timeoutPayment"
|
|||
|
)
|
|||
|
|
|||
|
// Account defines model for Account.
|
|||
|
type Account struct {
|
|||
|
Id *string `json:"_id,omitempty"`
|
|||
|
Cart *Cart `json:"cart,omitempty"`
|
|||
|
IsDeleted *bool `json:"isDeleted,omitempty"`
|
|||
|
UserId *string `json:"userId,omitempty"`
|
|||
|
Wallet *Wallet `json:"wallet,omitempty"`
|
|||
|
}
|
|||
|
|
|||
|
// Cart defines model for Cart.
|
|||
|
type Cart = []string
|
|||
|
|
|||
|
// Record defines model for Record.
|
|||
|
type Record struct {
|
|||
|
Comment *string `json:"comment,omitempty"`
|
|||
|
CreatedAt *time.Time `json:"createdAt,omitempty"`
|
|||
|
Id *string `json:"id,omitempty"`
|
|||
|
|
|||
|
// Subject я пока не могу предположить, какие будут фильтры по истории, поэтому предлагаю в это поле просто класть строку с json. ибо для каждого типа записи она своя.
|
|||
|
Subject *string `json:"subject,omitempty"`
|
|||
|
Type *RecordType `json:"type,omitempty"`
|
|||
|
UserId *string `json:"userId,omitempty"`
|
|||
|
}
|
|||
|
|
|||
|
// RecordType defines model for Record.Type.
|
|||
|
type RecordType string
|
|||
|
|
|||
|
// Wallet defines model for Wallet.
|
|||
|
type Wallet struct {
|
|||
|
Cash *int64 `json:"cash,omitempty"`
|
|||
|
Currency *string `json:"currency,omitempty"`
|
|||
|
|
|||
|
// Money деньги на счету в копейках. Чтобы при перессчётах не возникало денег изниоткуда. фиксируемся к одной валюте, она будет внутренней, никому её не покажем
|
|||
|
Money *int64 `json:"money,omitempty"`
|
|||
|
}
|
|||
|
|
|||
|
// PaginationAccountsParams defines parameters for PaginationAccounts.
|
|||
|
type PaginationAccountsParams struct {
|
|||
|
// P Номер страницы, начиная с 0
|
|||
|
P *int `form:"p,omitempty" json:"p,omitempty"`
|
|||
|
|
|||
|
// S размер страницы
|
|||
|
S *int `form:"s,omitempty" json:"s,omitempty"`
|
|||
|
}
|
|||
|
|
|||
|
// RemoveFromCartParams defines parameters for RemoveFromCart.
|
|||
|
type RemoveFromCartParams struct {
|
|||
|
Id string `form:"id" json:"id"`
|
|||
|
}
|
|||
|
|
|||
|
// Add2cartJSONBody defines parameters for Add2cart.
|
|||
|
type Add2cartJSONBody struct {
|
|||
|
Id *string `json:"id,omitempty"`
|
|||
|
}
|
|||
|
|
|||
|
// PayCartJSONBody defines parameters for PayCart.
|
|||
|
type PayCartJSONBody struct {
|
|||
|
// Id айдишник для того, чтобы указать сервису оплаты, какой юзер оплатил
|
|||
|
Id *string `json:"id,omitempty"`
|
|||
|
}
|
|||
|
|
|||
|
// UpdateCurrenciesJSONBody defines parameters for UpdateCurrencies.
|
|||
|
type UpdateCurrenciesJSONBody = []string
|
|||
|
|
|||
|
// GetHistoryParams defines parameters for GetHistory.
|
|||
|
type GetHistoryParams struct {
|
|||
|
// P Номер страницы, начиная с 0
|
|||
|
P *int `form:"p,omitempty" json:"p,omitempty"`
|
|||
|
|
|||
|
// S размер страницы
|
|||
|
S *int `form:"s,omitempty" json:"s,omitempty"`
|
|||
|
}
|
|||
|
|
|||
|
// ChangeCurrencyJSONBody defines parameters for ChangeCurrency.
|
|||
|
type ChangeCurrencyJSONBody struct {
|
|||
|
Currency *string `json:"currency,omitempty"`
|
|||
|
}
|
|||
|
|
|||
|
// RequestMoneyJSONBody defines parameters for RequestMoney.
|
|||
|
type RequestMoneyJSONBody struct {
|
|||
|
Cash *int `json:"cash,omitempty"`
|
|||
|
}
|
|||
|
|
|||
|
// PutMoneyJSONBody defines parameters for PutMoney.
|
|||
|
type PutMoneyJSONBody struct {
|
|||
|
Cash *int `json:"cash,omitempty"`
|
|||
|
Currency *string `json:"currency,omitempty"`
|
|||
|
Id *string `json:"id,omitempty"`
|
|||
|
}
|
|||
|
|
|||
|
// Add2cartJSONRequestBody defines body for Add2cart for application/json ContentType.
|
|||
|
type Add2cartJSONRequestBody Add2cartJSONBody
|
|||
|
|
|||
|
// PayCartJSONRequestBody defines body for PayCart for application/json ContentType.
|
|||
|
type PayCartJSONRequestBody PayCartJSONBody
|
|||
|
|
|||
|
// UpdateCurrenciesJSONRequestBody defines body for UpdateCurrencies for application/json ContentType.
|
|||
|
type UpdateCurrenciesJSONRequestBody = UpdateCurrenciesJSONBody
|
|||
|
|
|||
|
// Add2historyJSONRequestBody defines body for Add2history for application/json ContentType.
|
|||
|
type Add2historyJSONRequestBody = Record
|
|||
|
|
|||
|
// ChangeCurrencyJSONRequestBody defines body for ChangeCurrency for application/json ContentType.
|
|||
|
type ChangeCurrencyJSONRequestBody ChangeCurrencyJSONBody
|
|||
|
|
|||
|
// RequestMoneyJSONRequestBody defines body for RequestMoney for application/json ContentType.
|
|||
|
type RequestMoneyJSONRequestBody RequestMoneyJSONBody
|
|||
|
|
|||
|
// PutMoneyJSONRequestBody defines body for PutMoney for application/json ContentType.
|
|||
|
type PutMoneyJSONRequestBody PutMoneyJSONBody
|
|||
|
|
|||
|
// ServerInterface represents all server handlers.
|
|||
|
type ServerInterface interface {
|
|||
|
// удалить собственный аккаунт
|
|||
|
// (DELETE /account)
|
|||
|
DeleteAccount(ctx echo.Context) error
|
|||
|
// Получение текущего аккаунта юзера
|
|||
|
// (GET /account)
|
|||
|
GetAccount(ctx echo.Context) error
|
|||
|
// создать новый аккаунт
|
|||
|
// (POST /account)
|
|||
|
AddAccount(ctx echo.Context) error
|
|||
|
// удалить аккаунт по айди
|
|||
|
// (DELETE /account/{accountId})
|
|||
|
DeleteDirectAccount(ctx echo.Context, accountId string) error
|
|||
|
// получить аккаунт по айди
|
|||
|
// (GET /account/{accountId})
|
|||
|
GetDirectAccount(ctx echo.Context, accountId string) error
|
|||
|
// списко аккаунтов с пагинацией
|
|||
|
// (GET /accounts)
|
|||
|
PaginationAccounts(ctx echo.Context, params PaginationAccountsParams) error
|
|||
|
// удаляем из корзины тариф
|
|||
|
// (DELETE /cart)
|
|||
|
RemoveFromCart(ctx echo.Context, params RemoveFromCartParams) error
|
|||
|
// добавляем в корзину тариф
|
|||
|
// (PUT /cart)
|
|||
|
Add2cart(ctx echo.Context) error
|
|||
|
// оплатить козину
|
|||
|
// (POST /cart/pay)
|
|||
|
PayCart(ctx echo.Context) error
|
|||
|
// получить список одобренных валют
|
|||
|
// (GET /currencies)
|
|||
|
GetCurrencies(ctx echo.Context) error
|
|||
|
// обновляет список одобренных валют
|
|||
|
// (PATCH /currencies)
|
|||
|
UpdateCurrencies(ctx echo.Context) error
|
|||
|
// получение лога событий связанных с аккаунтом
|
|||
|
// (GET /history)
|
|||
|
GetHistory(ctx echo.Context, params GetHistoryParams) error
|
|||
|
// публикация лога в истории
|
|||
|
// (POST /history)
|
|||
|
Add2history(ctx echo.Context) error
|
|||
|
// изменить валюту кошелька
|
|||
|
// (PATCH /wallet)
|
|||
|
ChangeCurrency(ctx echo.Context) error
|
|||
|
// запрос на получение ссылки на оплату
|
|||
|
// (POST /wallet)
|
|||
|
RequestMoney(ctx echo.Context) error
|
|||
|
// зачислить деньги на кошелёк
|
|||
|
// (PUT /wallet)
|
|||
|
PutMoney(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
|
|||
|
|
|||
|
// 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
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.GetAccount(ctx)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// AddAccount converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) AddAccount(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
|
|||
|
// 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 "accountId" -------------
|
|||
|
var accountId string
|
|||
|
|
|||
|
err = runtime.BindStyledParameterWithLocation("simple", false, "accountId", runtime.ParamLocationPath, ctx.Param("accountId"), &accountId)
|
|||
|
if err != nil {
|
|||
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter accountId: %s", err))
|
|||
|
}
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.DeleteDirectAccount(ctx, accountId)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// GetDirectAccount converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) GetDirectAccount(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
// ------------- Path parameter "accountId" -------------
|
|||
|
var accountId string
|
|||
|
|
|||
|
err = runtime.BindStyledParameterWithLocation("simple", false, "accountId", runtime.ParamLocationPath, ctx.Param("accountId"), &accountId)
|
|||
|
if err != nil {
|
|||
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter accountId: %s", err))
|
|||
|
}
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.GetDirectAccount(ctx, accountId)
|
|||
|
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 "p" -------------
|
|||
|
|
|||
|
err = runtime.BindQueryParameter("form", false, false, "p", ctx.QueryParams(), ¶ms.P)
|
|||
|
if err != nil {
|
|||
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter p: %s", err))
|
|||
|
}
|
|||
|
|
|||
|
// ------------- Optional query parameter "s" -------------
|
|||
|
|
|||
|
err = runtime.BindQueryParameter("form", false, false, "s", ctx.QueryParams(), ¶ms.S)
|
|||
|
if err != nil {
|
|||
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter s: %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
|
|||
|
|
|||
|
// 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
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.Add2cart(ctx)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// PayCart converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) PayCart(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
|
|||
|
// 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
|
|||
|
|
|||
|
// 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
|
|||
|
|
|||
|
// Parameter object where we will unmarshal all parameters from the context
|
|||
|
var params GetHistoryParams
|
|||
|
// ------------- Optional query parameter "p" -------------
|
|||
|
|
|||
|
err = runtime.BindQueryParameter("form", false, false, "p", ctx.QueryParams(), ¶ms.P)
|
|||
|
if err != nil {
|
|||
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter p: %s", err))
|
|||
|
}
|
|||
|
|
|||
|
// ------------- Optional query parameter "s" -------------
|
|||
|
|
|||
|
err = runtime.BindQueryParameter("form", false, false, "s", ctx.QueryParams(), ¶ms.S)
|
|||
|
if err != nil {
|
|||
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter s: %s", err))
|
|||
|
}
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.GetHistory(ctx, params)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// Add2history converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) Add2history(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.Add2history(ctx)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// ChangeCurrency converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) ChangeCurrency(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
|
|||
|
// 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
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.RequestMoney(ctx)
|
|||
|
return err
|
|||
|
}
|
|||
|
|
|||
|
// PutMoney converts echo context to params.
|
|||
|
func (w *ServerInterfaceWrapper) PutMoney(ctx echo.Context) error {
|
|||
|
var err error
|
|||
|
|
|||
|
// Invoke the callback with all the unmarshalled arguments
|
|||
|
err = w.Handler.PutMoney(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.POST(baseURL+"/account", wrapper.AddAccount)
|
|||
|
router.DELETE(baseURL+"/account/:accountId", wrapper.DeleteDirectAccount)
|
|||
|
router.GET(baseURL+"/account/:accountId", wrapper.GetDirectAccount)
|
|||
|
router.GET(baseURL+"/accounts", wrapper.PaginationAccounts)
|
|||
|
router.DELETE(baseURL+"/cart", wrapper.RemoveFromCart)
|
|||
|
router.PUT(baseURL+"/cart", wrapper.Add2cart)
|
|||
|
router.POST(baseURL+"/cart/pay", wrapper.PayCart)
|
|||
|
router.GET(baseURL+"/currencies", wrapper.GetCurrencies)
|
|||
|
router.PATCH(baseURL+"/currencies", wrapper.UpdateCurrencies)
|
|||
|
router.GET(baseURL+"/history", wrapper.GetHistory)
|
|||
|
router.POST(baseURL+"/history", wrapper.Add2history)
|
|||
|
router.PATCH(baseURL+"/wallet", wrapper.ChangeCurrency)
|
|||
|
router.POST(baseURL+"/wallet", wrapper.RequestMoney)
|
|||
|
router.PUT(baseURL+"/wallet", wrapper.PutMoney)
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// Base64 encoded, gzipped, json marshaled Swagger object
|
|||
|
var swaggerSpec = []string{
|
|||
|
|
|||
|
"H4sIAAAAAAAC/+xb3W4bx/V/lcH+/xcJSlFk4tax7hy5H7koELgwctEaxZocSpuSu8zuMq0qCBBF105A",
|
|||
|
"2aofwC3Qm96uKK61IrnUK5x5o+Kcmf0eSrIkf6ToTUztzs6cOed3fudjJrtGy+n1HZvbvmds7Bpea5v3",
|
|||
|
"TPp5v9VyBraPP/uu0+eub3F68Uerjf/wv5i9fpcbG8YXjbudZufu3SetzhfNVvvuvXt3Pr/XaDaNmuHv",
|
|||
|
"9HGE57uWvWXs1YyW6dKU/+/yjrFh/N96tv66Wnx9E8fs1QzLe8C73OfF5Tpm1+PpzE8cp8tNG4cPPO5+",
|
|||
|
"dQPR/mx2u/xS4b6Ro/b20hmcJ9/yFgm8qTZn+bznFQT5/UWSXOfVY80G1APTdc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0eE/XGcQzmR0nWsMEtHDJR6sPdP/s",
|
|||
|
"wljKpeWmX3rYmqTxEG4kadWBpBiqPiJVsga6cpWCdHZTIigTVsDklJVOZtrYRlTQyWwxuWw9cTufUB44",
|
|||
|
"lalwmlWn2WmsjgfxkZz0XJ064Zvw02RlmZpPVEUU5eTFqUq3EZjsb2KaP6IbUtnYen7wKyTnmAq9pGYQ",
|
|||
|
"z+hqmkpKVcZOp+WFpK9wWKguW1AhE1PuccZgxrJEPb2kodJtMsRL6qieJcMoKyzf95LcrIoFyZRkmTml",
|
|||
|
"PPvpgVxypUbey4nIrmF29k2biuWNm0pCvblt2ltJQN65tbxaf+9IRuifUPIqhuq4J58+IQBKkJNM21h5",
|
|||
|
"rF71sVgWUQVHuwW+jmRMpUAqy7ALHCVHPYpsVh+8rzHxlBZfZFeuCtRDmL+o+sEhujO3hbweJt3kWLyg",
|
|||
|
"KmkBUZl1ArlkehOKflYK2tySuGJWEcsbYeWauHCBhNgiJpJaFm+SpNSkuTZVcamH0oN+S7fpbs2hqncA",
|
|||
|
"G43G1S6Z7d1q7tO17D8V3Xrb9/vexvr6luNsdXndHVzNyS/yPnkWe5qBK+2HoJP8XNunLtw2y+Mg62jA",
|
|||
|
"nJELRHAMMzEqe08BznHxBlLuQCJBVFTF0wqX0naXJa+XWpHFBVVld6py9DQHmzHEA3VrVBKgaVUnsTJp",
|
|||
|
"NqkXdEkydzNSRwulpsvgA4G59jZxpPZ+et7v/7B7Qi3ZYWb9Qm8wKKU0txWKKp6R5kRp+le6FVySQ+MJ",
|
|||
|
"pGf5UNN0K14qKl5UMKoVZNITFSM4T7LQXIzOpkgxpJkj148i4CefyP9HRDs8v0M1XG1Q80Eu1RdH2QdJ",
|
|||
|
"pr/3eO8/AQAA//8nG+8kJDMAAA==",
|
|||
|
}
|
|||
|
|
|||
|
// 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
|
|||
|
}
|