From 5262356b5e7f4a68ee08e5bce80e974bb7e4ab11 Mon Sep 17 00:00:00 2001 From: ErfanTech Date: Wed, 22 May 2024 01:40:16 +0330 Subject: [PATCH] fix(param): add json tag to fields --- docs/docs.go | 88 +++++++++++------------- docs/swagger.json | 88 +++++++++++------------- docs/swagger.yaml | 51 +++++++------- param/admin/admin/login.go | 18 ++--- param/admin/admin/register.go | 2 +- param/admin/kind_box_req/get_all.go | 4 +- param/benefactor/kind_box_req/get.go | 2 +- param/benefactor/kind_box_req/get_all.go | 2 +- param/pagination.go | 6 +- 9 files changed, 122 insertions(+), 139 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index 4217316..8e70423 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -796,7 +796,7 @@ const docTemplate = `{ "adminkindboxreqparam.KindBoxReqGetAllResponse": { "type": "object", "properties": { - "allKindBoxReq": { + "all_kind_box_req": { "type": "array", "items": { "$ref": "#/definitions/entity.KindBoxReq" @@ -865,31 +865,52 @@ const docTemplate = `{ "type": "object", "properties": { "description": { - "type": "string" + "type": "string", + "example": "This is a description" }, "email": { - "type": "string" + "type": "string", + "example": "example@gmail.com" }, "first_name": { - "type": "string" + "type": "string", + "example": "John" }, "gender": { - "$ref": "#/definitions/entity.Gender" + "allOf": [ + { + "$ref": "#/definitions/entity.Gender" + } + ], + "example": 1 }, "id": { - "type": "integer" + "type": "integer", + "example": 1 }, "last_name": { - "type": "string" + "type": "string", + "example": "Doe" }, "phone_number": { - "type": "string" + "type": "string", + "example": "09123456789" }, "role": { - "$ref": "#/definitions/entity.AdminRole" + "allOf": [ + { + "$ref": "#/definitions/entity.AdminRole" + } + ], + "example": 2 }, "status": { - "$ref": "#/definitions/entity.AdminStatus" + "allOf": [ + { + "$ref": "#/definitions/entity.AdminStatus" + } + ], + "example": 1 } } }, @@ -1157,38 +1178,8 @@ const docTemplate = `{ "benefactorkindboxreqparam.KindBoxReqGetResponse": { "type": "object", "properties": { - "benefactorID": { - "type": "integer" - }, - "countAccepted": { - "type": "integer" - }, - "countRequested": { - "type": "integer" - }, - "deliverAddressID": { - "type": "integer" - }, - "deliverReferDate": { - "type": "string" - }, - "deliveredAt": { - "type": "string" - }, - "description": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "kindBoxType": { - "$ref": "#/definitions/entity.KindBoxType" - }, - "senderAgentID": { - "type": "integer" - }, - "status": { - "$ref": "#/definitions/entity.KindBoxReqStatus" + "kind_box_req": { + "$ref": "#/definitions/entity.KindBoxReq" } } }, @@ -1407,14 +1398,17 @@ const docTemplate = `{ "param.PaginationResponse": { "type": "object", "properties": { - "pageNumber": { - "type": "integer" + "page_number": { + "type": "integer", + "example": 1 }, - "pageSize": { - "type": "integer" + "page_size": { + "type": "integer", + "example": 10 }, "total": { - "type": "integer" + "type": "integer", + "example": 100 } } } diff --git a/docs/swagger.json b/docs/swagger.json index 33bf56e..31dc8f9 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -785,7 +785,7 @@ "adminkindboxreqparam.KindBoxReqGetAllResponse": { "type": "object", "properties": { - "allKindBoxReq": { + "all_kind_box_req": { "type": "array", "items": { "$ref": "#/definitions/entity.KindBoxReq" @@ -854,31 +854,52 @@ "type": "object", "properties": { "description": { - "type": "string" + "type": "string", + "example": "This is a description" }, "email": { - "type": "string" + "type": "string", + "example": "example@gmail.com" }, "first_name": { - "type": "string" + "type": "string", + "example": "John" }, "gender": { - "$ref": "#/definitions/entity.Gender" + "allOf": [ + { + "$ref": "#/definitions/entity.Gender" + } + ], + "example": 1 }, "id": { - "type": "integer" + "type": "integer", + "example": 1 }, "last_name": { - "type": "string" + "type": "string", + "example": "Doe" }, "phone_number": { - "type": "string" + "type": "string", + "example": "09123456789" }, "role": { - "$ref": "#/definitions/entity.AdminRole" + "allOf": [ + { + "$ref": "#/definitions/entity.AdminRole" + } + ], + "example": 2 }, "status": { - "$ref": "#/definitions/entity.AdminStatus" + "allOf": [ + { + "$ref": "#/definitions/entity.AdminStatus" + } + ], + "example": 1 } } }, @@ -1146,38 +1167,8 @@ "benefactorkindboxreqparam.KindBoxReqGetResponse": { "type": "object", "properties": { - "benefactorID": { - "type": "integer" - }, - "countAccepted": { - "type": "integer" - }, - "countRequested": { - "type": "integer" - }, - "deliverAddressID": { - "type": "integer" - }, - "deliverReferDate": { - "type": "string" - }, - "deliveredAt": { - "type": "string" - }, - "description": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "kindBoxType": { - "$ref": "#/definitions/entity.KindBoxType" - }, - "senderAgentID": { - "type": "integer" - }, - "status": { - "$ref": "#/definitions/entity.KindBoxReqStatus" + "kind_box_req": { + "$ref": "#/definitions/entity.KindBoxReq" } } }, @@ -1396,14 +1387,17 @@ "param.PaginationResponse": { "type": "object", "properties": { - "pageNumber": { - "type": "integer" + "page_number": { + "type": "integer", + "example": 1 }, - "pageSize": { - "type": "integer" + "page_size": { + "type": "integer", + "example": 10 }, "total": { - "type": "integer" + "type": "integer", + "example": 100 } } } diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 94ae40a..d90fec9 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -73,7 +73,7 @@ definitions: type: object adminkindboxreqparam.KindBoxReqGetAllResponse: properties: - allKindBoxReq: + all_kind_box_req: items: $ref: '#/definitions/entity.KindBoxReq' type: array @@ -118,23 +118,35 @@ definitions: adminserviceparam.AdminInfo: properties: description: + example: This is a description type: string email: + example: example@gmail.com type: string first_name: + example: John type: string gender: - $ref: '#/definitions/entity.Gender' + allOf: + - $ref: '#/definitions/entity.Gender' + example: 1 id: + example: 1 type: integer last_name: + example: Doe type: string phone_number: + example: "09123456789" type: string role: - $ref: '#/definitions/entity.AdminRole' + allOf: + - $ref: '#/definitions/entity.AdminRole' + example: 2 status: - $ref: '#/definitions/entity.AdminStatus' + allOf: + - $ref: '#/definitions/entity.AdminStatus' + example: 1 type: object adminserviceparam.LoginWithPhoneNumberRequest: properties: @@ -309,28 +321,8 @@ definitions: type: object benefactorkindboxreqparam.KindBoxReqGetResponse: properties: - benefactorID: - type: integer - countAccepted: - type: integer - countRequested: - type: integer - deliverAddressID: - type: integer - deliverReferDate: - type: string - deliveredAt: - type: string - description: - type: string - id: - type: integer - kindBoxType: - $ref: '#/definitions/entity.KindBoxType' - senderAgentID: - type: integer - status: - $ref: '#/definitions/entity.KindBoxReqStatus' + kind_box_req: + $ref: '#/definitions/entity.KindBoxReq' type: object entity.Address: properties: @@ -483,11 +475,14 @@ definitions: type: object param.PaginationResponse: properties: - pageNumber: + page_number: + example: 1 type: integer - pageSize: + page_size: + example: 10 type: integer total: + example: 100 type: integer type: object info: diff --git a/param/admin/admin/login.go b/param/admin/admin/login.go index c6d3015..8c04ee4 100644 --- a/param/admin/admin/login.go +++ b/param/admin/admin/login.go @@ -13,13 +13,13 @@ type LoginWithPhoneNumberResponse struct { } type AdminInfo struct { - ID uint `json:"id"` - FirstName string `json:"first_name"` - LastName string `json:"last_name"` - PhoneNumber string `json:"phone_number"` - Role entity.AdminRole `json:"role"` - Description string `json:"description"` - Email string `json:"email"` - Gender entity.Gender `json:"gender"` - Status entity.AdminStatus `json:"status"` + ID uint `json:"id" example:"1"` + FirstName string `json:"first_name" example:"John"` + LastName string `json:"last_name" example:"Doe"` + PhoneNumber string `json:"phone_number" example:"09123456789"` + Role entity.AdminRole `json:"role" example:"2"` + Description string `json:"description" example:"This is a description"` + Email string `json:"email" example:"example@gmail.com"` + Gender entity.Gender `json:"gender" example:"1"` + Status entity.AdminStatus `json:"status" example:"1"` } diff --git a/param/admin/admin/register.go b/param/admin/admin/register.go index f77b9ab..5225b44 100644 --- a/param/admin/admin/register.go +++ b/param/admin/admin/register.go @@ -15,5 +15,5 @@ type RegisterRequest struct { } type RegisterResponse struct { - Admin entity.Admin + Admin entity.Admin `json:"admin"` } diff --git a/param/admin/kind_box_req/get_all.go b/param/admin/kind_box_req/get_all.go index 27d4cdc..8a95b05 100644 --- a/param/admin/kind_box_req/get_all.go +++ b/param/admin/kind_box_req/get_all.go @@ -8,6 +8,6 @@ import ( type KindBoxReqGetAllRequest struct{} type KindBoxReqGetAllResponse struct { - AllKindBoxReq []entity.KindBoxReq - Pagination paginationparam.PaginationResponse + AllKindBoxReq []entity.KindBoxReq `json:"all_kind_box_req"` + Pagination paginationparam.PaginationResponse `json:"pagination"` } diff --git a/param/benefactor/kind_box_req/get.go b/param/benefactor/kind_box_req/get.go index 14fbc3c..173183e 100644 --- a/param/benefactor/kind_box_req/get.go +++ b/param/benefactor/kind_box_req/get.go @@ -8,5 +8,5 @@ type KindBoxReqGetRequest struct { } type KindBoxReqGetResponse struct { - entity.KindBoxReq + entity.KindBoxReq `json:"kind_box_req"` } diff --git a/param/benefactor/kind_box_req/get_all.go b/param/benefactor/kind_box_req/get_all.go index 1cfdea7..c80ab34 100644 --- a/param/benefactor/kind_box_req/get_all.go +++ b/param/benefactor/kind_box_req/get_all.go @@ -7,5 +7,5 @@ type KindBoxReqGetAllRequest struct { } type KindBoxReqGetAllResponse struct { - AllKindBoxReq []entity.KindBoxReq + AllKindBoxReq []entity.KindBoxReq `json:"all_kind_box_req"` } diff --git a/param/pagination.go b/param/pagination.go index 8dcddcd..5657036 100644 --- a/param/pagination.go +++ b/param/pagination.go @@ -11,9 +11,9 @@ type PaginationRequest struct { } type PaginationResponse struct { - PageSize uint - PageNumber uint - Total uint + PageSize uint `json:"page_size" example:"10"` + PageNumber uint `json:"page_number" example:"1"` + Total uint `json:"total" example:"100"` } func (p *PaginationRequest) GetPageNumber() uint {