diff --git a/docs/docs.go b/docs/docs.go index 24693e47..14a36c1e 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -5574,10 +5574,15 @@ const docTemplate = `{ }, "schema.AnswerAddReq": { "type": "object", + "required": [ + "content" + ], "properties": { "content": { "description": "content", - "type": "string" + "type": "string", + "maxLength": 65535, + "minLength": 6 }, "html": { "description": "html", @@ -5591,10 +5596,15 @@ const docTemplate = `{ }, "schema.AnswerUpdateReq": { "type": "object", + "required": [ + "content" + ], "properties": { "content": { "description": "content", - "type": "string" + "type": "string", + "maxLength": 65535, + "minLength": 6 }, "edit_summary": { "description": "edit_summary", diff --git a/docs/swagger.json b/docs/swagger.json index fb2f297b..55e01da1 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -5562,10 +5562,15 @@ }, "schema.AnswerAddReq": { "type": "object", + "required": [ + "content" + ], "properties": { "content": { "description": "content", - "type": "string" + "type": "string", + "maxLength": 65535, + "minLength": 6 }, "html": { "description": "html", @@ -5579,10 +5584,15 @@ }, "schema.AnswerUpdateReq": { "type": "object", + "required": [ + "content" + ], "properties": { "content": { "description": "content", - "type": "string" + "type": "string", + "maxLength": 65535, + "minLength": 6 }, "edit_summary": { "description": "edit_summary", diff --git a/docs/swagger.yaml b/docs/swagger.yaml index fef405df..2dd68b72 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -218,6 +218,8 @@ definitions: properties: content: description: content + maxLength: 65535 + minLength: 6 type: string html: description: html @@ -225,11 +227,15 @@ definitions: question_id: description: question_id type: string + required: + - content type: object schema.AnswerUpdateReq: properties: content: description: content + maxLength: 65535 + minLength: 6 type: string edit_summary: description: edit_summary @@ -246,6 +252,8 @@ definitions: title: description: title type: string + required: + - content type: object schema.AvatarInfo: properties: diff --git a/internal/schema/answer_schema.go b/internal/schema/answer_schema.go index 724d9af9..34383eb4 100644 --- a/internal/schema/answer_schema.go +++ b/internal/schema/answer_schema.go @@ -20,10 +20,10 @@ const ( ) type AnswerAddReq struct { - QuestionID string `json:"question_id" ` // question_id - Content string `json:"content" ` // content - HTML string `json:"html" ` // html - UserID string `json:"-" ` // user_id + QuestionID string `json:"question_id" ` // question_id + Content string `validate:"required,gte=6,lte=65535" json:"content" ` // content + HTML string `json:"html" ` // html + UserID string `json:"-" ` // user_id } func (req *AnswerAddReq) Check() (errFields []*validator.FormErrorField, err error) { @@ -32,13 +32,13 @@ func (req *AnswerAddReq) Check() (errFields []*validator.FormErrorField, err err } type AnswerUpdateReq struct { - ID string `json:"id"` // id - QuestionID string `json:"question_id" ` // question_id - UserID string `json:"-" ` // user_id - Title string `json:"title" ` // title - Content string `json:"content"` // content - HTML string `json:"html" ` // html - EditSummary string `validate:"omitempty" json:"edit_summary"` // edit_summary + ID string `json:"id"` // id + QuestionID string `json:"question_id" ` // question_id + UserID string `json:"-" ` // user_id + Title string `json:"title" ` // title + Content string `validate:"required,gte=6,lte=65535" json:"content"` // content + HTML string `json:"html" ` // html + EditSummary string `validate:"omitempty" json:"edit_summary"` // edit_summary NoNeedReview bool `json:"-"` // whether user can edit it CanEdit bool `json:"-"`