add format int64 for swagger doc (#3247)

* add format int64 for swagger doc

* add format int64 for swagger doc

* add global override

* swagger doc update

* add new line for .swaggo file
This commit is contained in:
Yabin Ma 2024-12-12 06:52:52 +01:00 committed by GitHub
parent 94cc85377f
commit 1d9e0f71df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 138 additions and 67 deletions

2
.swaggo Normal file
View file

@ -0,0 +1,2 @@
// Replace all time.Duration with int64
replace time.Duration int64

View file

@ -89,7 +89,7 @@ type ServerConfig struct {
EgressesLimit int `yaml:"egresses_limit"` EgressesLimit int `yaml:"egresses_limit"`
DeployedByOperator bool `yaml:"deployed_by_operator"` DeployedByOperator bool `yaml:"deployed_by_operator"`
Environment string `yaml:"environment"` Environment string `yaml:"environment"`
JwtValidityDuration time.Duration `yaml:"jwt_validity_duration"` JwtValidityDuration time.Duration `yaml:"jwt_validity_duration" swaggertype:"primitive,integer" format:"int64"`
RacAutoDisable bool `yaml:"rac_auto_disable"` RacAutoDisable bool `yaml:"rac_auto_disable"`
CacheEnabled string `yaml:"caching_enabled"` CacheEnabled string `yaml:"caching_enabled"`
EndpointDetection bool `json:"endpoint_detection"` EndpointDetection bool `json:"endpoint_detection"`

View file

@ -16,10 +16,10 @@ type ApiNode struct {
Address6 string `json:"address6" validate:"omitempty,cidrv6"` Address6 string `json:"address6" validate:"omitempty,cidrv6"`
LocalAddress string `json:"localaddress" validate:"omitempty,cidr"` LocalAddress string `json:"localaddress" validate:"omitempty,cidr"`
AllowedIPs []string `json:"allowedips"` AllowedIPs []string `json:"allowedips"`
LastModified int64 `json:"lastmodified"` LastModified int64 `json:"lastmodified" swaggertype:"primitive,integer" format:"int64"`
ExpirationDateTime int64 `json:"expdatetime"` ExpirationDateTime int64 `json:"expdatetime" swaggertype:"primitive,integer" format:"int64"`
LastCheckIn int64 `json:"lastcheckin"` LastCheckIn int64 `json:"lastcheckin" swaggertype:"primitive,integer" format:"int64"`
LastPeerUpdate int64 `json:"lastpeerupdate"` LastPeerUpdate int64 `json:"lastpeerupdate" swaggertype:"primitive,integer" format:"int64"`
Network string `json:"network"` Network string `json:"network"`
NetworkRange string `json:"networkrange"` NetworkRange string `json:"networkrange"`
NetworkRange6 string `json:"networkrange6"` NetworkRange6 string `json:"networkrange6"`

View file

@ -58,7 +58,7 @@ type EnrollmentKey struct {
// APIEnrollmentKey - used to create enrollment keys via API // APIEnrollmentKey - used to create enrollment keys via API
type APIEnrollmentKey struct { type APIEnrollmentKey struct {
Expiration int64 `json:"expiration"` Expiration int64 `json:"expiration" swaggertype:"primitive,integer" format:"int64"`
UsesRemaining int `json:"uses_remaining"` UsesRemaining int `json:"uses_remaining"`
Networks []string `json:"networks"` Networks []string `json:"networks"`
Unlimited bool `json:"unlimited"` Unlimited bool `json:"unlimited"`

View file

@ -13,7 +13,7 @@ type ExtClient struct {
AllowedIPs []string `json:"allowed_ips"` AllowedIPs []string `json:"allowed_ips"`
IngressGatewayID string `json:"ingressgatewayid" bson:"ingressgatewayid"` IngressGatewayID string `json:"ingressgatewayid" bson:"ingressgatewayid"`
IngressGatewayEndpoint string `json:"ingressgatewayendpoint" bson:"ingressgatewayendpoint"` IngressGatewayEndpoint string `json:"ingressgatewayendpoint" bson:"ingressgatewayendpoint"`
LastModified int64 `json:"lastmodified" bson:"lastmodified"` LastModified int64 `json:"lastmodified" bson:"lastmodified" swaggertype:"primitive,integer" format:"int64"`
Enabled bool `json:"enabled" bson:"enabled"` Enabled bool `json:"enabled" bson:"enabled"`
OwnerID string `json:"ownerid" bson:"ownerid"` OwnerID string `json:"ownerid" bson:"ownerid"`
DeniedACLs map[string]struct{} `json:"deniednodeacls" bson:"acls,omitempty"` DeniedACLs map[string]struct{} `json:"deniednodeacls" bson:"acls,omitempty"`

View file

@ -71,7 +71,7 @@ type Host struct {
IsDefault bool `json:"isdefault" yaml:"isdefault"` IsDefault bool `json:"isdefault" yaml:"isdefault"`
NatType string `json:"nat_type,omitempty" yaml:"nat_type,omitempty"` NatType string `json:"nat_type,omitempty" yaml:"nat_type,omitempty"`
TurnEndpoint *netip.AddrPort `json:"turn_endpoint,omitempty" yaml:"turn_endpoint,omitempty"` TurnEndpoint *netip.AddrPort `json:"turn_endpoint,omitempty" yaml:"turn_endpoint,omitempty"`
PersistentKeepalive time.Duration `json:"persistentkeepalive" yaml:"persistentkeepalive"` PersistentKeepalive time.Duration `json:"persistentkeepalive" swaggertype:"primitive,integer" format:"int64" yaml:"persistentkeepalive"`
} }
// FormatBool converts a boolean to a [yes|no] string // FormatBool converts a boolean to a [yes|no] string

View file

@ -15,14 +15,14 @@ type Metrics struct {
// Metric - holds a metric for data between nodes // Metric - holds a metric for data between nodes
type Metric struct { type Metric struct {
NodeName string `json:"node_name" bson:"node_name" yaml:"node_name"` NodeName string `json:"node_name" bson:"node_name" yaml:"node_name"`
Uptime int64 `json:"uptime" bson:"uptime" yaml:"uptime"` Uptime int64 `json:"uptime" bson:"uptime" yaml:"uptime" swaggertype:"primitive,integer" format:"int64"`
TotalTime int64 `json:"totaltime" bson:"totaltime" yaml:"totaltime"` TotalTime int64 `json:"totaltime" bson:"totaltime" yaml:"totaltime" swaggertype:"primitive,integer" format:"int64"`
Latency int64 `json:"latency" bson:"latency" yaml:"latency"` Latency int64 `json:"latency" bson:"latency" yaml:"latency" swaggertype:"primitive,integer" format:"int64"`
TotalReceived int64 `json:"totalreceived" bson:"totalreceived" yaml:"totalreceived"` TotalReceived int64 `json:"totalreceived" bson:"totalreceived" yaml:"totalreceived" swaggertype:"primitive,integer" format:"int64"`
LastTotalReceived int64 `json:"lasttotalreceived" bson:"lasttotalreceived" yaml:"lasttotalreceived"` LastTotalReceived int64 `json:"lasttotalreceived" bson:"lasttotalreceived" yaml:"lasttotalreceived" swaggertype:"primitive,integer" format:"int64"`
TotalSent int64 `json:"totalsent" bson:"totalsent" yaml:"totalsent"` TotalSent int64 `json:"totalsent" bson:"totalsent" yaml:"totalsent" swaggertype:"primitive,integer" format:"int64"`
LastTotalSent int64 `json:"lasttotalsent" bson:"lasttotalsent" yaml:"lasttotalsent"` LastTotalSent int64 `json:"lasttotalsent" bson:"lasttotalsent" yaml:"lasttotalsent" swaggertype:"primitive,integer" format:"int64"`
ActualUptime time.Duration `json:"actualuptime" bson:"actualuptime" yaml:"actualuptime"` ActualUptime time.Duration `json:"actualuptime" swaggertype:"primitive,integer" format:"int64" bson:"actualuptime" yaml:"actualuptime"`
PercentUp float64 `json:"percentup" bson:"percentup" yaml:"percentup"` PercentUp float64 `json:"percentup" bson:"percentup" yaml:"percentup"`
Connected bool `json:"connected" bson:"connected" yaml:"connected"` Connected bool `json:"connected" bson:"connected" yaml:"connected"`
} }

View file

@ -11,8 +11,8 @@ type Network struct {
AddressRange string `json:"addressrange" bson:"addressrange" validate:"omitempty,cidrv4"` AddressRange string `json:"addressrange" bson:"addressrange" validate:"omitempty,cidrv4"`
AddressRange6 string `json:"addressrange6" bson:"addressrange6" validate:"omitempty,cidrv6"` AddressRange6 string `json:"addressrange6" bson:"addressrange6" validate:"omitempty,cidrv6"`
NetID string `json:"netid" bson:"netid" validate:"required,min=1,max=32,netid_valid"` NetID string `json:"netid" bson:"netid" validate:"required,min=1,max=32,netid_valid"`
NodesLastModified int64 `json:"nodeslastmodified" bson:"nodeslastmodified"` NodesLastModified int64 `json:"nodeslastmodified" bson:"nodeslastmodified" swaggertype:"primitive,integer" format:"int64"`
NetworkLastModified int64 `json:"networklastmodified" bson:"networklastmodified"` NetworkLastModified int64 `json:"networklastmodified" bson:"networklastmodified" swaggertype:"primitive,integer" format:"int64"`
DefaultInterface string `json:"defaultinterface" bson:"defaultinterface" validate:"min=1,max=35"` DefaultInterface string `json:"defaultinterface" bson:"defaultinterface" validate:"min=1,max=35"`
DefaultListenPort int32 `json:"defaultlistenport,omitempty" bson:"defaultlistenport,omitempty" validate:"omitempty,min=1024,max=65535"` DefaultListenPort int32 `json:"defaultlistenport,omitempty" bson:"defaultlistenport,omitempty" validate:"omitempty,min=1024,max=65535"`
NodeLimit int32 `json:"nodelimit" bson:"nodelimit"` NodeLimit int32 `json:"nodelimit" bson:"nodelimit"`

View file

@ -137,10 +137,10 @@ type LegacyNode struct {
IsHub string `json:"ishub" bson:"ishub" yaml:"ishub" validate:"checkyesorno"` IsHub string `json:"ishub" bson:"ishub" yaml:"ishub" validate:"checkyesorno"`
AccessKey string `json:"accesskey" bson:"accesskey" yaml:"accesskey"` AccessKey string `json:"accesskey" bson:"accesskey" yaml:"accesskey"`
Interface string `json:"interface" bson:"interface" yaml:"interface"` Interface string `json:"interface" bson:"interface" yaml:"interface"`
LastModified int64 `json:"lastmodified" bson:"lastmodified" yaml:"lastmodified"` LastModified int64 `json:"lastmodified" bson:"lastmodified" yaml:"lastmodified" swaggertype:"primitive,integer" format:"int64"`
ExpirationDateTime int64 `json:"expdatetime" bson:"expdatetime" yaml:"expdatetime"` ExpirationDateTime int64 `json:"expdatetime" bson:"expdatetime" yaml:"expdatetime" swaggertype:"primitive,integer" format:"int64"`
LastPeerUpdate int64 `json:"lastpeerupdate" bson:"lastpeerupdate" yaml:"lastpeerupdate"` LastPeerUpdate int64 `json:"lastpeerupdate" bson:"lastpeerupdate" yaml:"lastpeerupdate" swaggertype:"primitive,integer" format:"int64"`
LastCheckIn int64 `json:"lastcheckin" bson:"lastcheckin" yaml:"lastcheckin"` LastCheckIn int64 `json:"lastcheckin" bson:"lastcheckin" yaml:"lastcheckin" swaggertype:"primitive,integer" format:"int64"`
MacAddress string `json:"macaddress" bson:"macaddress" yaml:"macaddress"` MacAddress string `json:"macaddress" bson:"macaddress" yaml:"macaddress"`
Password string `json:"password" bson:"password" yaml:"password" validate:"required,min=6"` Password string `json:"password" bson:"password" yaml:"password" validate:"required,min=6"`
Network string `json:"network" bson:"network" yaml:"network" validate:"network_exists"` Network string `json:"network" bson:"network" yaml:"network" validate:"network_exists"`

View file

@ -196,7 +196,7 @@ type ServerUpdateData struct {
// also contains assymetrical encryption pub/priv keys for any server traffic // also contains assymetrical encryption pub/priv keys for any server traffic
type Telemetry struct { type Telemetry struct {
UUID string `json:"uuid" bson:"uuid"` UUID string `json:"uuid" bson:"uuid"`
LastSend int64 `json:"lastsend" bson:"lastsend"` LastSend int64 `json:"lastsend" bson:"lastsend" swaggertype:"primitive,integer" format:"int64"`
TrafficKeyPriv []byte `json:"traffickeypriv" bson:"traffickeypriv"` TrafficKeyPriv []byte `json:"traffickeypriv" bson:"traffickeypriv"`
TrafficKeyPub []byte `json:"traffickeypub" bson:"traffickeypub"` TrafficKeyPub []byte `json:"traffickeypub" bson:"traffickeypub"`
} }

View file

@ -18,7 +18,7 @@ var errValidation = errors.New(license_validation_err_msg)
// LicenseKey - the license key struct representation with associated data // LicenseKey - the license key struct representation with associated data
type LicenseKey struct { type LicenseKey struct {
LicenseValue string `json:"license_value"` // actual (public) key and the unique value for the key LicenseValue string `json:"license_value"` // actual (public) key and the unique value for the key
Expiration int64 `json:"expiration"` Expiration int64 `json:"expiration" swaggertype:"primitive,integer" format:"int64"`
UsageServers int `json:"limit_servers"` UsageServers int `json:"limit_servers"`
UsageUsers int `json:"limit_users"` UsageUsers int `json:"limit_users"`
UsageClients int `json:"limit_clients"` UsageClients int `json:"limit_clients"`

View file

@ -1,6 +1,7 @@
definitions: definitions:
acls.ACL: acls.ACL:
additionalProperties: additionalProperties:
format: int32
type: integer type: integer
type: object type: object
acls.ACLContainer: acls.ACLContainer:
@ -74,7 +75,8 @@ definitions:
ingressesLimit: ingressesLimit:
type: integer type: integer
jwtValidityDuration: jwtValidityDuration:
$ref: '#/definitions/time.Duration' format: int64
type: integer
licenseValue: licenseValue:
type: string type: string
machinesLimit: machinesLimit:
@ -109,6 +111,8 @@ definitions:
type: string type: string
publicIPService: publicIPService:
type: string type: string
publicIp:
type: string
racAutoDisable: racAutoDisable:
type: boolean type: boolean
restBackend: restBackend:
@ -155,6 +159,7 @@ definitions:
models.APIEnrollmentKey: models.APIEnrollmentKey:
properties: properties:
expiration: expiration:
format: int64
type: integer type: integer
groups: groups:
items: items:
@ -179,6 +184,41 @@ definitions:
required: required:
- tags - tags
type: object type: object
models.AclRule:
properties:
allowed:
type: boolean
allowed_ports:
items:
type: string
type: array
allowed_protocols:
allOf:
- $ref: '#/definitions/models.Protocol'
description: tcp, udp, etc.
direction:
allOf:
- $ref: '#/definitions/models.AllowedTrafficDirection'
description: single or two-way
id:
type: string
ip_list:
items:
$ref: '#/definitions/net.IPNet'
type: array
ip6_list:
items:
$ref: '#/definitions/net.IPNet'
type: array
type: object
models.AllowedTrafficDirection:
enum:
- 0
- 1
type: integer
x-enum-varnames:
- TrafficDirectionUni
- TrafficDirectionBi
models.ApiHost: models.ApiHost:
properties: properties:
autoupdate: autoupdate:
@ -267,6 +307,7 @@ definitions:
type: string type: string
type: array type: array
expdatetime: expdatetime:
format: int64
type: integer type: integer
fail_over_peers: fail_over_peers:
additionalProperties: additionalProperties:
@ -307,10 +348,13 @@ definitions:
isrelayed: isrelayed:
type: boolean type: boolean
lastcheckin: lastcheckin:
format: int64
type: integer type: integer
lastmodified: lastmodified:
format: int64
type: integer type: integer
lastpeerupdate: lastpeerupdate:
format: int64
type: integer type: integer
localaddress: localaddress:
type: string type: string
@ -334,6 +378,8 @@ definitions:
type: string type: string
static_node: static_node:
$ref: '#/definitions/models.ExtClient' $ref: '#/definitions/models.ExtClient'
status:
$ref: '#/definitions/models.NodeStatus'
tags: tags:
additionalProperties: additionalProperties:
type: object type: object
@ -481,6 +527,7 @@ definitions:
ingressgatewayid: ingressgatewayid:
type: string type: string
lastmodified: lastmodified:
format: int64
type: integer type: integer
network: network:
type: string type: string
@ -515,13 +562,27 @@ definitions:
properties: properties:
allow: allow:
type: boolean type: boolean
dstIP: allowed_ports:
items:
type: string
type: array
allowed_protocols:
allOf:
- $ref: '#/definitions/models.Protocol'
description: tcp, udp, etc.
dst_ip:
$ref: '#/definitions/net.IPNet' $ref: '#/definitions/net.IPNet'
srcIP: src_ip:
$ref: '#/definitions/net.IPNet' $ref: '#/definitions/net.IPNet'
type: object type: object
models.FwUpdate: models.FwUpdate:
properties: properties:
acl_rules:
additionalProperties:
$ref: '#/definitions/models.AclRule'
type: object
allow_all:
type: boolean
egress_info: egress_info:
additionalProperties: additionalProperties:
$ref: '#/definitions/models.EgressInfo' $ref: '#/definitions/models.EgressInfo'
@ -534,6 +595,10 @@ definitions:
type: boolean type: boolean
is_ingress_gw: is_ingress_gw:
type: boolean type: boolean
networks:
items:
$ref: '#/definitions/net.IPNet'
type: array
type: object type: object
models.Host: models.Host:
properties: properties:
@ -596,7 +661,8 @@ definitions:
os: os:
type: string type: string
persistentkeepalive: persistentkeepalive:
$ref: '#/definitions/time.Duration' format: int64
type: integer
publickey: publickey:
items: items:
type: integer type: integer
@ -797,26 +863,34 @@ definitions:
models.Metric: models.Metric:
properties: properties:
actualuptime: actualuptime:
$ref: '#/definitions/time.Duration' format: int64
type: integer
connected: connected:
type: boolean type: boolean
lasttotalreceived: lasttotalreceived:
format: int64
type: integer type: integer
lasttotalsent: lasttotalsent:
format: int64
type: integer type: integer
latency: latency:
format: int64
type: integer type: integer
node_name: node_name:
type: string type: string
percentup: percentup:
type: number type: number
totalreceived: totalreceived:
format: int64
type: integer type: integer
totalsent: totalsent:
format: int64
type: integer type: integer
totaltime: totaltime:
format: int64
type: integer type: integer
uptime: uptime:
format: int64
type: integer type: integer
type: object type: object
models.Metrics: models.Metrics:
@ -868,10 +942,12 @@ definitions:
minLength: 1 minLength: 1
type: string type: string
networklastmodified: networklastmodified:
format: int64
type: integer type: integer
nodelimit: nodelimit:
type: integer type: integer
nodeslastmodified: nodeslastmodified:
format: int64
type: integer type: integer
required: required:
- netid - netid
@ -967,6 +1043,8 @@ definitions:
type: integer type: integer
networkrange6: networkrange6:
type: number type: number
node_status:
$ref: '#/definitions/models.NodeStatus'
ownerid: ownerid:
type: string type: string
pendingdelete: pendingdelete:
@ -1005,10 +1083,36 @@ definitions:
serverconfig: serverconfig:
$ref: '#/definitions/models.ServerConfig' $ref: '#/definitions/models.ServerConfig'
type: object type: object
models.NodeStatus:
enum:
- online
- offline
- warning
- error
- unknown
type: string
x-enum-varnames:
- OnlineSt
- OfflineSt
- WarningSt
- ErrorSt
- UnKnown
models.PeerMap: models.PeerMap:
additionalProperties: additionalProperties:
$ref: '#/definitions/models.IDandAddr' $ref: '#/definitions/models.IDandAddr'
type: object type: object
models.Protocol:
enum:
- all
- udp
- tcp
- icmp
type: string
x-enum-varnames:
- ALL
- UDP
- TCP
- ICMP
models.RegisterResponse: models.RegisterResponse:
properties: properties:
requested_host: requested_host:
@ -1286,6 +1390,7 @@ definitions:
mask: mask:
description: network mask description: network mask
items: items:
format: int32
type: integer type: integer
type: array type: array
type: object type: object
@ -1303,42 +1408,6 @@ definitions:
type: object type: object
netip.AddrPort: netip.AddrPort:
type: object type: object
time.Duration:
enum:
- -9223372036854775808
- 9223372036854775807
- 1
- 1000
- 1000000
- 1000000000
- 60000000000
- 3600000000000
- -9223372036854775808
- 9223372036854775807
- 1
- 1000
- 1000000
- 1000000000
- 60000000000
- 3600000000000
type: integer
x-enum-varnames:
- minDuration
- maxDuration
- Nanosecond
- Microsecond
- Millisecond
- Second
- Minute
- Hour
- minDuration
- maxDuration
- Nanosecond
- Microsecond
- Millisecond
- Second
- Minute
- Hour
wgtypes.PeerConfig: wgtypes.PeerConfig:
properties: properties:
allowedIPs: allowedIPs:
@ -1353,13 +1422,13 @@ definitions:
- $ref: '#/definitions/net.UDPAddr' - $ref: '#/definitions/net.UDPAddr'
description: Endpoint specifies the endpoint of this peer entry, if not nil. description: Endpoint specifies the endpoint of this peer entry, if not nil.
persistentKeepaliveInterval: persistentKeepaliveInterval:
allOf:
- $ref: '#/definitions/time.Duration'
description: |- description: |-
PersistentKeepaliveInterval specifies the persistent keepalive interval PersistentKeepaliveInterval specifies the persistent keepalive interval
for this peer, if not nil. for this peer, if not nil.
A non-nil value of 0 will clear the persistent keepalive interval. A non-nil value of 0 will clear the persistent keepalive interval.
format: int64
type: integer
presharedKey: presharedKey:
description: |- description: |-
PresharedKey specifies a peer's preshared key configuration, if not nil. PresharedKey specifies a peer's preshared key configuration, if not nil.