fix: swagger documentation

This commit is contained in:
Paul Pan 2023-07-16 16:27:12 +08:00
parent 42b9e98408
commit 7660069c34
5 changed files with 8 additions and 4 deletions

View File

@ -31,6 +31,7 @@ func (h *handler) Build(_ context.Context, t *asynq.Task) error {
} }
for i := range config.Languages { for i := range config.Languages {
// do not store in db
config.Languages[i].Type = "" config.Languages[i].Type = ""
config.Languages[i].Script = "" config.Languages[i].Script = ""
config.Languages[i].Cmp = "" config.Languages[i].Cmp = ""

View File

@ -18,6 +18,8 @@ type queryRequest struct {
// @Response 200 {object} e.Response "model.status" // @Response 200 {object} e.Response "model.status"
// @Router /v1/status/query [post] // @Router /v1/status/query [post]
func (h *handler) Query(c *gin.Context) { func (h *handler) Query(c *gin.Context) {
// TODO: add permission check
req := new(queryRequest) req := new(queryRequest)
if err := c.ShouldBind(req); err != nil { if err := c.ShouldBind(req); err != nil {

View File

@ -21,9 +21,9 @@ type queryByVersionRequest struct {
// @Param offset formData int false "start position" // @Param offset formData int false "start position"
// @Param limit formData int true "limit number of records" // @Param limit formData int true "limit number of records"
// @Response 200 {object} e.Response "[]*model.status" // @Response 200 {object} e.Response "[]*model.status"
// @Security Authentication
// @Router /v1/status/query/problem_version [post] // @Router /v1/status/query/problem_version [post]
func (h *handler) QueryByProblemVersion(c *gin.Context) { func (h *handler) QueryByProblemVersion(c *gin.Context) {
claim, exist := c.Get("claim") claim, exist := c.Get("claim")
if !exist { if !exist {
e.Pong(c, e.UserUnauthenticated, nil) e.Pong(c, e.UserUnauthenticated, nil)

View File

@ -61,6 +61,7 @@ func (h *handler) Query(c *gin.Context) {
Point: currentPoint, Point: currentPoint,
} }
// TODO: only show code when user is admin or the code is submitted by the user
newResponse.Submission.Code = "" newResponse.Submission.Code = ""
response = append(response, newResponse) response = append(response, newResponse)

View File

@ -16,9 +16,9 @@ type Config struct {
} `json:"Runtime"` } `json:"Runtime"`
Languages []struct { Languages []struct {
Lang string `json:"Lang"` Lang string `json:"Lang"`
Type string `json:"Type"` Type string `json:"Type,omitempty"`
Script string `json:"Script"` Script string `json:"Script,omitempty"`
Cmp string `json:"Cmp"` Cmp string `json:"Cmp,omitempty"`
} `json:"Languages"` } `json:"Languages"`
Tasks []struct { Tasks []struct {
Id int `json:"Id"` Id int `json:"Id"`