From 7660069c341c3ffb775cbf2d4511f8d9427bdba2 Mon Sep 17 00:00:00 2001 From: Paul Pan Date: Sun, 16 Jul 2023 16:27:12 +0800 Subject: [PATCH] fix: swagger documentation --- internal/api/runner/build.go | 1 + internal/api/status/query.go | 2 ++ internal/api/status/queryByVersion.go | 2 +- internal/api/submission/query.go | 1 + internal/service/runner/config.go | 6 +++--- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/api/runner/build.go b/internal/api/runner/build.go index e9b065a..d6e0227 100644 --- a/internal/api/runner/build.go +++ b/internal/api/runner/build.go @@ -31,6 +31,7 @@ func (h *handler) Build(_ context.Context, t *asynq.Task) error { } for i := range config.Languages { + // do not store in db config.Languages[i].Type = "" config.Languages[i].Script = "" config.Languages[i].Cmp = "" diff --git a/internal/api/status/query.go b/internal/api/status/query.go index 06b7ed8..faf98c8 100644 --- a/internal/api/status/query.go +++ b/internal/api/status/query.go @@ -18,6 +18,8 @@ type queryRequest struct { // @Response 200 {object} e.Response "model.status" // @Router /v1/status/query [post] func (h *handler) Query(c *gin.Context) { + // TODO: add permission check + req := new(queryRequest) if err := c.ShouldBind(req); err != nil { diff --git a/internal/api/status/queryByVersion.go b/internal/api/status/queryByVersion.go index 741bdea..04bc72d 100644 --- a/internal/api/status/queryByVersion.go +++ b/internal/api/status/queryByVersion.go @@ -21,9 +21,9 @@ type queryByVersionRequest struct { // @Param offset formData int false "start position" // @Param limit formData int true "limit number of records" // @Response 200 {object} e.Response "[]*model.status" +// @Security Authentication // @Router /v1/status/query/problem_version [post] func (h *handler) QueryByProblemVersion(c *gin.Context) { - claim, exist := c.Get("claim") if !exist { e.Pong(c, e.UserUnauthenticated, nil) diff --git a/internal/api/submission/query.go b/internal/api/submission/query.go index f6121ea..a63683a 100644 --- a/internal/api/submission/query.go +++ b/internal/api/submission/query.go @@ -61,6 +61,7 @@ func (h *handler) Query(c *gin.Context) { Point: currentPoint, } + // TODO: only show code when user is admin or the code is submitted by the user newResponse.Submission.Code = "" response = append(response, newResponse) diff --git a/internal/service/runner/config.go b/internal/service/runner/config.go index 94131c0..844ffca 100644 --- a/internal/service/runner/config.go +++ b/internal/service/runner/config.go @@ -16,9 +16,9 @@ type Config struct { } `json:"Runtime"` Languages []struct { Lang string `json:"Lang"` - Type string `json:"Type"` - Script string `json:"Script"` - Cmp string `json:"Cmp"` + Type string `json:"Type,omitempty"` + Script string `json:"Script,omitempty"` + Cmp string `json:"Cmp,omitempty"` } `json:"Languages"` Tasks []struct { Id int `json:"Id"`