Skip to content

Commit

Permalink
feat: add validate for CourseGroupSearchV3Request
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYiJun committed Sep 28, 2023
1 parent 8306842 commit 0abe361
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
9 changes: 8 additions & 1 deletion internal/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -890,19 +890,26 @@ const docTemplate = `{
"summary": "search course group",
"parameters": [
{
"minimum": 0,
"type": "integer",
"example": 0,
"name": "page",
"in": "query"
},
{
"maximum": 100,
"minimum": 0,
"type": "integer",
"example": 10,
"name": "page_size",
"in": "query"
},
{
"type": "string",
"example": "计算机",
"name": "query",
"in": "query"
"in": "query",
"required": true
}
],
"responses": {
Expand Down
9 changes: 8 additions & 1 deletion internal/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -887,19 +887,26 @@
"summary": "search course group",
"parameters": [
{
"minimum": 0,
"type": "integer",
"example": 0,
"name": "page",
"in": "query"
},
{
"maximum": 100,
"minimum": 0,
"type": "integer",
"example": 10,
"name": "page_size",
"in": "query"
},
{
"type": "string",
"example": "计算机",
"name": "query",
"in": "query"
"in": "query",
"required": true
}
],
"responses": {
Expand Down
13 changes: 10 additions & 3 deletions internal/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1136,14 +1136,21 @@ paths:
- application/json
description: search course group, no courses
parameters:
- in: query
- example: 0
in: query
minimum: 0
name: page
type: integer
- in: query
- example: 10
in: query
maximum: 100
minimum: 0
name: page_size
type: integer
- in: query
- example: 计算机
in: query
name: query
required: true
type: string
produces:
- application/json
Expand Down
6 changes: 3 additions & 3 deletions internal/schema/course_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ func (r *CourseGroupHashV1Response) FromModel(hash string) *CourseGroupHashV1Res
/* V3 */

type CourseGroupSearchV3Request struct {
Query string `json:"query" form:"query" query:"query"`
Page int `json:"page" form:"page" query:"page"`
PageSize int `json:"page_size" form:"page_size" query:"page_size"`
Query string `json:"query" form:"query" query:"query" validate:"required" example:"计算机"`
Page int `json:"page" form:"page" query:"page" validate:"min=0" example:"0"`
PageSize int `json:"page_size" form:"page_size" query:"page_size" validate:"min=0,max=100" example:"10"`
}

type CourseGroupV3Response struct {
Expand Down

0 comments on commit 0abe361

Please sign in to comment.