From 680c21ca11dccfad56ae9150b941e6c5d64b1802 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 27 Nov 2024 17:22:59 -0800 Subject: [PATCH] completed is implicitly true --- openapi.yaml | 5 ---- pkg/api/oas_client_gen.go | 18 -------------- pkg/api/oas_handlers_gen.go | 4 ---- pkg/api/oas_parameters_gen.go | 45 ----------------------------------- pkg/service/submissions.go | 2 +- 5 files changed, 1 insertion(+), 73 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 158a847..a66c40b 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -142,11 +142,6 @@ paths: schema: type: integer format: int64 - - name: Completed - in: query - required: true - schema: - type: boolean responses: "200": description: Successful response diff --git a/pkg/api/oas_client_gen.go b/pkg/api/oas_client_gen.go index 4faf1cf..48df807 100644 --- a/pkg/api/oas_client_gen.go +++ b/pkg/api/oas_client_gen.go @@ -454,24 +454,6 @@ func (c *Client) sendPatchSubmissionCompleted(ctx context.Context, params PatchS pathParts[2] = "/completed" 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" r, err := ht.NewRequest(ctx, "PATCH", u) if err != nil { diff --git a/pkg/api/oas_handlers_gen.go b/pkg/api/oas_handlers_gen.go index 06c1faf..7b8897d 100644 --- a/pkg/api/oas_handlers_gen.go +++ b/pkg/api/oas_handlers_gen.go @@ -465,10 +465,6 @@ func (s *Server) handlePatchSubmissionCompletedRequest(args [1]string, argsEscap Name: "SubmissionID", In: "path", }: params.SubmissionID, - { - Name: "Completed", - In: "query", - }: params.Completed, }, Raw: r, } diff --git a/pkg/api/oas_parameters_gen.go b/pkg/api/oas_parameters_gen.go index 659dea3..aa105a0 100644 --- a/pkg/api/oas_parameters_gen.go +++ b/pkg/api/oas_parameters_gen.go @@ -179,7 +179,6 @@ func decodeListSubmissionsParams(args [0]string, argsEscaped bool, r *http.Reque // PatchSubmissionCompletedParams is parameters of patchSubmissionCompleted operation. type PatchSubmissionCompletedParams struct { SubmissionID int64 - Completed bool } func unpackPatchSubmissionCompletedParams(packed middleware.Parameters) (params PatchSubmissionCompletedParams) { @@ -190,18 +189,10 @@ func unpackPatchSubmissionCompletedParams(packed middleware.Parameters) (params } params.SubmissionID = packed[key].(int64) } - { - key := middleware.ParameterKey{ - Name: "Completed", - In: "query", - } - params.Completed = packed[key].(bool) - } return params } func decodePatchSubmissionCompletedParams(args [1]string, argsEscaped bool, r *http.Request) (params PatchSubmissionCompletedParams, _ error) { - q := uri.NewQueryDecoder(r.URL.Query()) // Decode path: SubmissionID. if err := func() error { param := args[0] @@ -247,42 +238,6 @@ func decodePatchSubmissionCompletedParams(args [1]string, argsEscaped bool, r *h 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 } diff --git a/pkg/service/submissions.go b/pkg/service/submissions.go index 2d5bd40..ade2cc0 100644 --- a/pkg/service/submissions.go +++ b/pkg/service/submissions.go @@ -106,7 +106,7 @@ func (svc *Service) ListSubmissions(ctx context.Context, request api.ListSubmiss // PATCH /submissions/{SubmissionID}/completed func (svc *Service) PatchSubmissionCompleted(ctx context.Context, params api.PatchSubmissionCompletedParams) error { pmap := datastore.Optional() - pmap.AddNotNil("completed", params.Completed) + pmap.Add("completed", true) err := svc.DB.Submissions().Update(ctx, params.SubmissionID, pmap) return err }