From 216cc8286ba17aaf6a8c3072600aa713add7407f Mon Sep 17 00:00:00 2001 From: Max Ma Date: Tue, 10 Dec 2024 12:58:05 +0100 Subject: [PATCH] add format int64 for swagger doc --- models/api_node.go | 6 +++--- models/enrollment_key.go | 2 +- models/extclient.go | 2 +- models/metrics.go | 14 +++++++------- models/network.go | 4 ++-- models/node.go | 8 ++++---- models/structs.go | 2 +- pro/types.go | 2 +- swagger.yaml | 18 ++++++++++++++++++ 9 files changed, 38 insertions(+), 20 deletions(-) diff --git a/models/api_node.go b/models/api_node.go index 69dfedc74..995c4f581 100644 --- a/models/api_node.go +++ b/models/api_node.go @@ -16,10 +16,10 @@ type ApiNode struct { Address6 string `json:"address6" validate:"omitempty,cidrv6"` LocalAddress string `json:"localaddress" validate:"omitempty,cidr"` AllowedIPs []string `json:"allowedips"` - LastModified int64 `json:"lastmodified"` - ExpirationDateTime int64 `json:"expdatetime"` + LastModified int64 `json:"lastmodified" swaggertype:"primitive,integer" format:"int64"` + ExpirationDateTime int64 `json:"expdatetime" swaggertype:"primitive,integer" format:"int64"` 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"` NetworkRange string `json:"networkrange"` NetworkRange6 string `json:"networkrange6"` diff --git a/models/enrollment_key.go b/models/enrollment_key.go index f133d7558..7ed6e56a8 100644 --- a/models/enrollment_key.go +++ b/models/enrollment_key.go @@ -58,7 +58,7 @@ type EnrollmentKey struct { // APIEnrollmentKey - used to create enrollment keys via API type APIEnrollmentKey struct { - Expiration int64 `json:"expiration"` + Expiration int64 `json:"expiration" swaggertype:"primitive,integer" format:"int64"` UsesRemaining int `json:"uses_remaining"` Networks []string `json:"networks"` Unlimited bool `json:"unlimited"` diff --git a/models/extclient.go b/models/extclient.go index cbccc5dd3..e9d3708b8 100644 --- a/models/extclient.go +++ b/models/extclient.go @@ -13,7 +13,7 @@ type ExtClient struct { AllowedIPs []string `json:"allowed_ips"` IngressGatewayID string `json:"ingressgatewayid" bson:"ingressgatewayid"` 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"` OwnerID string `json:"ownerid" bson:"ownerid"` DeniedACLs map[string]struct{} `json:"deniednodeacls" bson:"acls,omitempty"` diff --git a/models/metrics.go b/models/metrics.go index 62b4bb683..2e70a1780 100644 --- a/models/metrics.go +++ b/models/metrics.go @@ -15,13 +15,13 @@ type Metrics struct { // Metric - holds a metric for data between nodes type Metric struct { NodeName string `json:"node_name" bson:"node_name" yaml:"node_name"` - Uptime int64 `json:"uptime" bson:"uptime" yaml:"uptime"` - TotalTime int64 `json:"totaltime" bson:"totaltime" yaml:"totaltime"` - Latency int64 `json:"latency" bson:"latency" yaml:"latency"` - TotalReceived int64 `json:"totalreceived" bson:"totalreceived" yaml:"totalreceived"` - LastTotalReceived int64 `json:"lasttotalreceived" bson:"lasttotalreceived" yaml:"lasttotalreceived"` - TotalSent int64 `json:"totalsent" bson:"totalsent" yaml:"totalsent"` - LastTotalSent int64 `json:"lasttotalsent" bson:"lasttotalsent" yaml:"lasttotalsent"` + Uptime int64 `json:"uptime" bson:"uptime" yaml:"uptime" swaggertype:"primitive,integer" format:"int64"` + TotalTime int64 `json:"totaltime" bson:"totaltime" yaml:"totaltime" swaggertype:"primitive,integer" format:"int64"` + Latency int64 `json:"latency" bson:"latency" yaml:"latency" swaggertype:"primitive,integer" format:"int64"` + TotalReceived int64 `json:"totalreceived" bson:"totalreceived" yaml:"totalreceived" swaggertype:"primitive,integer" format:"int64"` + LastTotalReceived int64 `json:"lasttotalreceived" bson:"lasttotalreceived" yaml:"lasttotalreceived" swaggertype:"primitive,integer" format:"int64"` + TotalSent int64 `json:"totalsent" bson:"totalsent" yaml:"totalsent" swaggertype:"primitive,integer" format:"int64"` + LastTotalSent int64 `json:"lasttotalsent" bson:"lasttotalsent" yaml:"lasttotalsent" swaggertype:"primitive,integer" format:"int64"` 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"` diff --git a/models/network.go b/models/network.go index 32d95f865..dbb2fc4a4 100644 --- a/models/network.go +++ b/models/network.go @@ -11,8 +11,8 @@ type Network struct { AddressRange string `json:"addressrange" bson:"addressrange" validate:"omitempty,cidrv4"` AddressRange6 string `json:"addressrange6" bson:"addressrange6" validate:"omitempty,cidrv6"` NetID string `json:"netid" bson:"netid" validate:"required,min=1,max=32,netid_valid"` - NodesLastModified int64 `json:"nodeslastmodified" bson:"nodeslastmodified"` - NetworkLastModified int64 `json:"networklastmodified" bson:"networklastmodified"` + NodesLastModified int64 `json:"nodeslastmodified" bson:"nodeslastmodified" swaggertype:"primitive,integer" format:"int64"` + NetworkLastModified int64 `json:"networklastmodified" bson:"networklastmodified" swaggertype:"primitive,integer" format:"int64"` 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"` NodeLimit int32 `json:"nodelimit" bson:"nodelimit"` diff --git a/models/node.go b/models/node.go index 8ed63c0bd..c9e55e5d5 100644 --- a/models/node.go +++ b/models/node.go @@ -137,10 +137,10 @@ type LegacyNode struct { IsHub string `json:"ishub" bson:"ishub" yaml:"ishub" validate:"checkyesorno"` AccessKey string `json:"accesskey" bson:"accesskey" yaml:"accesskey"` Interface string `json:"interface" bson:"interface" yaml:"interface"` - LastModified int64 `json:"lastmodified" bson:"lastmodified" yaml:"lastmodified"` - ExpirationDateTime int64 `json:"expdatetime" bson:"expdatetime" yaml:"expdatetime"` - LastPeerUpdate int64 `json:"lastpeerupdate" bson:"lastpeerupdate" yaml:"lastpeerupdate"` - LastCheckIn int64 `json:"lastcheckin" bson:"lastcheckin" yaml:"lastcheckin"` + LastModified int64 `json:"lastmodified" bson:"lastmodified" yaml:"lastmodified" swaggertype:"primitive,integer" format:"int64"` + ExpirationDateTime int64 `json:"expdatetime" bson:"expdatetime" yaml:"expdatetime" swaggertype:"primitive,integer" format:"int64"` + LastPeerUpdate int64 `json:"lastpeerupdate" bson:"lastpeerupdate" yaml:"lastpeerupdate" swaggertype:"primitive,integer" format:"int64"` + LastCheckIn int64 `json:"lastcheckin" bson:"lastcheckin" yaml:"lastcheckin" swaggertype:"primitive,integer" format:"int64"` MacAddress string `json:"macaddress" bson:"macaddress" yaml:"macaddress"` Password string `json:"password" bson:"password" yaml:"password" validate:"required,min=6"` Network string `json:"network" bson:"network" yaml:"network" validate:"network_exists"` diff --git a/models/structs.go b/models/structs.go index 469046f1f..e929e7fc7 100644 --- a/models/structs.go +++ b/models/structs.go @@ -196,7 +196,7 @@ type ServerUpdateData struct { // also contains assymetrical encryption pub/priv keys for any server traffic type Telemetry struct { 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"` TrafficKeyPub []byte `json:"traffickeypub" bson:"traffickeypub"` } diff --git a/pro/types.go b/pro/types.go index 213d77bf8..4c1c85bbe 100644 --- a/pro/types.go +++ b/pro/types.go @@ -18,7 +18,7 @@ var errValidation = errors.New(license_validation_err_msg) // LicenseKey - the license key struct representation with associated data type LicenseKey struct { 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"` UsageUsers int `json:"limit_users"` UsageClients int `json:"limit_clients"` diff --git a/swagger.yaml b/swagger.yaml index 566597274..d264ff341 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -158,6 +158,7 @@ definitions: models.APIEnrollmentKey: properties: expiration: + format: int64 type: integer groups: items: @@ -305,6 +306,7 @@ definitions: type: string type: array expdatetime: + format: int64 type: integer fail_over_peers: additionalProperties: @@ -348,8 +350,10 @@ definitions: format: int64 type: integer lastmodified: + format: int64 type: integer lastpeerupdate: + format: int64 type: integer localaddress: type: string @@ -522,6 +526,7 @@ definitions: ingressgatewayid: type: string lastmodified: + format: int64 type: integer network: type: string @@ -862,22 +867,29 @@ definitions: connected: type: boolean lasttotalreceived: + format: int64 type: integer lasttotalsent: + format: int64 type: integer latency: + format: int64 type: integer node_name: type: string percentup: type: number totalreceived: + format: int64 type: integer totalsent: + format: int64 type: integer totaltime: + format: int64 type: integer uptime: + format: int64 type: integer type: object models.Metrics: @@ -929,10 +941,12 @@ definitions: minLength: 1 type: string networklastmodified: + format: int64 type: integer nodelimit: type: integer nodeslastmodified: + format: int64 type: integer required: - netid @@ -1402,6 +1416,8 @@ definitions: - 1000000000 - 60000000000 - 3600000000000 + - -9223372036854775808 + - 9223372036854775807 - 1 - 1000 - 1000000 @@ -1418,6 +1434,8 @@ definitions: - Second - Minute - Hour + - minDuration + - maxDuration - Nanosecond - Microsecond - Millisecond