completed is implicitly true

This commit is contained in:
Quaternions 2024-11-27 17:22:59 -08:00
parent 1119c91da3
commit 680c21ca11
5 changed files with 1 additions and 73 deletions

View File

@ -142,11 +142,6 @@ paths:
schema: schema:
type: integer type: integer
format: int64 format: int64
- name: Completed
in: query
required: true
schema:
type: boolean
responses: responses:
"200": "200":
description: Successful response description: Successful response

View File

@ -454,24 +454,6 @@ func (c *Client) sendPatchSubmissionCompleted(ctx context.Context, params PatchS
pathParts[2] = "/completed" pathParts[2] = "/completed"
uri.AddPathParts(u, pathParts[:]...) uri.AddPathParts(u, pathParts[:]...)
stage = "EncodeQueryParams"
q := uri.NewQueryEncoder()
{
// Encode "Completed" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "Completed",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
return e.EncodeValue(conv.BoolToString(params.Completed))
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
u.RawQuery = q.Values().Encode()
stage = "EncodeRequest" stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "PATCH", u) r, err := ht.NewRequest(ctx, "PATCH", u)
if err != nil { if err != nil {

View File

@ -465,10 +465,6 @@ func (s *Server) handlePatchSubmissionCompletedRequest(args [1]string, argsEscap
Name: "SubmissionID", Name: "SubmissionID",
In: "path", In: "path",
}: params.SubmissionID, }: params.SubmissionID,
{
Name: "Completed",
In: "query",
}: params.Completed,
}, },
Raw: r, Raw: r,
} }

View File

@ -179,7 +179,6 @@ func decodeListSubmissionsParams(args [0]string, argsEscaped bool, r *http.Reque
// PatchSubmissionCompletedParams is parameters of patchSubmissionCompleted operation. // PatchSubmissionCompletedParams is parameters of patchSubmissionCompleted operation.
type PatchSubmissionCompletedParams struct { type PatchSubmissionCompletedParams struct {
SubmissionID int64 SubmissionID int64
Completed bool
} }
func unpackPatchSubmissionCompletedParams(packed middleware.Parameters) (params PatchSubmissionCompletedParams) { func unpackPatchSubmissionCompletedParams(packed middleware.Parameters) (params PatchSubmissionCompletedParams) {
@ -190,18 +189,10 @@ func unpackPatchSubmissionCompletedParams(packed middleware.Parameters) (params
} }
params.SubmissionID = packed[key].(int64) params.SubmissionID = packed[key].(int64)
} }
{
key := middleware.ParameterKey{
Name: "Completed",
In: "query",
}
params.Completed = packed[key].(bool)
}
return params return params
} }
func decodePatchSubmissionCompletedParams(args [1]string, argsEscaped bool, r *http.Request) (params PatchSubmissionCompletedParams, _ error) { func decodePatchSubmissionCompletedParams(args [1]string, argsEscaped bool, r *http.Request) (params PatchSubmissionCompletedParams, _ error) {
q := uri.NewQueryDecoder(r.URL.Query())
// Decode path: SubmissionID. // Decode path: SubmissionID.
if err := func() error { if err := func() error {
param := args[0] param := args[0]
@ -247,42 +238,6 @@ func decodePatchSubmissionCompletedParams(args [1]string, argsEscaped bool, r *h
Err: err, Err: err,
} }
} }
// Decode query: Completed.
if err := func() error {
cfg := uri.QueryParameterDecodingConfig{
Name: "Completed",
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.ToBool(val)
if err != nil {
return err
}
params.Completed = c
return nil
}); err != nil {
return err
}
} else {
return validate.ErrFieldRequired
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "Completed",
In: "query",
Err: err,
}
}
return params, nil return params, nil
} }

View File

@ -106,7 +106,7 @@ func (svc *Service) ListSubmissions(ctx context.Context, request api.ListSubmiss
// PATCH /submissions/{SubmissionID}/completed // PATCH /submissions/{SubmissionID}/completed
func (svc *Service) PatchSubmissionCompleted(ctx context.Context, params api.PatchSubmissionCompletedParams) error { func (svc *Service) PatchSubmissionCompleted(ctx context.Context, params api.PatchSubmissionCompletedParams) error {
pmap := datastore.Optional() pmap := datastore.Optional()
pmap.AddNotNil("completed", params.Completed) pmap.Add("completed", true)
err := svc.DB.Submissions().Update(ctx, params.SubmissionID, pmap) err := svc.DB.Submissions().Update(ctx, params.SubmissionID, pmap)
return err return err
} }