feat(docs): Annotated required params

This commit is contained in:
Nicolai Ort 2024-12-11 17:45:51 +01:00
parent f5debf58fc
commit e2cd445aeb
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
6 changed files with 163 additions and 37 deletions

View File

@ -100,12 +100,18 @@ const docTemplate = `{
"definitions": {
"models.Card": {
"type": "object",
"required": [
"code",
"id",
"runner"
],
"properties": {
"code": {
"type": "string"
},
"enabled": {
"type": "boolean"
"type": "boolean",
"default": true
},
"id": {
"type": "integer"
@ -117,6 +123,10 @@ const docTemplate = `{
},
"models.CardRequest": {
"type": "object",
"required": [
"cards",
"locale"
],
"properties": {
"cards": {
"type": "array",
@ -135,6 +145,10 @@ const docTemplate = `{
},
"models.CertificateRequest": {
"type": "object",
"required": [
"locale",
"runners"
],
"properties": {
"locale": {
"type": "string",
@ -153,6 +167,10 @@ const docTemplate = `{
},
"models.ContractRequest": {
"type": "object",
"required": [
"locale",
"runners"
],
"properties": {
"locale": {
"type": "string",
@ -171,6 +189,11 @@ const docTemplate = `{
},
"models.DistanceDonation": {
"type": "object",
"required": [
"amount_per_distance",
"donor",
"id"
],
"properties": {
"amount": {
"type": "integer"
@ -191,6 +214,11 @@ const docTemplate = `{
},
"models.Donor": {
"type": "object",
"required": [
"first_name",
"id",
"last_name"
],
"properties": {
"first_name": {
"type": "string"
@ -208,6 +236,10 @@ const docTemplate = `{
},
"models.Group": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer"
@ -222,6 +254,12 @@ const docTemplate = `{
},
"models.Runner": {
"type": "object",
"required": [
"first_name",
"group",
"id",
"last_name"
],
"properties": {
"first_name": {
"type": "string"
@ -242,6 +280,13 @@ const docTemplate = `{
},
"models.RunnerWithDonations": {
"type": "object",
"required": [
"distance",
"first_name",
"group",
"id",
"last_name"
],
"properties": {
"distance": {
"type": "integer"

View File

@ -91,12 +91,18 @@
"definitions": {
"models.Card": {
"type": "object",
"required": [
"code",
"id",
"runner"
],
"properties": {
"code": {
"type": "string"
},
"enabled": {
"type": "boolean"
"type": "boolean",
"default": true
},
"id": {
"type": "integer"
@ -108,6 +114,10 @@
},
"models.CardRequest": {
"type": "object",
"required": [
"cards",
"locale"
],
"properties": {
"cards": {
"type": "array",
@ -126,6 +136,10 @@
},
"models.CertificateRequest": {
"type": "object",
"required": [
"locale",
"runners"
],
"properties": {
"locale": {
"type": "string",
@ -144,6 +158,10 @@
},
"models.ContractRequest": {
"type": "object",
"required": [
"locale",
"runners"
],
"properties": {
"locale": {
"type": "string",
@ -162,6 +180,11 @@
},
"models.DistanceDonation": {
"type": "object",
"required": [
"amount_per_distance",
"donor",
"id"
],
"properties": {
"amount": {
"type": "integer"
@ -182,6 +205,11 @@
},
"models.Donor": {
"type": "object",
"required": [
"first_name",
"id",
"last_name"
],
"properties": {
"first_name": {
"type": "string"
@ -199,6 +227,10 @@
},
"models.Group": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer"
@ -213,6 +245,12 @@
},
"models.Runner": {
"type": "object",
"required": [
"first_name",
"group",
"id",
"last_name"
],
"properties": {
"first_name": {
"type": "string"
@ -233,6 +271,13 @@
},
"models.RunnerWithDonations": {
"type": "object",
"required": [
"distance",
"first_name",
"group",
"id",
"last_name"
],
"properties": {
"distance": {
"type": "integer"

View File

@ -4,11 +4,16 @@ definitions:
code:
type: string
enabled:
default: true
type: boolean
id:
type: integer
runner:
$ref: '#/definitions/models.Runner'
required:
- code
- id
- runner
type: object
models.CardRequest:
properties:
@ -21,6 +26,9 @@ definitions:
- en
- de
type: string
required:
- cards
- locale
type: object
models.CertificateRequest:
properties:
@ -33,6 +41,9 @@ definitions:
items:
$ref: '#/definitions/models.RunnerWithDonations'
type: array
required:
- locale
- runners
type: object
models.ContractRequest:
properties:
@ -45,6 +56,9 @@ definitions:
items:
$ref: '#/definitions/models.Runner'
type: array
required:
- locale
- runners
type: object
models.DistanceDonation:
properties:
@ -58,6 +72,10 @@ definitions:
type: integer
paid_amount:
type: integer
required:
- amount_per_distance
- donor
- id
type: object
models.Donor:
properties:
@ -69,6 +87,10 @@ definitions:
type: string
middle_name:
type: string
required:
- first_name
- id
- last_name
type: object
models.Group:
properties:
@ -78,6 +100,9 @@ definitions:
type: string
parent_group:
$ref: '#/definitions/models.Group'
required:
- id
- name
type: object
models.Runner:
properties:
@ -91,6 +116,11 @@ definitions:
type: string
middle_name:
type: string
required:
- first_name
- group
- id
- last_name
type: object
models.RunnerWithDonations:
properties:
@ -114,6 +144,12 @@ definitions:
type: integer
total_per_distance:
type: integer
required:
- distance
- first_name
- group
- id
- last_name
type: object
info:
contact: {}

View File

@ -1,15 +1,15 @@
package models
type CardRequest struct {
Cards []Card `json:"cards"`
Locale string `json:"locale" enums:"en,de"`
Cards []Card `json:"cards" validate:"required"`
Locale string `json:"locale" enums:"en,de" validate:"required"`
}
type Card struct {
ID int `json:"id"`
Enabled bool `json:"enabled"`
Runner Runner `json:"runner"`
Code string `json:"code"`
ID int `json:"id" validate:"required"`
Enabled bool `json:"enabled" default:"true"`
Runner Runner `json:"runner" validate:"required"`
Code string `json:"code" validate:"required"`
}
type CardTemplateOptions struct {

View File

@ -1,35 +1,35 @@
package models
type CertificateRequest struct {
Runners []RunnerWithDonations `json:"runners"`
Locale string `json:"locale" enums:"en,de"`
Runners []RunnerWithDonations `json:"runners" validate:"required"`
Locale string `json:"locale" enums:"en,de" validate:"required"`
}
type RunnerWithDonations struct {
ID int `json:"id"`
FirstName string `json:"first_name"`
MiddleName string `json:"middle_name"`
LastName string `json:"last_name"`
Group Group `json:"group"`
Distance int `json:"distance"`
DistanceDonations []DistanceDonation `json:"distance_donations"`
TotalPerDistance int `json:"total_per_distance"`
TotalDonations int `json:"total_donations"`
ID int `json:"id" validate:"required"`
FirstName string `json:"first_name" validate:"required"`
MiddleName string `json:"middle_name" validate:"optional"`
LastName string `json:"last_name" validate:"required"`
Group Group `json:"group" validate:"required"`
Distance int `json:"distance" validate:"required"`
DistanceDonations []DistanceDonation `json:"distance_donations" validate:"optional"`
TotalPerDistance int `json:"total_per_distance" validate:"optional"`
TotalDonations int `json:"total_donations" validate:"optional"`
}
type DistanceDonation struct {
ID int `json:"id"`
ID int `json:"id" validate:"required"`
Amount int `json:"amount"`
PaidAmount int `json:"paid_amount"`
AmountPerDistance int `json:"amount_per_distance"`
Donor Donor `json:"donor"`
PaidAmount int `json:"paid_amount" validate:"optional"`
AmountPerDistance int `json:"amount_per_distance" validate:"required"`
Donor Donor `json:"donor" validate:"required"`
}
type Donor struct {
ID int `json:"id"`
FirstName string `json:"first_name"`
MiddleName string `json:"middle_name"`
LastName string `json:"last_name"`
ID int `json:"id" validate:"required"`
FirstName string `json:"first_name" validate:"required"`
MiddleName string `json:"middle_name" validate:"optional"`
LastName string `json:"last_name" validate:"required"`
}
type CertificateTemplateOptions struct {

View File

@ -1,22 +1,22 @@
package models
type ContractRequest struct {
Runners []Runner `json:"runners"`
Locale string `json:"locale" enums:"en,de"`
Runners []Runner `json:"runners" validate:"required"`
Locale string `json:"locale" enums:"en,de" validate:"required"`
}
type Runner struct {
ID int `json:"id"`
FirstName string `json:"first_name"`
MiddleName string `json:"middle_name"`
LastName string `json:"last_name"`
Group Group `json:"group"`
ID int `json:"id" validate:"required"`
FirstName string `json:"first_name" validate:"required"`
MiddleName string `json:"middle_name" validate:"optional"`
LastName string `json:"last_name" validate:"required"`
Group Group `json:"group" validate:"required"`
}
type Group struct {
ID int `json:"id"`
Name string `json:"name"`
ParentGroup *Group `json:"parent_group"`
ID int `json:"id" validate:"required"`
Name string `json:"name" validate:"required"`
ParentGroup *Group `json:"parent_group" validate:"optional"`
}
type ContractTemplateOptions struct {