fix(param): add json tag to fields

This commit is contained in:
Erfan Mohammadi 2024-05-22 01:40:16 +03:30
parent 53017a31a5
commit 5262356b5e
9 changed files with 122 additions and 139 deletions

View File

@ -796,7 +796,7 @@ const docTemplate = `{
"adminkindboxreqparam.KindBoxReqGetAllResponse": { "adminkindboxreqparam.KindBoxReqGetAllResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"allKindBoxReq": { "all_kind_box_req": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/entity.KindBoxReq" "$ref": "#/definitions/entity.KindBoxReq"
@ -865,32 +865,53 @@ const docTemplate = `{
"type": "object", "type": "object",
"properties": { "properties": {
"description": { "description": {
"type": "string" "type": "string",
"example": "This is a description"
}, },
"email": { "email": {
"type": "string" "type": "string",
"example": "example@gmail.com"
}, },
"first_name": { "first_name": {
"type": "string" "type": "string",
"example": "John"
}, },
"gender": { "gender": {
"allOf": [
{
"$ref": "#/definitions/entity.Gender" "$ref": "#/definitions/entity.Gender"
}
],
"example": 1
}, },
"id": { "id": {
"type": "integer" "type": "integer",
"example": 1
}, },
"last_name": { "last_name": {
"type": "string" "type": "string",
"example": "Doe"
}, },
"phone_number": { "phone_number": {
"type": "string" "type": "string",
"example": "09123456789"
}, },
"role": { "role": {
"allOf": [
{
"$ref": "#/definitions/entity.AdminRole" "$ref": "#/definitions/entity.AdminRole"
}
],
"example": 2
}, },
"status": { "status": {
"allOf": [
{
"$ref": "#/definitions/entity.AdminStatus" "$ref": "#/definitions/entity.AdminStatus"
} }
],
"example": 1
}
} }
}, },
"adminserviceparam.LoginWithPhoneNumberRequest": { "adminserviceparam.LoginWithPhoneNumberRequest": {
@ -1157,38 +1178,8 @@ const docTemplate = `{
"benefactorkindboxreqparam.KindBoxReqGetResponse": { "benefactorkindboxreqparam.KindBoxReqGetResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"benefactorID": { "kind_box_req": {
"type": "integer" "$ref": "#/definitions/entity.KindBoxReq"
},
"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"
} }
} }
}, },
@ -1407,14 +1398,17 @@ const docTemplate = `{
"param.PaginationResponse": { "param.PaginationResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"pageNumber": { "page_number": {
"type": "integer" "type": "integer",
"example": 1
}, },
"pageSize": { "page_size": {
"type": "integer" "type": "integer",
"example": 10
}, },
"total": { "total": {
"type": "integer" "type": "integer",
"example": 100
} }
} }
} }

View File

@ -785,7 +785,7 @@
"adminkindboxreqparam.KindBoxReqGetAllResponse": { "adminkindboxreqparam.KindBoxReqGetAllResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"allKindBoxReq": { "all_kind_box_req": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/entity.KindBoxReq" "$ref": "#/definitions/entity.KindBoxReq"
@ -854,32 +854,53 @@
"type": "object", "type": "object",
"properties": { "properties": {
"description": { "description": {
"type": "string" "type": "string",
"example": "This is a description"
}, },
"email": { "email": {
"type": "string" "type": "string",
"example": "example@gmail.com"
}, },
"first_name": { "first_name": {
"type": "string" "type": "string",
"example": "John"
}, },
"gender": { "gender": {
"allOf": [
{
"$ref": "#/definitions/entity.Gender" "$ref": "#/definitions/entity.Gender"
}
],
"example": 1
}, },
"id": { "id": {
"type": "integer" "type": "integer",
"example": 1
}, },
"last_name": { "last_name": {
"type": "string" "type": "string",
"example": "Doe"
}, },
"phone_number": { "phone_number": {
"type": "string" "type": "string",
"example": "09123456789"
}, },
"role": { "role": {
"allOf": [
{
"$ref": "#/definitions/entity.AdminRole" "$ref": "#/definitions/entity.AdminRole"
}
],
"example": 2
}, },
"status": { "status": {
"allOf": [
{
"$ref": "#/definitions/entity.AdminStatus" "$ref": "#/definitions/entity.AdminStatus"
} }
],
"example": 1
}
} }
}, },
"adminserviceparam.LoginWithPhoneNumberRequest": { "adminserviceparam.LoginWithPhoneNumberRequest": {
@ -1146,38 +1167,8 @@
"benefactorkindboxreqparam.KindBoxReqGetResponse": { "benefactorkindboxreqparam.KindBoxReqGetResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"benefactorID": { "kind_box_req": {
"type": "integer" "$ref": "#/definitions/entity.KindBoxReq"
},
"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"
} }
} }
}, },
@ -1396,14 +1387,17 @@
"param.PaginationResponse": { "param.PaginationResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"pageNumber": { "page_number": {
"type": "integer" "type": "integer",
"example": 1
}, },
"pageSize": { "page_size": {
"type": "integer" "type": "integer",
"example": 10
}, },
"total": { "total": {
"type": "integer" "type": "integer",
"example": 100
} }
} }
} }

