1
0
api/ent/ogent/oas_param_dec_gen.go

340 lines
6.2 KiB
Go
Raw Normal View History

2022-08-31 06:18:14 +00:00
// Code generated by ogen, DO NOT EDIT.
package ogent
import (
"bytes"
"context"
"fmt"
"io"
"math"
"math/big"
"math/bits"
"net"
"net/http"
"net/url"
"regexp"
"sort"
"strconv"
"strings"
"sync"
"time"
"github.com/go-faster/errors"
"github.com/go-faster/jx"
"github.com/google/uuid"
"github.com/ogen-go/ogen/conv"
ht "github.com/ogen-go/ogen/http"
"github.com/ogen-go/ogen/json"
"github.com/ogen-go/ogen/otelogen"
"github.com/ogen-go/ogen/uri"
"github.com/ogen-go/ogen/validate"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/trace"
)
// No-op definition for keeping imports.
var (
_ = context.Background()
_ = fmt.Stringer(nil)
_ = strings.Builder{}
_ = errors.Is
_ = sort.Ints
_ = http.MethodGet
_ = io.Copy
_ = json.Marshal
_ = bytes.NewReader
_ = strconv.ParseInt
_ = time.Time{}
_ = conv.ToInt32
_ = uuid.UUID{}
_ = uri.PathEncoder{}
_ = url.URL{}
_ = math.Mod
_ = bits.LeadingZeros64
_ = big.Rat{}
_ = validate.Int{}
_ = ht.NewRequest
_ = net.IP{}
_ = otelogen.Version
_ = attribute.KeyValue{}
_ = trace.TraceIDFromHex
_ = otel.GetTracerProvider
_ = metric.NewNoopMeterProvider
_ = regexp.MustCompile
_ = jx.Null
_ = sync.Pool{}
_ = codes.Unset
)
func decodeDeleteUsersParams(args [1]string, r *http.Request) (DeleteUsersParams, error) {
var (
params DeleteUsersParams
)
// Decode path: id.
{
param := args[0]
if len(param) > 0 {
d := uri.NewPathDecoder(uri.PathDecoderConfig{
Param: "id",
Value: param,
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
s, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToInt(s)
if err != nil {
return err
}
params.ID = c
return nil
}(); err != nil {
return params, err
}
} else {
return params, errors.New("path: id: not specified")
}
}
return params, nil
}
func decodeDrawDoneParams(args [1]string, r *http.Request) (DrawDoneParams, error) {
var (
params DrawDoneParams
)
// Decode path: id.
{
param := args[0]
if len(param) > 0 {
d := uri.NewPathDecoder(uri.PathDecoderConfig{
Param: "id",
Value: param,
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
s, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToInt(s)
if err != nil {
return err
}
params.ID = c
return nil
}(); err != nil {
return params, err
}
} else {
return params, errors.New("path: id: not specified")
}
}
return params, nil
}
func decodeDrawStartParams(args [1]string, r *http.Request) (DrawStartParams, error) {
var (
params DrawStartParams
)
// Decode path: id.
{
param := args[0]
if len(param) > 0 {
d := uri.NewPathDecoder(uri.PathDecoderConfig{
Param: "id",
Value: param,
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
s, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToInt(s)
if err != nil {
return err
}
params.ID = c
return nil
}(); err != nil {
return params, err
}
} else {
return params, errors.New("path: id: not specified")
}
}
return params, nil
}
func decodeListUsersParams(args [0]string, r *http.Request) (ListUsersParams, error) {
var (
params ListUsersParams
queryArgs = r.URL.Query()
)
// Decode query: page.
{
values, ok := queryArgs["page"]
if ok {
d := uri.NewQueryDecoder(uri.QueryDecoderConfig{
Values: values,
Style: uri.QueryStyleForm,
Explode: true,
})
if err := func() error {
var paramsDotPageVal int
if err := func() error {
s, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToInt(s)
if err != nil {
return err
}
paramsDotPageVal = c
return nil
}(); err != nil {
return err
}
params.Page.SetTo(paramsDotPageVal)
return nil
}(); err != nil {
return params, errors.Wrap(err, "query: page: parse")
}
}
}
// Decode query: itemsPerPage.
{
values, ok := queryArgs["itemsPerPage"]
if ok {
d := uri.NewQueryDecoder(uri.QueryDecoderConfig{
Values: values,
Style: uri.QueryStyleForm,
Explode: true,
})
if err := func() error {
var paramsDotItemsPerPageVal int
if err := func() error {
s, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToInt(s)
if err != nil {
return err
}
paramsDotItemsPerPageVal = c
return nil
}(); err != nil {
return err
}
params.ItemsPerPage.SetTo(paramsDotItemsPerPageVal)
return nil
}(); err != nil {
return params, errors.Wrap(err, "query: itemsPerPage: parse")
}
}
}
return params, nil
}
func decodeReadUsersParams(args [1]string, r *http.Request) (ReadUsersParams, error) {
var (
params ReadUsersParams
)
// Decode path: id.
{
param := args[0]
if len(param) > 0 {
d := uri.NewPathDecoder(uri.PathDecoderConfig{
Param: "id",
Value: param,
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
s, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToInt(s)
if err != nil {
return err
}
params.ID = c
return nil
}(); err != nil {
return params, err
}
} else {
return params, errors.New("path: id: not specified")
}
}
return params, nil
}
func decodeUpdateUsersParams(args [1]string, r *http.Request) (UpdateUsersParams, error) {
var (
params UpdateUsersParams
)
// Decode path: id.
{
param := args[0]
if len(param) > 0 {
d := uri.NewPathDecoder(uri.PathDecoderConfig{
Param: "id",
Value: param,
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
s, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToInt(s)
if err != nil {
return err
}
params.ID = c
return nil
}(); err != nil {
return params, err
}
} else {
return params, errors.New("path: id: not specified")
}
}
return params, nil
}