mirror of
https://github.com/derfenix/webarchive.git
synced 2026-03-11 22:40:58 +03:00
201 lines
3.8 KiB
Go
201 lines
3.8 KiB
Go
// Code generated by ogen, DO NOT EDIT.
|
|
|
|
package openapi
|
|
|
|
import (
|
|
"net/http"
|
|
"net/url"
|
|
|
|
"github.com/go-faster/errors"
|
|
"github.com/google/uuid"
|
|
|
|
"github.com/ogen-go/ogen/conv"
|
|
"github.com/ogen-go/ogen/middleware"
|
|
"github.com/ogen-go/ogen/ogenerrors"
|
|
"github.com/ogen-go/ogen/uri"
|
|
"github.com/ogen-go/ogen/validate"
|
|
)
|
|
|
|
// GetFileParams is parameters of getFile operation.
|
|
type GetFileParams struct {
|
|
ID uuid.UUID
|
|
FileID uuid.UUID
|
|
}
|
|
|
|
func unpackGetFileParams(packed middleware.Parameters) (params GetFileParams) {
|
|
{
|
|
key := middleware.ParameterKey{
|
|
Name: "id",
|
|
In: "path",
|
|
}
|
|
params.ID = packed[key].(uuid.UUID)
|
|
}
|
|
{
|
|
key := middleware.ParameterKey{
|
|
Name: "file_id",
|
|
In: "path",
|
|
}
|
|
params.FileID = packed[key].(uuid.UUID)
|
|
}
|
|
return params
|
|
}
|
|
|
|
func decodeGetFileParams(args [2]string, argsEscaped bool, r *http.Request) (params GetFileParams, _ error) {
|
|
// Decode path: id.
|
|
if err := func() error {
|
|
param := args[0]
|
|
if argsEscaped {
|
|
unescaped, err := url.PathUnescape(args[0])
|
|
if err != nil {
|
|
return errors.Wrap(err, "unescape path")
|
|
}
|
|
param = unescaped
|
|
}
|
|
if len(param) > 0 {
|
|
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
|
Param: "id",
|
|
Value: param,
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
|
|
if err := func() error {
|
|
val, err := d.DecodeValue()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
c, err := conv.ToUUID(val)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
params.ID = c
|
|
return nil
|
|
}(); err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
return validate.ErrFieldRequired
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return params, &ogenerrors.DecodeParamError{
|
|
Name: "id",
|
|
In: "path",
|
|
Err: err,
|
|
}
|
|
}
|
|
// Decode path: file_id.
|
|
if err := func() error {
|
|
param := args[1]
|
|
if argsEscaped {
|
|
unescaped, err := url.PathUnescape(args[1])
|
|
if err != nil {
|
|
return errors.Wrap(err, "unescape path")
|
|
}
|
|
param = unescaped
|
|
}
|
|
if len(param) > 0 {
|
|
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
|
Param: "file_id",
|
|
Value: param,
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
|
|
if err := func() error {
|
|
val, err := d.DecodeValue()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
c, err := conv.ToUUID(val)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
params.FileID = c
|
|
return nil
|
|
}(); err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
return validate.ErrFieldRequired
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return params, &ogenerrors.DecodeParamError{
|
|
Name: "file_id",
|
|
In: "path",
|
|
Err: err,
|
|
}
|
|
}
|
|
return params, nil
|
|
}
|
|
|
|
// GetPageParams is parameters of getPage operation.
|
|
type GetPageParams struct {
|
|
ID uuid.UUID
|
|
}
|
|
|
|
func unpackGetPageParams(packed middleware.Parameters) (params GetPageParams) {
|
|
{
|
|
key := middleware.ParameterKey{
|
|
Name: "id",
|
|
In: "path",
|
|
}
|
|
params.ID = packed[key].(uuid.UUID)
|
|
}
|
|
return params
|
|
}
|
|
|
|
func decodeGetPageParams(args [1]string, argsEscaped bool, r *http.Request) (params GetPageParams, _ error) {
|
|
// Decode path: id.
|
|
if err := func() error {
|
|
param := args[0]
|
|
if argsEscaped {
|
|
unescaped, err := url.PathUnescape(args[0])
|
|
if err != nil {
|
|
return errors.Wrap(err, "unescape path")
|
|
}
|
|
param = unescaped
|
|
}
|
|
if len(param) > 0 {
|
|
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
|
Param: "id",
|
|
Value: param,
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
|
|
if err := func() error {
|
|
val, err := d.DecodeValue()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
c, err := conv.ToUUID(val)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
params.ID = c
|
|
return nil
|
|
}(); err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
return validate.ErrFieldRequired
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return params, &ogenerrors.DecodeParamError{
|
|
Name: "id",
|
|
In: "path",
|
|
Err: err,
|
|
}
|
|
}
|
|
return params, nil
|
|
}
|