From e7596959bb52c99c8abcfc25a61f8b677c0ad3ab Mon Sep 17 00:00:00 2001 From: sirius1y Date: Fri, 22 Mar 2024 10:13:05 +0800 Subject: [PATCH 1/2] Fix:#34 Add swagger comments in /src/server/handler/problem.go and generate docs --- src/application/server/docs/docs.go | 285 ++++++++++++++++++++++ src/application/server/docs/swagger.json | 256 +++++++++++++++++++ src/application/server/docs/swagger.yaml | 169 +++++++++++++ src/application/server/handler/problem.go | 44 ++++ 4 files changed, 754 insertions(+) create mode 100644 src/application/server/docs/docs.go create mode 100644 src/application/server/docs/swagger.json create mode 100644 src/application/server/docs/swagger.yaml diff --git a/src/application/server/docs/docs.go b/src/application/server/docs/docs.go new file mode 100644 index 0000000..296ee1d --- /dev/null +++ b/src/application/server/docs/docs.go @@ -0,0 +1,285 @@ +// Package docs Code generated by swaggo/swag. DO NOT EDIT +package docs + +import "github.com/swaggo/swag" + +const docTemplate = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "contact": {}, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/problem": { + "get": { + "description": "Get problem list", + "consumes": [ + "application/json" + ], + "tags": [ + "problem" + ], + "summary": "Get problem list", + "responses": { + "200": { + "description": "OK" + } + } + }, + "put": { + "description": "Put a problem", + "consumes": [ + "application/json" + ], + "tags": [ + "problem" + ], + "summary": "Put a problem", + "responses": {} + } + }, + "/problem/{slug}": { + "get": { + "description": "Get a problem", + "consumes": [ + "application/json" + ], + "tags": [ + "problem" + ], + "summary": "Get a problem", + "responses": { + "200": { + "description": "OK" + } + } + }, + "delete": { + "description": "Delete a problem", + "consumes": [ + "application/json" + ], + "tags": [ + "problem" + ], + "summary": "Delete a problem", + "responses": {} + } + }, + "/problem/{slug}/check": { + "get": { + "description": "Check problem slug", + "consumes": [ + "application/json" + ], + "tags": [ + "problem" + ], + "summary": "Check problem slug", + "parameters": [ + { + "type": "string", + "description": "problem slug", + "name": "slug", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/problem/{slug}/package": { + "put": { + "description": "Put problem package", + "consumes": [ + "application/json" + ], + "tags": [ + "problem" + ], + "summary": "Put problem package", + "parameters": [ + { + "type": "string", + "description": "problem slug", + "name": "slug", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/problem/{slug}/submission": { + "post": { + "description": "Post submission", + "consumes": [ + "application/json" + ], + "tags": [ + "problem" + ], + "summary": "Post submission", + "parameters": [ + { + "type": "string", + "description": "problem slug", + "name": "slug", + "in": "path", + "required": true + }, + { + "description": "judge request", + "name": "judgeRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handler.PostSubmissionBody" + } + } + ], + "responses": {} + } + }, + "/submission": { + "get": { + "description": "Get submission list", + "consumes": [ + "application/json" + ], + "tags": [ + "submission" + ], + "summary": "Get submission list", + "parameters": [ + { + "type": "integer", + "description": "limit", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "offset", + "name": "offset", + "in": "query" + } + ], + "responses": {} + } + }, + "/user/login": { + "post": { + "description": "A Cookie will be set if login successfully", + "consumes": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Login by account and password", + "parameters": [ + { + "description": "body", + "name": "loginBody", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handler.loginBody" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/user/me": { + "get": { + "description": "If correctly logined with cookie, return current user", + "tags": [ + "user" + ], + "summary": "Get current user", + "responses": { + "200": { + "description": "OK" + }, + "401": { + "description": "Unauthorized" + } + } + } + }, + "/user/stream": { + "get": { + "description": "Stream", + "consumes": [ + "text/event-stream" + ], + "produces": [ + "text/event-stream" + ], + "tags": [ + "user" + ], + "summary": "Stream", + "responses": { + "200": { + "description": "data: {message}", + "schema": { + "type": "string" + } + } + } + } + } + }, + "definitions": { + "handler.PostSubmissionBody": { + "type": "object" + }, + "handler.loginBody": { + "type": "object", + "properties": { + "account": { + "type": "string", + "example": "admin" + }, + "password": { + "type": "string", + "example": "admin" + } + } + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "", + Host: "", + BasePath: "", + Schemes: []string{}, + Title: "", + Description: "", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/src/application/server/docs/swagger.json b/src/application/server/docs/swagger.json new file mode 100644 index 0000000..ebe2209 --- /dev/null +++ b/src/application/server/docs/swagger.json @@ -0,0 +1,256 @@ +{ + "swagger": "2.0", + "info": { + "contact": {} + }, + "paths": { + "/problem": { + "get": { + "description": "Get problem list", + "consumes": [ + "application/json" + ], + "tags": [ + "problem" + ], + "summary": "Get problem list", + "responses": { + "200": { + "description": "OK" + } + } + }, + "put": { + "description": "Put a problem", + "consumes": [ + "application/json" + ], + "tags": [ + "problem" + ], + "summary": "Put a problem", + "responses": {} + } + }, + "/problem/{slug}": { + "get": { + "description": "Get a problem", + "consumes": [ + "application/json" + ], + "tags": [ + "problem" + ], + "summary": "Get a problem", + "responses": { + "200": { + "description": "OK" + } + } + }, + "delete": { + "description": "Delete a problem", + "consumes": [ + "application/json" + ], + "tags": [ + "problem" + ], + "summary": "Delete a problem", + "responses": {} + } + }, + "/problem/{slug}/check": { + "get": { + "description": "Check problem slug", + "consumes": [ + "application/json" + ], + "tags": [ + "problem" + ], + "summary": "Check problem slug", + "parameters": [ + { + "type": "string", + "description": "problem slug", + "name": "slug", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/problem/{slug}/package": { + "put": { + "description": "Put problem package", + "consumes": [ + "application/json" + ], + "tags": [ + "problem" + ], + "summary": "Put problem package", + "parameters": [ + { + "type": "string", + "description": "problem slug", + "name": "slug", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/problem/{slug}/submission": { + "post": { + "description": "Post submission", + "consumes": [ + "application/json" + ], + "tags": [ + "problem" + ], + "summary": "Post submission", + "parameters": [ + { + "type": "string", + "description": "problem slug", + "name": "slug", + "in": "path", + "required": true + }, + { + "description": "judge request", + "name": "judgeRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handler.PostSubmissionBody" + } + } + ], + "responses": {} + } + }, + "/submission": { + "get": { + "description": "Get submission list", + "consumes": [ + "application/json" + ], + "tags": [ + "submission" + ], + "summary": "Get submission list", + "parameters": [ + { + "type": "integer", + "description": "limit", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "offset", + "name": "offset", + "in": "query" + } + ], + "responses": {} + } + }, + "/user/login": { + "post": { + "description": "A Cookie will be set if login successfully", + "consumes": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Login by account and password", + "parameters": [ + { + "description": "body", + "name": "loginBody", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handler.loginBody" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/user/me": { + "get": { + "description": "If correctly logined with cookie, return current user", + "tags": [ + "user" + ], + "summary": "Get current user", + "responses": { + "200": { + "description": "OK" + }, + "401": { + "description": "Unauthorized" + } + } + } + }, + "/user/stream": { + "get": { + "description": "Stream", + "consumes": [ + "text/event-stream" + ], + "produces": [ + "text/event-stream" + ], + "tags": [ + "user" + ], + "summary": "Stream", + "responses": { + "200": { + "description": "data: {message}", + "schema": { + "type": "string" + } + } + } + } + } + }, + "definitions": { + "handler.PostSubmissionBody": { + "type": "object" + }, + "handler.loginBody": { + "type": "object", + "properties": { + "account": { + "type": "string", + "example": "admin" + }, + "password": { + "type": "string", + "example": "admin" + } + } + } + } +} \ No newline at end of file diff --git a/src/application/server/docs/swagger.yaml b/src/application/server/docs/swagger.yaml new file mode 100644 index 0000000..8cdeea2 --- /dev/null +++ b/src/application/server/docs/swagger.yaml @@ -0,0 +1,169 @@ +definitions: + handler.PostSubmissionBody: + type: object + handler.loginBody: + properties: + account: + example: admin + type: string + password: + example: admin + type: string + type: object +info: + contact: {} +paths: + /problem: + get: + consumes: + - application/json + description: Get problem list + responses: + "200": + description: OK + summary: Get problem list + tags: + - problem + put: + consumes: + - application/json + description: Put a problem + responses: {} + summary: Put a problem + tags: + - problem + /problem/{slug}: + delete: + consumes: + - application/json + description: Delete a problem + responses: {} + summary: Delete a problem + tags: + - problem + get: + consumes: + - application/json + description: Get a problem + responses: + "200": + description: OK + summary: Get a problem + tags: + - problem + /problem/{slug}/check: + get: + consumes: + - application/json + description: Check problem slug + parameters: + - description: problem slug + in: path + name: slug + required: true + type: string + responses: + "200": + description: OK + summary: Check problem slug + tags: + - problem + /problem/{slug}/package: + put: + consumes: + - application/json + description: Put problem package + parameters: + - description: problem slug + in: path + name: slug + required: true + type: string + responses: {} + summary: Put problem package + tags: + - problem + /problem/{slug}/submission: + post: + consumes: + - application/json + description: Post submission + parameters: + - description: problem slug + in: path + name: slug + required: true + type: string + - description: judge request + in: body + name: judgeRequest + required: true + schema: + $ref: '#/definitions/handler.PostSubmissionBody' + responses: {} + summary: Post submission + tags: + - problem + /submission: + get: + consumes: + - application/json + description: Get submission list + parameters: + - description: limit + in: query + name: limit + type: integer + - description: offset + in: query + name: offset + type: integer + responses: {} + summary: Get submission list + tags: + - submission + /user/login: + post: + consumes: + - application/json + description: A Cookie will be set if login successfully + parameters: + - description: body + in: body + name: loginBody + required: true + schema: + $ref: '#/definitions/handler.loginBody' + responses: + "200": + description: OK + summary: Login by account and password + tags: + - user + /user/me: + get: + description: If correctly logined with cookie, return current user + responses: + "200": + description: OK + "401": + description: Unauthorized + summary: Get current user + tags: + - user + /user/stream: + get: + consumes: + - text/event-stream + description: Stream + produces: + - text/event-stream + responses: + "200": + description: 'data: {message}' + schema: + type: string + summary: Stream + tags: + - user +swagger: "2.0" diff --git a/src/application/server/handler/problem.go b/src/application/server/handler/problem.go index 94a93b7..d55ca12 100644 --- a/src/application/server/handler/problem.go +++ b/src/application/server/handler/problem.go @@ -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") @@ -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 { @@ -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") @@ -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") @@ -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") @@ -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"` From f2ffae2e5b8047e1f41066a478308b09578e46c9 Mon Sep 17 00:00:00 2001 From: sirius1y Date: Fri, 22 Mar 2024 10:47:49 +0800 Subject: [PATCH 2/2] Fix:#34 Add swagger comments in problem.go --- src/application/server/docs/docs.go | 285 ----------------------- src/application/server/docs/swagger.json | 256 -------------------- src/application/server/docs/swagger.yaml | 169 -------------- 3 files changed, 710 deletions(-) delete mode 100644 src/application/server/docs/docs.go delete mode 100644 src/application/server/docs/swagger.json delete mode 100644 src/application/server/docs/swagger.yaml diff --git a/src/application/server/docs/docs.go b/src/application/server/docs/docs.go deleted file mode 100644 index 296ee1d..0000000 --- a/src/application/server/docs/docs.go +++ /dev/null @@ -1,285 +0,0 @@ -// Package docs Code generated by swaggo/swag. DO NOT EDIT -package docs - -import "github.com/swaggo/swag" - -const docTemplate = `{ - "schemes": {{ marshal .Schemes }}, - "swagger": "2.0", - "info": { - "description": "{{escape .Description}}", - "title": "{{.Title}}", - "contact": {}, - "version": "{{.Version}}" - }, - "host": "{{.Host}}", - "basePath": "{{.BasePath}}", - "paths": { - "/problem": { - "get": { - "description": "Get problem list", - "consumes": [ - "application/json" - ], - "tags": [ - "problem" - ], - "summary": "Get problem list", - "responses": { - "200": { - "description": "OK" - } - } - }, - "put": { - "description": "Put a problem", - "consumes": [ - "application/json" - ], - "tags": [ - "problem" - ], - "summary": "Put a problem", - "responses": {} - } - }, - "/problem/{slug}": { - "get": { - "description": "Get a problem", - "consumes": [ - "application/json" - ], - "tags": [ - "problem" - ], - "summary": "Get a problem", - "responses": { - "200": { - "description": "OK" - } - } - }, - "delete": { - "description": "Delete a problem", - "consumes": [ - "application/json" - ], - "tags": [ - "problem" - ], - "summary": "Delete a problem", - "responses": {} - } - }, - "/problem/{slug}/check": { - "get": { - "description": "Check problem slug", - "consumes": [ - "application/json" - ], - "tags": [ - "problem" - ], - "summary": "Check problem slug", - "parameters": [ - { - "type": "string", - "description": "problem slug", - "name": "slug", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - } - } - } - }, - "/problem/{slug}/package": { - "put": { - "description": "Put problem package", - "consumes": [ - "application/json" - ], - "tags": [ - "problem" - ], - "summary": "Put problem package", - "parameters": [ - { - "type": "string", - "description": "problem slug", - "name": "slug", - "in": "path", - "required": true - } - ], - "responses": {} - } - }, - "/problem/{slug}/submission": { - "post": { - "description": "Post submission", - "consumes": [ - "application/json" - ], - "tags": [ - "problem" - ], - "summary": "Post submission", - "parameters": [ - { - "type": "string", - "description": "problem slug", - "name": "slug", - "in": "path", - "required": true - }, - { - "description": "judge request", - "name": "judgeRequest", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handler.PostSubmissionBody" - } - } - ], - "responses": {} - } - }, - "/submission": { - "get": { - "description": "Get submission list", - "consumes": [ - "application/json" - ], - "tags": [ - "submission" - ], - "summary": "Get submission list", - "parameters": [ - { - "type": "integer", - "description": "limit", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "description": "offset", - "name": "offset", - "in": "query" - } - ], - "responses": {} - } - }, - "/user/login": { - "post": { - "description": "A Cookie will be set if login successfully", - "consumes": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Login by account and password", - "parameters": [ - { - "description": "body", - "name": "loginBody", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handler.loginBody" - } - } - ], - "responses": { - "200": { - "description": "OK" - } - } - } - }, - "/user/me": { - "get": { - "description": "If correctly logined with cookie, return current user", - "tags": [ - "user" - ], - "summary": "Get current user", - "responses": { - "200": { - "description": "OK" - }, - "401": { - "description": "Unauthorized" - } - } - } - }, - "/user/stream": { - "get": { - "description": "Stream", - "consumes": [ - "text/event-stream" - ], - "produces": [ - "text/event-stream" - ], - "tags": [ - "user" - ], - "summary": "Stream", - "responses": { - "200": { - "description": "data: {message}", - "schema": { - "type": "string" - } - } - } - } - } - }, - "definitions": { - "handler.PostSubmissionBody": { - "type": "object" - }, - "handler.loginBody": { - "type": "object", - "properties": { - "account": { - "type": "string", - "example": "admin" - }, - "password": { - "type": "string", - "example": "admin" - } - } - } - } -}` - -// SwaggerInfo holds exported Swagger Info so clients can modify it -var SwaggerInfo = &swag.Spec{ - Version: "", - Host: "", - BasePath: "", - Schemes: []string{}, - Title: "", - Description: "", - InfoInstanceName: "swagger", - SwaggerTemplate: docTemplate, - LeftDelim: "{{", - RightDelim: "}}", -} - -func init() { - swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) -} diff --git a/src/application/server/docs/swagger.json b/src/application/server/docs/swagger.json deleted file mode 100644 index ebe2209..0000000 --- a/src/application/server/docs/swagger.json +++ /dev/null @@ -1,256 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "contact": {} - }, - "paths": { - "/problem": { - "get": { - "description": "Get problem list", - "consumes": [ - "application/json" - ], - "tags": [ - "problem" - ], - "summary": "Get problem list", - "responses": { - "200": { - "description": "OK" - } - } - }, - "put": { - "description": "Put a problem", - "consumes": [ - "application/json" - ], - "tags": [ - "problem" - ], - "summary": "Put a problem", - "responses": {} - } - }, - "/problem/{slug}": { - "get": { - "description": "Get a problem", - "consumes": [ - "application/json" - ], - "tags": [ - "problem" - ], - "summary": "Get a problem", - "responses": { - "200": { - "description": "OK" - } - } - }, - "delete": { - "description": "Delete a problem", - "consumes": [ - "application/json" - ], - "tags": [ - "problem" - ], - "summary": "Delete a problem", - "responses": {} - } - }, - "/problem/{slug}/check": { - "get": { - "description": "Check problem slug", - "consumes": [ - "application/json" - ], - "tags": [ - "problem" - ], - "summary": "Check problem slug", - "parameters": [ - { - "type": "string", - "description": "problem slug", - "name": "slug", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - } - } - } - }, - "/problem/{slug}/package": { - "put": { - "description": "Put problem package", - "consumes": [ - "application/json" - ], - "tags": [ - "problem" - ], - "summary": "Put problem package", - "parameters": [ - { - "type": "string", - "description": "problem slug", - "name": "slug", - "in": "path", - "required": true - } - ], - "responses": {} - } - }, - "/problem/{slug}/submission": { - "post": { - "description": "Post submission", - "consumes": [ - "application/json" - ], - "tags": [ - "problem" - ], - "summary": "Post submission", - "parameters": [ - { - "type": "string", - "description": "problem slug", - "name": "slug", - "in": "path", - "required": true - }, - { - "description": "judge request", - "name": "judgeRequest", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handler.PostSubmissionBody" - } - } - ], - "responses": {} - } - }, - "/submission": { - "get": { - "description": "Get submission list", - "consumes": [ - "application/json" - ], - "tags": [ - "submission" - ], - "summary": "Get submission list", - "parameters": [ - { - "type": "integer", - "description": "limit", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "description": "offset", - "name": "offset", - "in": "query" - } - ], - "responses": {} - } - }, - "/user/login": { - "post": { - "description": "A Cookie will be set if login successfully", - "consumes": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Login by account and password", - "parameters": [ - { - "description": "body", - "name": "loginBody", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handler.loginBody" - } - } - ], - "responses": { - "200": { - "description": "OK" - } - } - } - }, - "/user/me": { - "get": { - "description": "If correctly logined with cookie, return current user", - "tags": [ - "user" - ], - "summary": "Get current user", - "responses": { - "200": { - "description": "OK" - }, - "401": { - "description": "Unauthorized" - } - } - } - }, - "/user/stream": { - "get": { - "description": "Stream", - "consumes": [ - "text/event-stream" - ], - "produces": [ - "text/event-stream" - ], - "tags": [ - "user" - ], - "summary": "Stream", - "responses": { - "200": { - "description": "data: {message}", - "schema": { - "type": "string" - } - } - } - } - } - }, - "definitions": { - "handler.PostSubmissionBody": { - "type": "object" - }, - "handler.loginBody": { - "type": "object", - "properties": { - "account": { - "type": "string", - "example": "admin" - }, - "password": { - "type": "string", - "example": "admin" - } - } - } - } -} \ No newline at end of file diff --git a/src/application/server/docs/swagger.yaml b/src/application/server/docs/swagger.yaml deleted file mode 100644 index 8cdeea2..0000000 --- a/src/application/server/docs/swagger.yaml +++ /dev/null @@ -1,169 +0,0 @@ -definitions: - handler.PostSubmissionBody: - type: object - handler.loginBody: - properties: - account: - example: admin - type: string - password: - example: admin - type: string - type: object -info: - contact: {} -paths: - /problem: - get: - consumes: - - application/json - description: Get problem list - responses: - "200": - description: OK - summary: Get problem list - tags: - - problem - put: - consumes: - - application/json - description: Put a problem - responses: {} - summary: Put a problem - tags: - - problem - /problem/{slug}: - delete: - consumes: - - application/json - description: Delete a problem - responses: {} - summary: Delete a problem - tags: - - problem - get: - consumes: - - application/json - description: Get a problem - responses: - "200": - description: OK - summary: Get a problem - tags: - - problem - /problem/{slug}/check: - get: - consumes: - - application/json - description: Check problem slug - parameters: - - description: problem slug - in: path - name: slug - required: true - type: string - responses: - "200": - description: OK - summary: Check problem slug - tags: - - problem - /problem/{slug}/package: - put: - consumes: - - application/json - description: Put problem package - parameters: - - description: problem slug - in: path - name: slug - required: true - type: string - responses: {} - summary: Put problem package - tags: - - problem - /problem/{slug}/submission: - post: - consumes: - - application/json - description: Post submission - parameters: - - description: problem slug - in: path - name: slug - required: true - type: string - - description: judge request - in: body - name: judgeRequest - required: true - schema: - $ref: '#/definitions/handler.PostSubmissionBody' - responses: {} - summary: Post submission - tags: - - problem - /submission: - get: - consumes: - - application/json - description: Get submission list - parameters: - - description: limit - in: query - name: limit - type: integer - - description: offset - in: query - name: offset - type: integer - responses: {} - summary: Get submission list - tags: - - submission - /user/login: - post: - consumes: - - application/json - description: A Cookie will be set if login successfully - parameters: - - description: body - in: body - name: loginBody - required: true - schema: - $ref: '#/definitions/handler.loginBody' - responses: - "200": - description: OK - summary: Login by account and password - tags: - - user - /user/me: - get: - description: If correctly logined with cookie, return current user - responses: - "200": - description: OK - "401": - description: Unauthorized - summary: Get current user - tags: - - user - /user/stream: - get: - consumes: - - text/event-stream - description: Stream - produces: - - text/event-stream - responses: - "200": - description: 'data: {message}' - schema: - type: string - summary: Stream - tags: - - user -swagger: "2.0"