View File

@ -73,7 +73,7 @@ definitions:
type: object type: object
adminkindboxreqparam.KindBoxReqGetAllResponse: adminkindboxreqparam.KindBoxReqGetAllResponse:
properties: properties:
allKindBoxReq: all_kind_box_req:
items: items:
$ref: '#/definitions/entity.KindBoxReq' $ref: '#/definitions/entity.KindBoxReq'
type: array type: array
@ -118,23 +118,35 @@ definitions:
adminserviceparam.AdminInfo: adminserviceparam.AdminInfo:
properties: properties:
description: description:
example: This is a description
type: string type: string
email: email:
example: example@gmail.com
type: string type: string
first_name: first_name:
example: John
type: string type: string
gender: gender:
$ref: '#/definitions/entity.Gender' allOf:
- $ref: '#/definitions/entity.Gender'
example: 1
id: id:
example: 1
type: integer type: integer
last_name: last_name:
example: Doe
type: string type: string
phone_number: phone_number:
example: "09123456789"
type: string type: string
role: role:
$ref: '#/definitions/entity.AdminRole' allOf:
- $ref: '#/definitions/entity.AdminRole'
example: 2
status: status:
$ref: '#/definitions/entity.AdminStatus' allOf:
- $ref: '#/definitions/entity.AdminStatus'
example: 1
type: object type: object
adminserviceparam.LoginWithPhoneNumberRequest: adminserviceparam.LoginWithPhoneNumberRequest:
properties: properties:
@ -309,28 +321,8 @@ definitions:
type: object type: object
benefactorkindboxreqparam.KindBoxReqGetResponse: benefactorkindboxreqparam.KindBoxReqGetResponse:
properties: properties:
benefactorID: kind_box_req:
type: integer $ref: '#/definitions/entity.KindBoxReq'
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'
type: object type: object
entity.Address: entity.Address:
properties: properties:
@ -483,11 +475,14 @@ definitions:
type: object type: object
param.PaginationResponse: param.PaginationResponse:
properties: properties:
pageNumber: page_number:
example: 1
type: integer type: integer
pageSize: page_size:
example: 10
type: integer type: integer
total: total:
example: 100
type: integer type: integer
type: object type: object
info: info:

View File

@ -13,13 +13,13 @@ type LoginWithPhoneNumberResponse struct {
} }
type AdminInfo struct { type AdminInfo struct {
ID uint `json:"id"` ID uint `json:"id" example:"1"`
FirstName string `json:"first_name"` FirstName string `json:"first_name" example:"John"`
LastName string `json:"last_name"` LastName string `json:"last_name" example:"Doe"`
PhoneNumber string `json:"phone_number"` PhoneNumber string `json:"phone_number" example:"09123456789"`
Role entity.AdminRole `json:"role"` Role entity.AdminRole `json:"role" example:"2"`
Description string `json:"description"` Description string `json:"description" example:"This is a description"`
Email string `json:"email"` Email string `json:"email" example:"example@gmail.com"`
Gender entity.Gender `json:"gender"` Gender entity.Gender `json:"gender" example:"1"`
Status entity.AdminStatus `json:"status"` Status entity.AdminStatus `json:"status" example:"1"`
} }

View File

@ -15,5 +15,5 @@ type RegisterRequest struct {
} }
type RegisterResponse struct { type RegisterResponse struct {
Admin entity.Admin Admin entity.Admin `json:"admin"`
} }

View File

@ -8,6 +8,6 @@ import (
type KindBoxReqGetAllRequest struct{} type KindBoxReqGetAllRequest struct{}
type KindBoxReqGetAllResponse struct { type KindBoxReqGetAllResponse struct {
AllKindBoxReq []entity.KindBoxReq AllKindBoxReq []entity.KindBoxReq `json:"all_kind_box_req"`
Pagination paginationparam.PaginationResponse Pagination paginationparam.PaginationResponse `json:"pagination"`
} }

View File

@ -8,5 +8,5 @@ type KindBoxReqGetRequest struct {
} }
type KindBoxReqGetResponse struct { type KindBoxReqGetResponse struct {
entity.KindBoxReq entity.KindBoxReq `json:"kind_box_req"`
} }

View File

@ -7,5 +7,5 @@ type KindBoxReqGetAllRequest struct {
} }
type KindBoxReqGetAllResponse struct { type KindBoxReqGetAllResponse struct {
AllKindBoxReq []entity.KindBoxReq AllKindBoxReq []entity.KindBoxReq `json:"all_kind_box_req"`
} }

View File

@ -11,9 +11,9 @@ type PaginationRequest struct {
} }
type PaginationResponse struct { type PaginationResponse struct {
PageSize uint PageSize uint `json:"page_size" example:"10"`
PageNumber uint PageNumber uint `json:"page_number" example:"1"`
Total uint Total uint `json:"total" example:"100"`
} }
func (p *PaginationRequest) GetPageNumber() uint { func (p *PaginationRequest) GetPageNumber() uint {