openapi: generate

This commit is contained in:
Quaternions 2024-12-17 21:36:40 -08:00
parent 88dfc92bc6
commit 76d36bea5c
10 changed files with 887 additions and 1293 deletions

View File

@ -119,13 +119,13 @@ type Invoker interface {
// Get list of script policies.
//
// GET /script-policy
ListScriptPolicy(ctx context.Context, request *ListScriptPolicyReq) ([]ScriptPolicy, error)
ListScriptPolicy(ctx context.Context, params ListScriptPolicyParams) ([]ScriptPolicy, error)
// ListSubmissions invokes listSubmissions operation.
//
// Get list of submissions.
//
// GET /submissions
ListSubmissions(ctx context.Context, request *ListSubmissionsReq) ([]Submission, error)
ListSubmissions(ctx context.Context, params ListSubmissionsParams) ([]Submission, error)
// SetSubmissionCompleted invokes setSubmissionCompleted operation.
//
// Retrieve map with ID.
@ -2017,12 +2017,12 @@ func (c *Client) sendGetSubmission(ctx context.Context, params GetSubmissionPara
// Get list of script policies.
//
// GET /script-policy
func (c *Client) ListScriptPolicy(ctx context.Context, request *ListScriptPolicyReq) ([]ScriptPolicy, error) {
res, err := c.sendListScriptPolicy(ctx, request)
func (c *Client) ListScriptPolicy(ctx context.Context, params ListScriptPolicyParams) ([]ScriptPolicy, error) {
res, err := c.sendListScriptPolicy(ctx, params)
return res, err
}
func (c *Client) sendListScriptPolicy(ctx context.Context, request *ListScriptPolicyReq) (res []ScriptPolicy, err error) {
func (c *Client) sendListScriptPolicy(ctx context.Context, params ListScriptPolicyParams) (res []ScriptPolicy, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("listScriptPolicy"),
semconv.HTTPRequestMethodKey.String("GET"),
@ -2062,14 +2062,94 @@ func (c *Client) sendListScriptPolicy(ctx context.Context, request *ListScriptPo
pathParts[0] = "/script-policy"
uri.AddPathParts(u, pathParts[:]...)
stage = "EncodeQueryParams"
q := uri.NewQueryEncoder()
{
// Encode "Page" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "Page",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
return e.EncodeValue(conv.Int32ToString(params.Page))
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "Limit" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "Limit",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
return e.EncodeValue(conv.Int32ToString(params.Limit))
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "FromScriptHash" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "FromScriptHash",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.FromScriptHash.Get(); ok {
return e.EncodeValue(conv.StringToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "ToScriptID" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "ToScriptID",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.ToScriptID.Get(); ok {
return e.EncodeValue(conv.Int64ToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "Policy" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "Policy",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.Policy.Get(); ok {
return e.EncodeValue(conv.Int32ToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
u.RawQuery = q.Values().Encode()
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "GET", u)
if err != nil {
return res, errors.Wrap(err, "create request")
}
if err := encodeListScriptPolicyRequest(request, r); err != nil {
return res, errors.Wrap(err, "encode request")
}
{
type bitset = [1]uint8
@ -2125,12 +2205,12 @@ func (c *Client) sendListScriptPolicy(ctx context.Context, request *ListScriptPo
// Get list of submissions.
//
// GET /submissions
func (c *Client) ListSubmissions(ctx context.Context, request *ListSubmissionsReq) ([]Submission, error) {
res, err := c.sendListSubmissions(ctx, request)
func (c *Client) ListSubmissions(ctx context.Context, params ListSubmissionsParams) ([]Submission, error) {
res, err := c.sendListSubmissions(ctx, params)
return res, err
}
func (c *Client) sendListSubmissions(ctx context.Context, request *ListSubmissionsReq) (res []Submission, err error) {
func (c *Client) sendListSubmissions(ctx context.Context, params ListSubmissionsParams) (res []Submission, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("listSubmissions"),
semconv.HTTPRequestMethodKey.String("GET"),
@ -2170,14 +2250,94 @@ func (c *Client) sendListSubmissions(ctx context.Context, request *ListSubmissio
pathParts[0] = "/submissions"
uri.AddPathParts(u, pathParts[:]...)
stage = "EncodeQueryParams"
q := uri.NewQueryEncoder()
{
// Encode "Page" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "Page",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
return e.EncodeValue(conv.Int32ToString(params.Page))
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "Limit" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "Limit",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
return e.EncodeValue(conv.Int32ToString(params.Limit))
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "DisplayName" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "DisplayName",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.DisplayName.Get(); ok {
return e.EncodeValue(conv.StringToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "Creator" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "Creator",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.Creator.Get(); ok {
return e.EncodeValue(conv.StringToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "GameID" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "GameID",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.GameID.Get(); ok {
return e.EncodeValue(conv.Int32ToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
u.RawQuery = q.Values().Encode()
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "GET", u)
if err != nil {
return res, errors.Wrap(err, "create request")
}
if err := encodeListSubmissionsRequest(request, r); err != nil {
return res, errors.Wrap(err, "encode request")
}
{
type bitset = [1]uint8

View File

@ -3075,21 +3075,16 @@ func (s *Server) handleListScriptPolicyRequest(args [0]string, argsEscaped bool,
return
}
}
request, close, err := s.decodeListScriptPolicyRequest(r)
params, err := decodeListScriptPolicyParams(args, argsEscaped, r)
if err != nil {
err = &ogenerrors.DecodeRequestError{
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
defer recordError("DecodeRequest", err)
defer recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
defer func() {
if err := close(); err != nil {
recordError("CloseRequest", err)
}
}()
var response []ScriptPolicy
if m := s.cfg.Middleware; m != nil {
@ -3098,14 +3093,35 @@ func (s *Server) handleListScriptPolicyRequest(args [0]string, argsEscaped bool,
OperationName: ListScriptPolicyOperation,
OperationSummary: "Get list of script policies",
OperationID: "listScriptPolicy",
Body: request,
Params: middleware.Parameters{},
Raw: r,
Body: nil,
Params: middleware.Parameters{
{
Name: "Page",
In: "query",
}: params.Page,
{
Name: "Limit",
In: "query",
}: params.Limit,
{
Name: "FromScriptHash",
In: "query",
}: params.FromScriptHash,
{
Name: "ToScriptID",
In: "query",
}: params.ToScriptID,
{
Name: "Policy",
In: "query",
}: params.Policy,
},
Raw: r,
}
type (
Request = *ListScriptPolicyReq
Params = struct{}
Request = struct{}
Params = ListScriptPolicyParams
Response = []ScriptPolicy
)
response, err = middleware.HookMiddleware[
@ -3115,14 +3131,14 @@ func (s *Server) handleListScriptPolicyRequest(args [0]string, argsEscaped bool,
](
m,
mreq,
nil,
unpackListScriptPolicyParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.ListScriptPolicy(ctx, request)
response, err = s.h.ListScriptPolicy(ctx, params)
return response, err
},
)
} else {
response, err = s.h.ListScriptPolicy(ctx, request)
response, err = s.h.ListScriptPolicy(ctx, params)
}
if err != nil {
if errRes, ok := errors.Into[*ErrorStatusCode](err); ok {
@ -3270,21 +3286,16 @@ func (s *Server) handleListSubmissionsRequest(args [0]string, argsEscaped bool,
return
}
}
request, close, err := s.decodeListSubmissionsRequest(r)
params, err := decodeListSubmissionsParams(args, argsEscaped, r)
if err != nil {
err = &ogenerrors.DecodeRequestError{
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
defer recordError("DecodeRequest", err)
defer recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
defer func() {
if err := close(); err != nil {
recordError("CloseRequest", err)
}
}()
var response []Submission
if m := s.cfg.Middleware; m != nil {
@ -3293,14 +3304,35 @@ func (s *Server) handleListSubmissionsRequest(args [0]string, argsEscaped bool,
OperationName: ListSubmissionsOperation,
OperationSummary: "Get list of submissions",
OperationID: "listSubmissions",
Body: request,
Params: middleware.Parameters{},
Raw: r,
Body: nil,
Params: middleware.Parameters{
{
Name: "Page",
In: "query",
}: params.Page,
{
Name: "Limit",
In: "query",
}: params.Limit,
{
Name: "DisplayName",
In: "query",
}: params.DisplayName,
{
Name: "Creator",
In: "query",
}: params.Creator,
{
Name: "GameID",
In: "query",
}: params.GameID,
},
Raw: r,
}
type (
Request = *ListSubmissionsReq
Params = struct{}
Request = struct{}
Params = ListSubmissionsParams
Response = []Submission
)
response, err = middleware.HookMiddleware[
@ -3310,14 +3342,14 @@ func (s *Server) handleListSubmissionsRequest(args [0]string, argsEscaped bool,
](
m,
mreq,
nil,
unpackListSubmissionsParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.ListSubmissions(ctx, request)
response, err = s.h.ListSubmissions(ctx, params)
return response, err
},
)
} else {
response, err = s.h.ListSubmissions(ctx, request)
response, err = s.h.ListSubmissions(ctx, params)
}
if err != nil {
if errRes, ok := errors.Into[*ErrorStatusCode](err); ok {

View File

@ -221,228 +221,6 @@ func (s *ID) UnmarshalJSON(data []byte) error {
return s.Decode(d)
}
// Encode implements json.Marshaler.
func (s *ListScriptPolicyReq) Encode(e *jx.Encoder) {
e.ObjStart()
s.encodeFields(e)
e.ObjEnd()
}
// encodeFields encodes fields.
func (s *ListScriptPolicyReq) encodeFields(e *jx.Encoder) {
{
e.FieldStart("Page")
s.Page.Encode(e)
}
{
if s.Filter.Set {
e.FieldStart("Filter")
s.Filter.Encode(e)
}
}
}
var jsonFieldsNameOfListScriptPolicyReq = [2]string{
0: "Page",
1: "Filter",
}
// Decode decodes ListScriptPolicyReq from json.
func (s *ListScriptPolicyReq) Decode(d *jx.Decoder) error {
if s == nil {
return errors.New("invalid: unable to decode ListScriptPolicyReq to nil")
}
var requiredBitSet [1]uint8
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
switch string(k) {
case "Page":
requiredBitSet[0] |= 1 << 0
if err := func() error {
if err := s.Page.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"Page\"")
}
case "Filter":
if err := func() error {
s.Filter.Reset()
if err := s.Filter.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"Filter\"")
}
default:
return d.Skip()
}
return nil
}); err != nil {
return errors.Wrap(err, "decode ListScriptPolicyReq")
}
// Validate required fields.
var failures []validate.FieldError
for i, mask := range [1]uint8{
0b00000001,
} {
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
// Mask only required fields and check equality to mask using XOR.
//
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
// Bits of fields which would be set are actually bits of missed fields.
missed := bits.OnesCount8(result)
for bitN := 0; bitN < missed; bitN++ {
bitIdx := bits.TrailingZeros8(result)
fieldIdx := i*8 + bitIdx
var name string
if fieldIdx < len(jsonFieldsNameOfListScriptPolicyReq) {
name = jsonFieldsNameOfListScriptPolicyReq[fieldIdx]
} else {
name = strconv.Itoa(fieldIdx)
}
failures = append(failures, validate.FieldError{
Name: name,
Error: validate.ErrFieldRequired,
})
// Reset bit.
result &^= 1 << bitIdx
}
}
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
// MarshalJSON implements stdjson.Marshaler.
func (s *ListScriptPolicyReq) MarshalJSON() ([]byte, error) {
e := jx.Encoder{}
s.Encode(&e)
return e.Bytes(), nil
}
// UnmarshalJSON implements stdjson.Unmarshaler.
func (s *ListScriptPolicyReq) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data)
return s.Decode(d)
}
// Encode implements json.Marshaler.
func (s *ListSubmissionsReq) Encode(e *jx.Encoder) {
e.ObjStart()
s.encodeFields(e)
e.ObjEnd()
}
// encodeFields encodes fields.
func (s *ListSubmissionsReq) encodeFields(e *jx.Encoder) {
{
e.FieldStart("Page")
s.Page.Encode(e)
}
{
if s.Filter.Set {
e.FieldStart("Filter")
s.Filter.Encode(e)
}
}
}
var jsonFieldsNameOfListSubmissionsReq = [2]string{
0: "Page",
1: "Filter",
}
// Decode decodes ListSubmissionsReq from json.
func (s *ListSubmissionsReq) Decode(d *jx.Decoder) error {
if s == nil {
return errors.New("invalid: unable to decode ListSubmissionsReq to nil")
}
var requiredBitSet [1]uint8
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
switch string(k) {
case "Page":
requiredBitSet[0] |= 1 << 0
if err := func() error {
if err := s.Page.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"Page\"")
}
case "Filter":
if err := func() error {
s.Filter.Reset()
if err := s.Filter.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"Filter\"")
}
default:
return d.Skip()
}
return nil
}); err != nil {
return errors.Wrap(err, "decode ListSubmissionsReq")
}
// Validate required fields.
var failures []validate.FieldError
for i, mask := range [1]uint8{
0b00000001,
} {
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
// Mask only required fields and check equality to mask using XOR.
//
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
// Bits of fields which would be set are actually bits of missed fields.
missed := bits.OnesCount8(result)
for bitN := 0; bitN < missed; bitN++ {
bitIdx := bits.TrailingZeros8(result)
fieldIdx := i*8 + bitIdx
var name string
if fieldIdx < len(jsonFieldsNameOfListSubmissionsReq) {
name = jsonFieldsNameOfListSubmissionsReq[fieldIdx]
} else {
name = strconv.Itoa(fieldIdx)
}
failures = append(failures, validate.FieldError{
Name: name,
Error: validate.ErrFieldRequired,
})
// Reset bit.
result &^= 1 << bitIdx
}
}
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
// MarshalJSON implements stdjson.Marshaler.
func (s *ListSubmissionsReq) MarshalJSON() ([]byte, error) {
e := jx.Encoder{}
s.Encode(&e)
return e.Bytes(), nil
}
// UnmarshalJSON implements stdjson.Unmarshaler.
func (s *ListSubmissionsReq) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data)
return s.Decode(d)
}
// Encode encodes int32 as json.
func (o OptInt32) Encode(e *jx.Encoder) {
if !o.Set {
@ -513,39 +291,6 @@ func (s *OptInt64) UnmarshalJSON(data []byte) error {
return s.Decode(d)
}
// Encode encodes ScriptPolicyFilter as json.
func (o OptScriptPolicyFilter) Encode(e *jx.Encoder) {
if !o.Set {
return
}
o.Value.Encode(e)
}
// Decode decodes ScriptPolicyFilter from json.
func (o *OptScriptPolicyFilter) Decode(d *jx.Decoder) error {
if o == nil {
return errors.New("invalid: unable to decode OptScriptPolicyFilter to nil")
}
o.Set = true
if err := o.Value.Decode(d); err != nil {
return err
}
return nil
}
// MarshalJSON implements stdjson.Marshaler.
func (s OptScriptPolicyFilter) MarshalJSON() ([]byte, error) {
e := jx.Encoder{}
s.Encode(&e)
return e.Bytes(), nil
}
// UnmarshalJSON implements stdjson.Unmarshaler.
func (s *OptScriptPolicyFilter) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data)
return s.Decode(d)
}
// Encode encodes string as json.
func (o OptString) Encode(e *jx.Encoder) {
if !o.Set {
@ -581,152 +326,6 @@ func (s *OptString) UnmarshalJSON(data []byte) error {
return s.Decode(d)
}
// Encode encodes SubmissionFilter as json.
func (o OptSubmissionFilter) Encode(e *jx.Encoder) {
if !o.Set {
return
}
o.Value.Encode(e)
}
// Decode decodes SubmissionFilter from json.
func (o *OptSubmissionFilter) Decode(d *jx.Decoder) error {
if o == nil {
return errors.New("invalid: unable to decode OptSubmissionFilter to nil")
}
o.Set = true
if err := o.Value.Decode(d); err != nil {
return err
}
return nil
}
// MarshalJSON implements stdjson.Marshaler.
func (s OptSubmissionFilter) MarshalJSON() ([]byte, error) {
e := jx.Encoder{}
s.Encode(&e)
return e.Bytes(), nil
}
// UnmarshalJSON implements stdjson.Unmarshaler.
func (s *OptSubmissionFilter) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data)
return s.Decode(d)
}
// Encode implements json.Marshaler.
func (s *Pagination) Encode(e *jx.Encoder) {
e.ObjStart()
s.encodeFields(e)
e.ObjEnd()
}
// encodeFields encodes fields.
func (s *Pagination) encodeFields(e *jx.Encoder) {
{
e.FieldStart("Number")
e.Int32(s.Number)
}
{
e.FieldStart("Size")
e.Int32(s.Size)
}
}
var jsonFieldsNameOfPagination = [2]string{
0: "Number",
1: "Size",
}
// Decode decodes Pagination from json.
func (s *Pagination) Decode(d *jx.Decoder) error {
if s == nil {
return errors.New("invalid: unable to decode Pagination to nil")
}
var requiredBitSet [1]uint8
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
switch string(k) {
case "Number":
requiredBitSet[0] |= 1 << 0
if err := func() error {
v, err := d.Int32()
s.Number = int32(v)
if err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"Number\"")
}
case "Size":
requiredBitSet[0] |= 1 << 1
if err := func() error {
v, err := d.Int32()
s.Size = int32(v)
if err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"Size\"")
}
default:
return d.Skip()
}
return nil
}); err != nil {
return errors.Wrap(err, "decode Pagination")
}
// Validate required fields.
var failures []validate.FieldError
for i, mask := range [1]uint8{
0b00000011,
} {
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
// Mask only required fields and check equality to mask using XOR.
//
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
// Bits of fields which would be set are actually bits of missed fields.
missed := bits.OnesCount8(result)
for bitN := 0; bitN < missed; bitN++ {
bitIdx := bits.TrailingZeros8(result)
fieldIdx := i*8 + bitIdx
var name string
if fieldIdx < len(jsonFieldsNameOfPagination) {
name = jsonFieldsNameOfPagination[fieldIdx]
} else {
name = strconv.Itoa(fieldIdx)
}
failures = append(failures, validate.FieldError{
Name: name,
Error: validate.ErrFieldRequired,
})
// Reset bit.
result &^= 1 << bitIdx
}
}
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
// MarshalJSON implements stdjson.Marshaler.
func (s *Pagination) MarshalJSON() ([]byte, error) {
e := jx.Encoder{}
s.Encode(&e)
return e.Bytes(), nil
}
// UnmarshalJSON implements stdjson.Unmarshaler.
func (s *Pagination) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data)
return s.Decode(d)
}
// Encode implements json.Marshaler.
func (s *Script) Encode(e *jx.Encoder) {
e.ObjStart()
@ -1298,103 +897,6 @@ func (s *ScriptPolicyCreate) UnmarshalJSON(data []byte) error {
return s.Decode(d)
}
// Encode implements json.Marshaler.
func (s *ScriptPolicyFilter) Encode(e *jx.Encoder) {
e.ObjStart()
s.encodeFields(e)
e.ObjEnd()
}
// encodeFields encodes fields.
func (s *ScriptPolicyFilter) encodeFields(e *jx.Encoder) {
{
if s.FromScriptHash.Set {
e.FieldStart("FromScriptHash")
s.FromScriptHash.Encode(e)
}
}
{
if s.ToScriptID.Set {
e.FieldStart("ToScriptID")
s.ToScriptID.Encode(e)
}
}
{
if s.Policy.Set {
e.FieldStart("Policy")
s.Policy.Encode(e)
}
}
}
var jsonFieldsNameOfScriptPolicyFilter = [3]string{
0: "FromScriptHash",
1: "ToScriptID",
2: "Policy",
}
// Decode decodes ScriptPolicyFilter from json.
func (s *ScriptPolicyFilter) Decode(d *jx.Decoder) error {
if s == nil {
return errors.New("invalid: unable to decode ScriptPolicyFilter to nil")
}
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
switch string(k) {
case "FromScriptHash":
if err := func() error {
s.FromScriptHash.Reset()
if err := s.FromScriptHash.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"FromScriptHash\"")
}
case "ToScriptID":
if err := func() error {
s.ToScriptID.Reset()
if err := s.ToScriptID.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"ToScriptID\"")
}
case "Policy":
if err := func() error {
s.Policy.Reset()
if err := s.Policy.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"Policy\"")
}
default:
return d.Skip()
}
return nil
}); err != nil {
return errors.Wrap(err, "decode ScriptPolicyFilter")
}
return nil
}
// MarshalJSON implements stdjson.Marshaler.
func (s *ScriptPolicyFilter) MarshalJSON() ([]byte, error) {
e := jx.Encoder{}
s.Encode(&e)
return e.Bytes(), nil
}
// UnmarshalJSON implements stdjson.Unmarshaler.
func (s *ScriptPolicyFilter) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data)
return s.Decode(d)
}
// Encode implements json.Marshaler.
func (s *ScriptPolicyUpdate) Encode(e *jx.Encoder) {
e.ObjStart()
@ -2170,100 +1672,3 @@ func (s *SubmissionCreate) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data)
return s.Decode(d)
}
// Encode implements json.Marshaler.
func (s *SubmissionFilter) Encode(e *jx.Encoder) {
e.ObjStart()
s.encodeFields(e)
e.ObjEnd()
}
// encodeFields encodes fields.
func (s *SubmissionFilter) encodeFields(e *jx.Encoder) {
{
if s.DisplayName.Set {
e.FieldStart("DisplayName")
s.DisplayName.Encode(e)
}
}
{
if s.Creator.Set {
e.FieldStart("Creator")
s.Creator.Encode(e)
}
}
{
if s.GameID.Set {
e.FieldStart("GameID")
s.GameID.Encode(e)
}
}
}
var jsonFieldsNameOfSubmissionFilter = [3]string{
0: "DisplayName",
1: "Creator",
2: "GameID",
}
// Decode decodes SubmissionFilter from json.
func (s *SubmissionFilter) Decode(d *jx.Decoder) error {
if s == nil {
return errors.New("invalid: unable to decode SubmissionFilter to nil")
}
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
switch string(k) {
case "DisplayName":
if err := func() error {
s.DisplayName.Reset()
if err := s.DisplayName.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"DisplayName\"")
}
case "Creator":
if err := func() error {
s.Creator.Reset()
if err := s.Creator.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"Creator\"")
}
case "GameID":
if err := func() error {
s.GameID.Reset()
if err := s.GameID.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"GameID\"")
}
default:
return d.Skip()
}
return nil
}); err != nil {
return errors.Wrap(err, "decode SubmissionFilter")
}
return nil
}
// MarshalJSON implements stdjson.Marshaler.
func (s *SubmissionFilter) MarshalJSON() ([]byte, error) {
e := jx.Encoder{}
s.Encode(&e)
return e.Bytes(), nil
}
// UnmarshalJSON implements stdjson.Unmarshaler.
func (s *SubmissionFilter) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data)
return s.Decode(d)
}

View File

@ -822,6 +822,651 @@ func decodeGetSubmissionParams(args [1]string, argsEscaped bool, r *http.Request
return params, nil
}
// ListScriptPolicyParams is parameters of listScriptPolicy operation.
type ListScriptPolicyParams struct {
Page int32
Limit int32
FromScriptHash OptString
ToScriptID OptInt64
Policy OptInt32
}
func unpackListScriptPolicyParams(packed middleware.Parameters) (params ListScriptPolicyParams) {
{
key := middleware.ParameterKey{
Name: "Page",
In: "query",
}
params.Page = packed[key].(int32)
}
{
key := middleware.ParameterKey{
Name: "Limit",
In: "query",
}
params.Limit = packed[key].(int32)
}
{
key := middleware.ParameterKey{
Name: "FromScriptHash",
In: "query",
}
if v, ok := packed[key]; ok {
params.FromScriptHash = v.(OptString)
}
}
{
key := middleware.ParameterKey{
Name: "ToScriptID",
In: "query",
}
if v, ok := packed[key]; ok {
params.ToScriptID = v.(OptInt64)
}
}
{
key := middleware.ParameterKey{
Name: "Policy",
In: "query",
}
if v, ok := packed[key]; ok {
params.Policy = v.(OptInt32)
}
}
return params
}
func decodeListScriptPolicyParams(args [0]string, argsEscaped bool, r *http.Request) (params ListScriptPolicyParams, _ error) {
q := uri.NewQueryDecoder(r.URL.Query())
// Decode query: Page.
if err := func() error {
cfg := uri.QueryParameterDecodingConfig{
Name: "Page",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.HasParam(cfg); err == nil {
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToInt32(val)
if err != nil {
return err
}
params.Page = c
return nil
}); err != nil {
return err
}
if err := func() error {
if err := (validate.Int{
MinSet: true,
Min: 1,
MaxSet: false,
Max: 0,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,
MultipleOf: 0,
}).Validate(int64(params.Page)); err != nil {
return errors.Wrap(err, "int")
}
return nil
}(); err != nil {
return err
}
} else {
return validate.ErrFieldRequired
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "Page",
In: "query",
Err: err,
}
}
// Decode query: Limit.
if err := func() error {
cfg := uri.QueryParameterDecodingConfig{
Name: "Limit",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.HasParam(cfg); err == nil {
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToInt32(val)
if err != nil {
return err
}
params.Limit = c
return nil
}); err != nil {
return err
}
if err := func() error {
if err := (validate.Int{
MinSet: true,
Min: 1,
MaxSet: true,
Max: 100,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,
MultipleOf: 0,
}).Validate(int64(params.Limit)); err != nil {
return errors.Wrap(err, "int")
}
return nil
}(); err != nil {
return err
}
} else {
return validate.ErrFieldRequired
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "Limit",
In: "query",
Err: err,
}
}
// Decode query: FromScriptHash.
if err := func() error {
cfg := uri.QueryParameterDecodingConfig{
Name: "FromScriptHash",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.HasParam(cfg); err == nil {
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
var paramsDotFromScriptHashVal string
if err := func() error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToString(val)
if err != nil {
return err
}
paramsDotFromScriptHashVal = c
return nil
}(); err != nil {
return err
}
params.FromScriptHash.SetTo(paramsDotFromScriptHashVal)
return nil
}); err != nil {
return err
}
if err := func() error {
if value, ok := params.FromScriptHash.Get(); ok {
if err := func() error {
if err := (validate.String{
MinLength: 16,
MinLengthSet: true,
MaxLength: 16,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
}).Validate(string(value)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "FromScriptHash",
In: "query",
Err: err,
}
}
// Decode query: ToScriptID.
if err := func() error {
cfg := uri.QueryParameterDecodingConfig{
Name: "ToScriptID",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.HasParam(cfg); err == nil {
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
var paramsDotToScriptIDVal int64
if err := func() error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToInt64(val)
if err != nil {
return err
}
paramsDotToScriptIDVal = c
return nil
}(); err != nil {
return err
}
params.ToScriptID.SetTo(paramsDotToScriptIDVal)
return nil
}); err != nil {
return err
}
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "ToScriptID",
In: "query",
Err: err,
}
}
// Decode query: Policy.
if err := func() error {
cfg := uri.QueryParameterDecodingConfig{
Name: "Policy",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.HasParam(cfg); err == nil {
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
var paramsDotPolicyVal int32
if err := func() error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToInt32(val)
if err != nil {
return err
}
paramsDotPolicyVal = c
return nil
}(); err != nil {
return err
}
params.Policy.SetTo(paramsDotPolicyVal)
return nil
}); err != nil {
return err
}
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "Policy",
In: "query",
Err: err,
}
}
return params, nil
}
// ListSubmissionsParams is parameters of listSubmissions operation.
type ListSubmissionsParams struct {
Page int32
Limit int32
DisplayName OptString
Creator OptString
GameID OptInt32
}
func unpackListSubmissionsParams(packed middleware.Parameters) (params ListSubmissionsParams) {
{
key := middleware.ParameterKey{
Name: "Page",
In: "query",
}
params.Page = packed[key].(int32)
}
{
key := middleware.ParameterKey{
Name: "Limit",
In: "query",
}
params.Limit = packed[key].(int32)
}
{
key := middleware.ParameterKey{
Name: "DisplayName",
In: "query",
}
if v, ok := packed[key]; ok {
params.DisplayName = v.(OptString)
}
}
{
key := middleware.ParameterKey{
Name: "Creator",
In: "query",
}
if v, ok := packed[key]; ok {
params.Creator = v.(OptString)
}
}
{
key := middleware.ParameterKey{
Name: "GameID",
In: "query",
}
if v, ok := packed[key]; ok {
params.GameID = v.(OptInt32)
}
}
return params
}
func decodeListSubmissionsParams(args [0]string, argsEscaped bool, r *http.Request) (params ListSubmissionsParams, _ error) {
q := uri.NewQueryDecoder(r.URL.Query())
// Decode query: Page.
if err := func() error {
cfg := uri.QueryParameterDecodingConfig{
Name: "Page",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.HasParam(cfg); err == nil {
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToInt32(val)
if err != nil {
return err
}
params.Page = c
return nil
}); err != nil {
return err
}
if err := func() error {
if err := (validate.Int{
MinSet: true,
Min: 1,
MaxSet: false,
Max: 0,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,
MultipleOf: 0,
}).Validate(int64(params.Page)); err != nil {
return errors.Wrap(err, "int")
}
return nil
}(); err != nil {
return err
}
} else {
return validate.ErrFieldRequired
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "Page",
In: "query",
Err: err,
}
}
// Decode query: Limit.
if err := func() error {
cfg := uri.QueryParameterDecodingConfig{
Name: "Limit",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.HasParam(cfg); err == nil {
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToInt32(val)
if err != nil {
return err
}
params.Limit = c
return nil
}); err != nil {
return err
}
if err := func() error {
if err := (validate.Int{
MinSet: true,
Min: 1,
MaxSet: true,
Max: 100,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,
MultipleOf: 0,
}).Validate(int64(params.Limit)); err != nil {
return errors.Wrap(err, "int")
}
return nil
}(); err != nil {
return err
}
} else {
return validate.ErrFieldRequired
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "Limit",
In: "query",
Err: err,
}
}
// Decode query: DisplayName.
if err := func() error {
cfg := uri.QueryParameterDecodingConfig{
Name: "DisplayName",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.HasParam(cfg); err == nil {
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
var paramsDotDisplayNameVal string
if err := func() error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToString(val)
if err != nil {
return err
}
paramsDotDisplayNameVal = c
return nil
}(); err != nil {
return err
}
params.DisplayName.SetTo(paramsDotDisplayNameVal)
return nil
}); err != nil {
return err
}
if err := func() error {
if value, ok := params.DisplayName.Get(); ok {
if err := func() error {
if err := (validate.String{
MinLength: 0,
MinLengthSet: false,
MaxLength: 128,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
}).Validate(string(value)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "DisplayName",
In: "query",
Err: err,
}
}
// Decode query: Creator.
if err := func() error {
cfg := uri.QueryParameterDecodingConfig{
Name: "Creator",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.HasParam(cfg); err == nil {
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
var paramsDotCreatorVal string
if err := func() error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToString(val)
if err != nil {
return err
}
paramsDotCreatorVal = c
return nil
}(); err != nil {
return err
}
params.Creator.SetTo(paramsDotCreatorVal)
return nil
}); err != nil {
return err
}
if err := func() error {
if value, ok := params.Creator.Get(); ok {
if err := func() error {
if err := (validate.String{
MinLength: 0,
MinLengthSet: false,
MaxLength: 128,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
}).Validate(string(value)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "Creator",
In: "query",
Err: err,
}
}
// Decode query: GameID.
if err := func() error {
cfg := uri.QueryParameterDecodingConfig{
Name: "GameID",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.HasParam(cfg); err == nil {
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
var paramsDotGameIDVal int32
if err := func() error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToInt32(val)
if err != nil {
return err
}
paramsDotGameIDVal = c
return nil
}(); err != nil {
return err
}
params.GameID.SetTo(paramsDotGameIDVal)
return nil
}); err != nil {
return err
}
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "GameID",
In: "query",
Err: err,
}
}
return params, nil
}
// SetSubmissionCompletedParams is parameters of setSubmissionCompleted operation.
type SetSubmissionCompletedParams struct {
// The unique identifier for a submission.

View File

@ -220,148 +220,6 @@ func (s *Server) decodeCreateSubmissionRequest(r *http.Request) (
}
}
func (s *Server) decodeListScriptPolicyRequest(r *http.Request) (
req *ListScriptPolicyReq,
close func() error,
rerr error,
) {
var closers []func() error
close = func() error {
var merr error
// Close in reverse order, to match defer behavior.
for i := len(closers) - 1; i >= 0; i-- {
c := closers[i]
merr = multierr.Append(merr, c())
}
return merr
}
defer func() {
if rerr != nil {
rerr = multierr.Append(rerr, close())
}
}()
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
if err != nil {
return req, close, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/json":
if r.ContentLength == 0 {
return req, close, validate.ErrBodyRequired
}
buf, err := io.ReadAll(r.Body)
if err != nil {
return req, close, err
}
if len(buf) == 0 {
return req, close, validate.ErrBodyRequired
}
d := jx.DecodeBytes(buf)
var request ListScriptPolicyReq
if err := func() error {
if err := request.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return req, close, err
}
if err := func() error {
if err := request.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return req, close, errors.Wrap(err, "validate")
}
return &request, close, nil
default:
return req, close, validate.InvalidContentType(ct)
}
}
func (s *Server) decodeListSubmissionsRequest(r *http.Request) (
req *ListSubmissionsReq,
close func() error,
rerr error,
) {
var closers []func() error
close = func() error {
var merr error
// Close in reverse order, to match defer behavior.
for i := len(closers) - 1; i >= 0; i-- {
c := closers[i]
merr = multierr.Append(merr, c())
}
return merr
}
defer func() {
if rerr != nil {
rerr = multierr.Append(rerr, close())
}
}()
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
if err != nil {
return req, close, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/json":
if r.ContentLength == 0 {
return req, close, validate.ErrBodyRequired
}
buf, err := io.ReadAll(r.Body)
if err != nil {
return req, close, err
}
if len(buf) == 0 {
return req, close, validate.ErrBodyRequired
}
d := jx.DecodeBytes(buf)
var request ListSubmissionsReq
if err := func() error {
if err := request.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return req, close, err
}
if err := func() error {
if err := request.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return req, close, errors.Wrap(err, "validate")
}
return &request, close, nil
default:
return req, close, validate.InvalidContentType(ct)
}
}
func (s *Server) decodeUpdateScriptRequest(r *http.Request) (
req *ScriptUpdate,
close func() error,

View File

@ -53,34 +53,6 @@ func encodeCreateSubmissionRequest(
return nil
}
func encodeListScriptPolicyRequest(
req *ListScriptPolicyReq,
r *http.Request,
) error {
const contentType = "application/json"
e := new(jx.Encoder)
{
req.Encode(e)
}
encoded := e.Bytes()
ht.SetBody(r, bytes.NewReader(encoded), contentType)
return nil
}
func encodeListSubmissionsRequest(
req *ListSubmissionsReq,
r *http.Request,
) error {
const contentType = "application/json"
e := new(jx.Encoder)
{
req.Encode(e)
}
encoded := e.Bytes()
ht.SetBody(r, bytes.NewReader(encoded), contentType)
return nil
}
func encodeUpdateScriptRequest(
req *ScriptUpdate,
r *http.Request,

View File

@ -116,56 +116,6 @@ func (s *ID) SetID(val int64) {
s.ID = val
}
type ListScriptPolicyReq struct {
Page Pagination `json:"Page"`
Filter OptScriptPolicyFilter `json:"Filter"`
}
// GetPage returns the value of Page.
func (s *ListScriptPolicyReq) GetPage() Pagination {
return s.Page
}
// GetFilter returns the value of Filter.
func (s *ListScriptPolicyReq) GetFilter() OptScriptPolicyFilter {
return s.Filter
}
// SetPage sets the value of Page.
func (s *ListScriptPolicyReq) SetPage(val Pagination) {
s.Page = val
}
// SetFilter sets the value of Filter.
func (s *ListScriptPolicyReq) SetFilter(val OptScriptPolicyFilter) {
s.Filter = val
}
type ListSubmissionsReq struct {
Page Pagination `json:"Page"`
Filter OptSubmissionFilter `json:"Filter"`
}
// GetPage returns the value of Page.
func (s *ListSubmissionsReq) GetPage() Pagination {
return s.Page
}
// GetFilter returns the value of Filter.
func (s *ListSubmissionsReq) GetFilter() OptSubmissionFilter {
return s.Filter
}
// SetPage sets the value of Page.
func (s *ListSubmissionsReq) SetPage(val Pagination) {
s.Page = val
}
// SetFilter sets the value of Filter.
func (s *ListSubmissionsReq) SetFilter(val OptSubmissionFilter) {
s.Filter = val
}
// NewOptInt32 returns new OptInt32 with value set to v.
func NewOptInt32(v int32) OptInt32 {
return OptInt32{
@ -258,52 +208,6 @@ func (o OptInt64) Or(d int64) int64 {
return d
}
// NewOptScriptPolicyFilter returns new OptScriptPolicyFilter with value set to v.
func NewOptScriptPolicyFilter(v ScriptPolicyFilter) OptScriptPolicyFilter {
return OptScriptPolicyFilter{
Value: v,
Set: true,
}
}
// OptScriptPolicyFilter is optional ScriptPolicyFilter.
type OptScriptPolicyFilter struct {
Value ScriptPolicyFilter
Set bool
}
// IsSet returns true if OptScriptPolicyFilter was set.
func (o OptScriptPolicyFilter) IsSet() bool { return o.Set }
// Reset unsets value.
func (o *OptScriptPolicyFilter) Reset() {
var v ScriptPolicyFilter
o.Value = v
o.Set = false
}
// SetTo sets value to v.
func (o *OptScriptPolicyFilter) SetTo(v ScriptPolicyFilter) {
o.Set = true
o.Value = v
}
// Get returns value and boolean that denotes whether value was set.
func (o OptScriptPolicyFilter) Get() (v ScriptPolicyFilter, ok bool) {
if !o.Set {
return v, false
}
return o.Value, true
}
// Or returns value if set, or given parameter if does not.
func (o OptScriptPolicyFilter) Or(d ScriptPolicyFilter) ScriptPolicyFilter {
if v, ok := o.Get(); ok {
return v
}
return d
}
// NewOptString returns new OptString with value set to v.
func NewOptString(v string) OptString {
return OptString{
@ -350,78 +254,6 @@ func (o OptString) Or(d string) string {
return d
}
// NewOptSubmissionFilter returns new OptSubmissionFilter with value set to v.
func NewOptSubmissionFilter(v SubmissionFilter) OptSubmissionFilter {
return OptSubmissionFilter{
Value: v,
Set: true,
}
}
// OptSubmissionFilter is optional SubmissionFilter.
type OptSubmissionFilter struct {
Value SubmissionFilter
Set bool
}
// IsSet returns true if OptSubmissionFilter was set.
func (o OptSubmissionFilter) IsSet() bool { return o.Set }
// Reset unsets value.
func (o *OptSubmissionFilter) Reset() {
var v SubmissionFilter
o.Value = v
o.Set = false
}
// SetTo sets value to v.
func (o *OptSubmissionFilter) SetTo(v SubmissionFilter) {
o.Set = true
o.Value = v
}
// Get returns value and boolean that denotes whether value was set.
func (o OptSubmissionFilter) Get() (v SubmissionFilter, ok bool) {
if !o.Set {
return v, false
}
return o.Value, true
}
// Or returns value if set, or given parameter if does not.
func (o OptSubmissionFilter) Or(d SubmissionFilter) SubmissionFilter {
if v, ok := o.Get(); ok {
return v
}
return d
}
// Ref: #/components/schemas/Pagination
type Pagination struct {
Number int32 `json:"Number"`
Size int32 `json:"Size"`
}
// GetNumber returns the value of Number.
func (s *Pagination) GetNumber() int32 {
return s.Number
}
// GetSize returns the value of Size.
func (s *Pagination) GetSize() int32 {
return s.Size
}
// SetNumber sets the value of Number.
func (s *Pagination) SetNumber(val int32) {
s.Number = val
}
// SetSize sets the value of Size.
func (s *Pagination) SetSize(val int32) {
s.Size = val
}
// Ref: #/components/schemas/Script
type Script struct {
ID int64 `json:"ID"`
@ -603,43 +435,6 @@ func (s *ScriptPolicyCreate) SetPolicy(val int32) {
s.Policy = val
}
// Ref: #/components/schemas/ScriptPolicyFilter
type ScriptPolicyFilter struct {
FromScriptHash OptString `json:"FromScriptHash"`
ToScriptID OptInt64 `json:"ToScriptID"`
Policy OptInt32 `json:"Policy"`
}
// GetFromScriptHash returns the value of FromScriptHash.
func (s *ScriptPolicyFilter) GetFromScriptHash() OptString {
return s.FromScriptHash
}
// GetToScriptID returns the value of ToScriptID.
func (s *ScriptPolicyFilter) GetToScriptID() OptInt64 {
return s.ToScriptID
}
// GetPolicy returns the value of Policy.
func (s *ScriptPolicyFilter) GetPolicy() OptInt32 {
return s.Policy
}
// SetFromScriptHash sets the value of FromScriptHash.
func (s *ScriptPolicyFilter) SetFromScriptHash(val OptString) {
s.FromScriptHash = val
}
// SetToScriptID sets the value of ToScriptID.
func (s *ScriptPolicyFilter) SetToScriptID(val OptInt64) {
s.ToScriptID = val
}
// SetPolicy sets the value of Policy.
func (s *ScriptPolicyFilter) SetPolicy(val OptInt32) {
s.Policy = val
}
// Ref: #/components/schemas/ScriptPolicyUpdate
type ScriptPolicyUpdate struct {
ID int64 `json:"ID"`
@ -956,43 +751,6 @@ func (s *SubmissionCreate) SetTargetAssetID(val OptInt64) {
s.TargetAssetID = val
}
// Ref: #/components/schemas/SubmissionFilter
type SubmissionFilter struct {
DisplayName OptString `json:"DisplayName"`
Creator OptString `json:"Creator"`
GameID OptInt32 `json:"GameID"`
}
// GetDisplayName returns the value of DisplayName.
func (s *SubmissionFilter) GetDisplayName() OptString {
return s.DisplayName
}
// GetCreator returns the value of Creator.
func (s *SubmissionFilter) GetCreator() OptString {
return s.Creator
}
// GetGameID returns the value of GameID.
func (s *SubmissionFilter) GetGameID() OptInt32 {
return s.GameID
}
// SetDisplayName sets the value of DisplayName.
func (s *SubmissionFilter) SetDisplayName(val OptString) {
s.DisplayName = val
}
// SetCreator sets the value of Creator.
func (s *SubmissionFilter) SetCreator(val OptString) {
s.Creator = val
}
// SetGameID sets the value of GameID.
func (s *SubmissionFilter) SetGameID(val OptInt32) {
s.GameID = val
}
// UpdateScriptNoContent is response for UpdateScript operation.
type UpdateScriptNoContent struct{}

View File

@ -103,13 +103,13 @@ type Handler interface {
// Get list of script policies.
//
// GET /script-policy
ListScriptPolicy(ctx context.Context, req *ListScriptPolicyReq) ([]ScriptPolicy, error)
ListScriptPolicy(ctx context.Context, params ListScriptPolicyParams) ([]ScriptPolicy, error)
// ListSubmissions implements listSubmissions operation.
//
// Get list of submissions.
//
// GET /submissions
ListSubmissions(ctx context.Context, req *ListSubmissionsReq) ([]Submission, error)
ListSubmissions(ctx context.Context, params ListSubmissionsParams) ([]Submission, error)
// SetSubmissionCompleted implements setSubmissionCompleted operation.
//
// Retrieve map with ID.

View File

@ -153,7 +153,7 @@ func (UnimplementedHandler) GetSubmission(ctx context.Context, params GetSubmiss
// Get list of script policies.
//
// GET /script-policy
func (UnimplementedHandler) ListScriptPolicy(ctx context.Context, req *ListScriptPolicyReq) (r []ScriptPolicy, _ error) {
func (UnimplementedHandler) ListScriptPolicy(ctx context.Context, params ListScriptPolicyParams) (r []ScriptPolicy, _ error) {
return r, ht.ErrNotImplemented
}
@ -162,7 +162,7 @@ func (UnimplementedHandler) ListScriptPolicy(ctx context.Context, req *ListScrip
// Get list of submissions.
//
// GET /submissions
func (UnimplementedHandler) ListSubmissions(ctx context.Context, req *ListSubmissionsReq) (r []Submission, _ error) {
func (UnimplementedHandler) ListSubmissions(ctx context.Context, params ListSubmissionsParams) (r []Submission, _ error) {
return r, ht.ErrNotImplemented
}

View File

@ -8,140 +8,6 @@ import (
"github.com/ogen-go/ogen/validate"
)
func (s *ListScriptPolicyReq) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := s.Page.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "Page",
Error: err,
})
}
if err := func() error {
if value, ok := s.Filter.Get(); ok {
if err := func() error {
if err := value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "Filter",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *ListSubmissionsReq) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := s.Page.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "Page",
Error: err,
})
}
if err := func() error {
if value, ok := s.Filter.Get(); ok {
if err := func() error {
if err := value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "Filter",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *Pagination) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := (validate.Int{
MinSet: true,
Min: 1,
MaxSet: false,
Max: 0,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,
MultipleOf: 0,
}).Validate(int64(s.Number)); err != nil {
return errors.Wrap(err, "int")
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "Number",
Error: err,
})
}
if err := func() error {
if err := (validate.Int{
MinSet: true,
Min: 1,
MaxSet: true,
Max: 100,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,
MultipleOf: 0,
}).Validate(int64(s.Size)); err != nil {
return errors.Wrap(err, "int")
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "Size",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *Script) Validate() error {
if s == nil {
return validate.ErrNilPointer
@ -292,44 +158,6 @@ func (s *ScriptPolicy) Validate() error {
return nil
}
func (s *ScriptPolicyFilter) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if value, ok := s.FromScriptHash.Get(); ok {
if err := func() error {
if err := (validate.String{
MinLength: 16,
MinLengthSet: true,
MaxLength: 16,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
}).Validate(string(value)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "FromScriptHash",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *ScriptUpdate) Validate() error {
if s == nil {
return validate.ErrNilPointer
@ -493,67 +321,3 @@ func (s *SubmissionCreate) Validate() error {
}
return nil
}
func (s *SubmissionFilter) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if value, ok := s.DisplayName.Get(); ok {
if err := func() error {
if err := (validate.String{
MinLength: 0,
MinLengthSet: false,
MaxLength: 128,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
}).Validate(string(value)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "DisplayName",
Error: err,
})
}
if err := func() error {
if value, ok := s.Creator.Get(); ok {
if err := func() error {
if err := (validate.String{
MinLength: 0,
MinLengthSet: false,
MaxLength: 128,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
}).Validate(string(value)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "Creator",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}