Skip to content

Commit

Permalink
Merge pull request #58 from sirius2alpha/fix-issue-34
Browse files Browse the repository at this point in the history
Fix:#34 Add swagger comments in problem.go
  • Loading branch information
slhmy authored Mar 22, 2024
2 parents a564dea + f2ffae2 commit 2a39706
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/application/server/handler/problem.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ func SetupProblemRoute(baseRoute *gin.RouterGroup) {
}
}

// getProblem
//
// @Router /problem/{slug} [get]
// @Summary Get a problem
// @Description Get a problem
// @Tags problem
// @Accept json
// @Success 200
func getProblem(ginCtx *gin.Context) {
slug := ginCtx.Param("slug")

Expand All @@ -42,6 +50,13 @@ func getProblem(ginCtx *gin.Context) {
})
}

// putProblem
//
// @Router /problem [put]
// @Summary Put a problem
// @Description Put a problem
// @Tags problem
// @Accept json
func putProblem(ginCtx *gin.Context) {
problem := model.Problem{}
if err := ginCtx.ShouldBindJSON(&problem); err != nil {
Expand All @@ -56,6 +71,13 @@ func putProblem(ginCtx *gin.Context) {
}
}

// deleteProblem
//
// @Router /problem/{slug} [delete]
// @Summary Delete a problem
// @Description Delete a problem
// @Tags problem
// @Accept json
func deleteProblem(ginCtx *gin.Context) {
slug := ginCtx.Param("slug")

Expand Down Expand Up @@ -87,6 +109,14 @@ func getProblemInfoList(ginCtx *gin.Context) {
})
}

// putProblemPackage
//
// @Router /problem/{slug}/package [put]
// @Summary Put problem package
// @Description Put problem package
// @Tags problem
// @Accept json
// @Param slug path string true "problem slug"
func putProblemPackage(ginCtx *gin.Context) {
slug := ginCtx.Param("slug")
file, err := ginCtx.FormFile("file")
Expand All @@ -105,6 +135,15 @@ func putProblemPackage(ginCtx *gin.Context) {
ginCtx.Done()
}

// checkProblemSlug
//
// @Router /problem/{slug}/check [get]
// @Summary Check problem slug
// @Description Check problem slug
// @Tags problem
// @Accept json
// @Success 200
// @Param slug path string true "problem slug"
func checkProblemSlug(ginCtx *gin.Context) {
slug := ginCtx.Param("slug")

Expand All @@ -119,6 +158,11 @@ func checkProblemSlug(ginCtx *gin.Context) {
})
}

// PostSubmissionBody
//
// @Description The body of a submission request, containing the code and the language used for the submission.
// @Property code (string) required "The source code of the submission" minlength(1)
// @Property language (SubmissionLanguage) required "The programming language used for the submission"
type PostSubmissionBody struct {
Code string `json:"code" binding:"required"`
Language model.SubmissionLanguage `json:"language" binding:"required"`
Expand Down

0 comments on commit 2a39706

Please sign in to comment.