diff --git a/core/controllers/FeedbackController.go b/core/controllers/FeedbackController.go index 81a38a3..7e5fb88 100644 --- a/core/controllers/FeedbackController.go +++ b/core/controllers/FeedbackController.go @@ -3,6 +3,7 @@ package controllers import ( "TSS-microservices/common" feedback_form "TSS-microservices/core/http/requests/feedback-form" + feedback_response "TSS-microservices/core/http/responses/feedback" "TSS-microservices/core/models" "TSS-microservices/core/repositories" "github.com/gin-gonic/gin" @@ -122,18 +123,7 @@ func (controller *FeedbackController) GetById(context *gin.Context) { // type: string // responses: // 200: -// description: list of feedback -// schema: -// type: object -// properties: -// data: -// type: array -// items: -// "$ref": "#/definitions/FeedbackModel" -// limit: -// type: integer -// offset: -// type: integer +// "$ref": "#/responses/GetManyResponse" func (controller *FeedbackController) GetMany(context *gin.Context) { limit, _ := strconv.Atoi(context.DefaultQuery("limit", "10")) @@ -159,5 +149,5 @@ func (controller *FeedbackController) GetMany(context *gin.Context) { return } - context.JSON(http.StatusOK, gin.H{"data": feedback, "limit": limit, "offset": offset}) + context.JSON(http.StatusOK, feedback_response.GetManyResponse{Body: feedback_response.GetManyResponseBody{Limit: limit, Offset: offset, Data: feedback}}.Body) } diff --git a/core/controllers/HermesController.go b/core/controllers/HermesController.go index 9368019..736b873 100644 --- a/core/controllers/HermesController.go +++ b/core/controllers/HermesController.go @@ -57,7 +57,7 @@ func (controller *HermesController) SendMail(context *gin.Context) { mailTemplate.Subject = input.Subject } - message, err := controller.handleMailMessage(mailTemplate, input.PlaceHolder) + message, err := controller.handleMailMessage(mailTemplate, input.Placeholder) if err != nil { context.JSON(common.ErrorHandlerHttpResponse(err)) diff --git a/core/http/requests/hermes-forms/SendMailFormRequest.go b/core/http/requests/hermes-forms/SendMailFormRequest.go index 364d40f..5bde8f4 100644 --- a/core/http/requests/hermes-forms/SendMailFormRequest.go +++ b/core/http/requests/hermes-forms/SendMailFormRequest.go @@ -2,11 +2,22 @@ package hermes_forms type SendMailFormRequest struct { // required: true + // type: string Code string `json:"code" binding:"required"` // required: true - Recipients []string `json:"recipients" binding:"required"` - PlaceHolder map[string]string `json:"placeholder" binding:"required"` - Subject string `json:"subject"` + // type: array + // items: + // type: string + // example: ["email1@gmal.com", "email2@gmail.com"] + Recipients []string `json:"recipients" binding:"required"` + // required: false + // type: object + Placeholder map[string]string `json:"placeholder" binding:"required"` + // required: false + // type: string + // extensions: + // x-note: All key must be capital the first character + Subject string `json:"subject"` } // swagger:parameters SendMail diff --git a/core/http/responses/feedback/GetManyResponse.go b/core/http/responses/feedback/GetManyResponse.go new file mode 100644 index 0000000..e20020c --- /dev/null +++ b/core/http/responses/feedback/GetManyResponse.go @@ -0,0 +1,15 @@ +package feedback + +import "TSS-microservices/core/models" + +// swagger:response GetManyResponse +type GetManyResponse struct { + // in: body + Body GetManyResponseBody `json:"body"` +} + +type GetManyResponseBody struct { + Limit int `json:"limit"` + Offset int `json:"offset"` + Data []models.Feedback `json:"data"` +} diff --git a/docs/swagger.json b/docs/swagger.json index 11a6001..ccc7971 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -64,24 +64,7 @@ ], "responses": { "200": { - "description": "list of feedback", - "schema": { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/FeedbackModel" - } - }, - "limit": { - "type": "integer" - }, - "offset": { - "type": "integer" - } - } - } + "$ref": "#/responses/GetManyResponse" } } }, @@ -417,6 +400,29 @@ "x-go-name": "Feedback", "x-go-package": "TSS-microservices/core/models" }, + "GetManyResponseBody": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/FeedbackModel" + }, + "x-go-name": "Data" + }, + "limit": { + "type": "integer", + "format": "int64", + "x-go-name": "Limit" + }, + "offset": { + "type": "integer", + "format": "int64", + "x-go-name": "Offset" + } + }, + "x-go-package": "TSS-microservices/core/http/responses/feedback" + }, "NullTime": { "description": "NullTime implements the [Scanner] interface so\nit can be used as a scan destination, similar to [NullString].", "type": "object", @@ -462,18 +468,23 @@ "additionalProperties": { "type": "string" }, - "x-go-name": "PlaceHolder" + "x-go-name": "Placeholder" }, "recipients": { "type": "array", "items": { "type": "string" }, - "x-go-name": "Recipients" + "x-go-name": "Recipients", + "example": [ + "email1@gmal.com", + "email2@gmail.com" + ] }, "subject": { "type": "string", - "x-go-name": "Subject" + "x-go-name": "Subject", + "x-note": "All key must be capital the first character" } }, "x-go-package": "TSS-microservices/core/http/requests/hermes-forms" @@ -532,6 +543,12 @@ } }, "responses": { + "GetManyResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/GetManyResponseBody" + } + }, "ValidationError": { "description": "A ValidationError is an error that is used when the required input fails validation.", "schema": {