Skip to content

Commit

Permalink
add format int64 for swagger doc
Browse files Browse the repository at this point in the history
  • Loading branch information
yabinma committed Dec 10, 2024
1 parent 9024aea commit 574f89f
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 13 deletions.
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type ServerConfig struct {
EgressesLimit int `yaml:"egresses_limit"`
DeployedByOperator bool `yaml:"deployed_by_operator"`
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"`
CacheEnabled string `yaml:"caching_enabled"`
EndpointDetection bool `json:"endpoint_detection"`
Expand Down
2 changes: 1 addition & 1 deletion models/api_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type ApiNode struct {
AllowedIPs []string `json:"allowedips"`
LastModified int64 `json:"lastmodified"`
ExpirationDateTime int64 `json:"expdatetime"`
LastCheckIn int64 `json:"lastcheckin"`
LastCheckIn int64 `json:"lastcheckin" swaggertype:"primitive,integer" format:"int64"`
LastPeerUpdate int64 `json:"lastpeerupdate"`
Network string `json:"network"`
NetworkRange string `json:"networkrange"`
Expand Down
2 changes: 1 addition & 1 deletion models/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type Host struct {
IsDefault bool `json:"isdefault" yaml:"isdefault"`
NatType string `json:"nat_type,omitempty" yaml:"nat_type,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
Expand Down
2 changes: 1 addition & 1 deletion models/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Metric struct {
LastTotalReceived int64 `json:"lasttotalreceived" bson:"lasttotalreceived" yaml:"lasttotalreceived"`
TotalSent int64 `json:"totalsent" bson:"totalsent" yaml:"totalsent"`
LastTotalSent int64 `json:"lasttotalsent" bson:"lasttotalsent" yaml:"lasttotalsent"`
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"`
Connected bool `json:"connected" bson:"connected" yaml:"connected"`
}
Expand Down
103 changes: 94 additions & 9 deletions swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ definitions:
ingressesLimit:
type: integer
jwtValidityDuration:
$ref: '#/definitions/time.Duration'
format: int64
type: integer
licenseValue:
type: string
machinesLimit:
Expand Down Expand Up @@ -109,6 +110,8 @@ definitions:
type: string
publicIPService:
type: string
publicIp:
type: string
racAutoDisable:
type: boolean
restBackend:
Expand Down Expand Up @@ -179,6 +182,41 @@ definitions:
required:
- tags
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:
properties:
autoupdate:
Expand Down Expand Up @@ -307,6 +345,7 @@ definitions:
isrelayed:
type: boolean
lastcheckin:
format: int64
type: integer
lastmodified:
type: integer
Expand Down Expand Up @@ -334,6 +373,8 @@ definitions:
type: string
static_node:
$ref: '#/definitions/models.ExtClient'
status:
$ref: '#/definitions/models.NodeStatus'
tags:
additionalProperties:
type: object
Expand Down Expand Up @@ -515,13 +556,27 @@ definitions:
properties:
allow:
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'
srcIP:
src_ip:
$ref: '#/definitions/net.IPNet'
type: object
models.FwUpdate:
properties:
acl_rules:
additionalProperties:
$ref: '#/definitions/models.AclRule'
type: object
allow_all:
type: boolean
egress_info:
additionalProperties:
$ref: '#/definitions/models.EgressInfo'
Expand All @@ -534,6 +589,10 @@ definitions:
type: boolean
is_ingress_gw:
type: boolean
networks:
items:
$ref: '#/definitions/net.IPNet'
type: array
type: object
models.Host:
properties:
Expand Down Expand Up @@ -596,7 +655,8 @@ definitions:
os:
type: string
persistentkeepalive:
$ref: '#/definitions/time.Duration'
format: int64
type: integer
publickey:
items:
type: integer
Expand Down Expand Up @@ -797,7 +857,8 @@ definitions:
models.Metric:
properties:
actualuptime:
$ref: '#/definitions/time.Duration'
format: int64
type: integer
connected:
type: boolean
lasttotalreceived:
Expand Down Expand Up @@ -967,6 +1028,8 @@ definitions:
type: integer
networkrange6:
type: number
node_status:
$ref: '#/definitions/models.NodeStatus'
ownerid:
type: string
pendingdelete:
Expand Down Expand Up @@ -1005,10 +1068,36 @@ definitions:
serverconfig:
$ref: '#/definitions/models.ServerConfig'
type: object
models.NodeStatus:
enum:
- online
- offline
- warning
- error
- unknown
type: string
x-enum-varnames:
- OnlineSt
- OfflineSt
- WarningSt
- ErrorSt
- UnKnown
models.PeerMap:
additionalProperties:
$ref: '#/definitions/models.IDandAddr'
type: object
models.Protocol:
enum:
- all
- udp
- tcp
- icmp
type: string
x-enum-varnames:
- ALL
- UDP
- TCP
- ICMP
models.RegisterResponse:
properties:
requested_host:
Expand Down Expand Up @@ -1313,8 +1402,6 @@ definitions:
- 1000000000
- 60000000000
- 3600000000000
- -9223372036854775808
- 9223372036854775807
- 1
- 1000
- 1000000
Expand All @@ -1331,8 +1418,6 @@ definitions:
- Second
- Minute
- Hour
- minDuration
- maxDuration
- Nanosecond
- Microsecond
- Millisecond
Expand Down

0 comments on commit 574f89f

Please sign in to comment.