add swagger

This commit is contained in:
kandrusyak
2023-08-02 22:49:48 +03:00
parent a1705758df
commit fe09a32bbc
4 changed files with 319 additions and 9 deletions

View File

@@ -6,6 +6,7 @@ import (
"time"
)
// swagger:model Event
type Event struct {
gorm.Model
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primarykey"`
@@ -20,9 +21,27 @@ type Event struct {
OrgId uuid.UUID `json:"-"`
}
// swagger:model CreateEvent
type CreateEvent struct {
Start time.Time `json:"start" validate:"required,gt"`
End time.Time `json:"end" validate:"required,gtfield=Start"`
Person *PersonalInformation `json:"person" validate:"required,dive"`
MedicId uuid.UUID `json:"medic_id" validate:"required"`
// The event start time
// example: 2023-08-02T19:21:23.617Z
// required: true
Start time.Time `json:"start" validate:"required,gt"`
// The event end time
// example: 2023-08-02T19:21:23.617Z
// required: true
End time.Time `json:"end" validate:"required,gtfield=Start"`
// The person information
// required: true
Person *PersonalInformation `json:"person" validate:"required,dive"`
// The UUID of a medic
// example: 6204037c-30e6-408b-8aaa-dd8219860b4b
// required: true
MedicId uuid.UUID `json:"medic_id" validate:"required"`
}
// swagger:parameters CreateEvent
type CreateEventArg struct {
//in: body
CreateEvent *CreateEvent
}

View File

@@ -2,12 +2,23 @@ package model
import "github.com/google/uuid"
// swagger:model PersonalInformation
type PersonalInformation struct {
ID uuid.UUID `json:"id,omitempty" validate:"required_without_all=FirstName LastName Patronymic Phone"`
FirstName string `json:"first_name,omitempty" validate:"required_without=ID"`
LastName string `json:"last_name,omitempty" validate:"required_without=ID"`
Patronymic string `json:"patronymic,omitempty" validate:"required_without=ID"`
Phone string `json:"phone,omitempty" validate:"required_without=ID"`
// The UUID of a person
// example: 6204037c-30e6-408b-8aaa-dd8219860b4b
ID uuid.UUID `json:"id,omitempty" validate:"required_without_all=FirstName LastName Patronymic Phone"`
// The first name of a person
// example: Иван
FirstName string `json:"first_name,omitempty" validate:"required_without=ID"`
// The last name of a person
// example: Иванов
LastName string `json:"last_name,omitempty" validate:"required_without=ID"`
// The patronymic of a person
// example: Иванович
Patronymic string `json:"patronymic,omitempty" validate:"required_without=ID"`
// The first name of a person
// example: 79206321370
Phone string `json:"phone,omitempty" validate:"required_without=ID"`
}
type PersonalInformationCreate struct {