swag - use pascalcase for properties (#54)

Co-authored-by: Markus Koetter <koetter@cispa.de>
This commit is contained in:
commonism 2021-09-27 20:28:03 +02:00 committed by GitHub
parent 9147fe33cb
commit 93db475eee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 112 additions and 102 deletions

View File

@ -52,7 +52,7 @@ docker-push:
docker push $(IMAGE) docker push $(IMAGE)
api-docs: api-docs:
cd internal/server; swag init --parseDependency --parseInternal --generalInfo api.go cd internal/server; swag init --propertyStrategy pascalcase --parseDependency --parseInternal --generalInfo api.go
$(GOCMD) fmt internal/server/docs/docs.go $(GOCMD) fmt internal/server/docs/docs.go
$(BUILDDIR)/%-amd64: cmd/%/main.go dep phony $(BUILDDIR)/%-amd64: cmd/%/main.go dep phony

View File

@ -1,14 +1,13 @@
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag // This file was generated by swaggo/swag
package docs package docs
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"strings" "strings"
"text/template"
"github.com/alecthomas/template"
"github.com/swaggo/swag" "github.com/swaggo/swag"
) )
@ -16,7 +15,7 @@ var doc = `{
"schemes": {{ marshal .Schemes }}, "schemes": {{ marshal .Schemes }},
"swagger": "2.0", "swagger": "2.0",
"info": { "info": {
"description": "{{.Description}}", "description": "{{escape .Description}}",
"title": "{{.Title}}", "title": "{{.Title}}",
"contact": { "contact": {
"name": "WireGuard Portal Project", "name": "WireGuard Portal Project",
@ -1203,10 +1202,10 @@ var doc = `{
"gorm.DeletedAt": { "gorm.DeletedAt": {
"type": "object", "type": "object",
"properties": { "properties": {
"time": { "Time": {
"type": "string" "type": "string"
}, },
"valid": { "Valid": {
"description": "Valid is true if Time is not NULL", "description": "Valid is true if Time is not NULL",
"type": "boolean" "type": "boolean"
} }
@ -1215,7 +1214,7 @@ var doc = `{
"server.ApiError": { "server.ApiError": {
"type": "object", "type": "object",
"properties": { "properties": {
"message": { "Message": {
"type": "string" "type": "string"
} }
} }
@ -1223,16 +1222,16 @@ var doc = `{
"server.PeerDeploymentInformation": { "server.PeerDeploymentInformation": {
"type": "object", "type": "object",
"properties": { "properties": {
"device": { "Device": {
"type": "string" "type": "string"
}, },
"deviceIdentifier": { "DeviceIdentifier": {
"type": "string" "type": "string"
}, },
"identifier": { "Identifier": {
"type": "string" "type": "string"
}, },
"publicKey": { "PublicKey": {
"type": "string" "type": "string"
} }
} }
@ -1240,30 +1239,30 @@ var doc = `{
"server.ProvisioningRequest": { "server.ProvisioningRequest": {
"type": "object", "type": "object",
"required": [ "required": [
"email", "Email",
"identifier" "Identifier"
], ],
"properties": { "properties": {
"allowedIPsStr": { "AllowedIPsStr": {
"type": "string" "type": "string"
}, },
"deviceName": { "DNSStr": {
"type": "string"
},
"DeviceName": {
"description": "DeviceName is optional, if not specified, the configured default device will be used.", "description": "DeviceName is optional, if not specified, the configured default device will be used.",
"type": "string" "type": "string"
}, },
"dnsstr": { "Email": {
"type": "string" "type": "string"
}, },
"email": { "Identifier": {
"type": "string" "type": "string"
}, },
"identifier": { "Mtu": {
"type": "string"
},
"mtu": {
"type": "integer" "type": "integer"
}, },
"persistentKeepalive": { "PersistentKeepalive": {
"type": "integer" "type": "integer"
} }
} }
@ -1271,43 +1270,43 @@ var doc = `{
"users.User": { "users.User": {
"type": "object", "type": "object",
"required": [ "required": [
"email", "Email",
"firstname", "Firstname",
"lastname" "Lastname"
], ],
"properties": { "properties": {
"createdAt": { "CreatedAt": {
"description": "database internal fields", "description": "database internal fields",
"type": "string" "type": "string"
}, },
"deletedAt": { "DeletedAt": {
"$ref": "#/definitions/gorm.DeletedAt" "$ref": "#/definitions/gorm.DeletedAt"
}, },
"email": { "Email": {
"description": "required fields", "description": "required fields",
"type": "string" "type": "string"
}, },
"firstname": { "Firstname": {
"description": "optional fields", "description": "optional fields",
"type": "string" "type": "string"
}, },
"isAdmin": { "IsAdmin": {
"type": "boolean" "type": "boolean"
}, },
"lastname": { "Lastname": {
"type": "string" "type": "string"
}, },
"password": { "Password": {
"description": "optional, integrated password authentication", "description": "optional, integrated password authentication",
"type": "string" "type": "string"
}, },
"phone": { "Phone": {
"type": "string" "type": "string"
}, },
"source": { "Source": {
"type": "string" "type": "string"
}, },
"updatedAt": { "UpdatedAt": {
"type": "string" "type": "string"
} }
} }
@ -1315,87 +1314,87 @@ var doc = `{
"wireguard.Device": { "wireguard.Device": {
"type": "object", "type": "object",
"required": [ "required": [
"deviceName", "DeviceName",
"ipsStr", "IPsStr",
"privateKey", "PrivateKey",
"publicKey", "PublicKey",
"type" "Type"
], ],
"properties": { "properties": {
"createdAt": { "CreatedAt": {
"type": "string" "type": "string"
}, },
"defaultAllowedIPsStr": { "DNSStr": {
"description": "comma separated list of IPs that are used in the client config file",
"type": "string"
},
"defaultEndpoint": {
"description": "Settings that are applied to all peer by default",
"type": "string"
},
"defaultPersistentKeepalive": {
"type": "integer"
},
"deviceName": {
"type": "string"
},
"displayName": {
"type": "string"
},
"dnsstr": {
"description": "comma separated list of the DNS servers of the client, wg-quick addition", "description": "comma separated list of the DNS servers of the client, wg-quick addition",
"type": "string" "type": "string"
}, },
"firewallMark": { "DefaultAllowedIPsStr": {
"description": "comma separated list of IPs that are used in the client config file",
"type": "string"
},
"DefaultEndpoint": {
"description": "Settings that are applied to all peer by default",
"type": "string"
},
"DefaultPersistentKeepalive": {
"type": "integer" "type": "integer"
}, },
"ipsStr": { "DeviceName": {
"type": "string"
},
"DisplayName": {
"type": "string"
},
"FirewallMark": {
"type": "integer"
},
"IPsStr": {
"description": "comma separated list of the IPs of the client, wg-quick addition", "description": "comma separated list of the IPs of the client, wg-quick addition",
"type": "string" "type": "string"
}, },
"listenPort": { "ListenPort": {
"type": "integer" "type": "integer"
}, },
"mtu": { "Mtu": {
"description": "the interface MTU, wg-quick addition", "description": "the interface MTU, wg-quick addition",
"type": "integer" "type": "integer"
}, },
"postDown": { "PostDown": {
"description": "post down script, wg-quick addition", "description": "post down script, wg-quick addition",
"type": "string" "type": "string"
}, },
"postUp": { "PostUp": {
"description": "post up script, wg-quick addition", "description": "post up script, wg-quick addition",
"type": "string" "type": "string"
}, },
"preDown": { "PreDown": {
"description": "pre down script, wg-quick addition", "description": "pre down script, wg-quick addition",
"type": "string" "type": "string"
}, },
"preUp": { "PreUp": {
"description": "pre up script, wg-quick addition", "description": "pre up script, wg-quick addition",
"type": "string" "type": "string"
}, },
"privateKey": { "PrivateKey": {
"description": "Core WireGuard Settings (Interface section)", "description": "Core WireGuard Settings (Interface section)",
"type": "string" "type": "string"
}, },
"publicKey": { "PublicKey": {
"description": "Misc. WireGuard Settings", "description": "Misc. WireGuard Settings",
"type": "string" "type": "string"
}, },
"routingTable": { "RoutingTable": {
"description": "the routing table, wg-quick addition", "description": "the routing table, wg-quick addition",
"type": "string" "type": "string"
}, },
"saveConfig": { "SaveConfig": {
"description": "if set to ` + "`" + `true', the configuration is saved from the current state of the interface upon shutdown, wg-quick addition", "description": "if set to ` + "`" + `true', the configuration is saved from the current state of the interface upon shutdown, wg-quick addition",
"type": "boolean" "type": "boolean"
}, },
"type": { "Type": {
"type": "string" "type": "string"
}, },
"updatedAt": { "UpdatedAt": {
"type": "string" "type": "string"
} }
} }
@ -1403,71 +1402,75 @@ var doc = `{
"wireguard.Peer": { "wireguard.Peer": {
"type": "object", "type": "object",
"required": [ "required": [
"deviceName", "DeviceName",
"email", "Email",
"identifier", "Identifier",
"publicKey" "PublicKey"
], ],
"properties": { "properties": {
"allowedIPsStr": { "AllowedIPsSrvStr": {
"description": "a comma separated list of IPs that are used in the server config file",
"type": "string"
},
"AllowedIPsStr": {
"description": "a comma separated list of IPs that are used in the client config file", "description": "a comma separated list of IPs that are used in the client config file",
"type": "string" "type": "string"
}, },
"createdAt": { "CreatedAt": {
"type": "string" "type": "string"
}, },
"createdBy": { "CreatedBy": {
"type": "string" "type": "string"
}, },
"deactivatedAt": { "DNSStr": {
"type": "string"
},
"deviceName": {
"type": "string"
},
"dnsstr": {
"description": "comma separated list of the DNS servers for the client", "description": "comma separated list of the DNS servers for the client",
"type": "string" "type": "string"
}, },
"email": { "DeactivatedAt": {
"type": "string" "type": "string"
}, },
"endpoint": { "DeviceName": {
"type": "string" "type": "string"
}, },
"identifier": { "Email": {
"description": "Identifier AND Email make a WireGuard peer unique",
"type": "string" "type": "string"
}, },
"ignoreGlobalSettings": { "Endpoint": {
"type": "boolean" "type": "string"
}, },
"ipsStr": { "IPsStr": {
"description": "a comma separated list of IPs of the client", "description": "a comma separated list of IPs of the client",
"type": "string" "type": "string"
}, },
"mtu": { "Identifier": {
"description": "Identifier AND Email make a WireGuard peer unique",
"type": "string"
},
"IgnoreGlobalSettings": {
"type": "boolean"
},
"Mtu": {
"description": "Global Device Settings (can be ignored, only make sense if device is in server mode)", "description": "Global Device Settings (can be ignored, only make sense if device is in server mode)",
"type": "integer" "type": "integer"
}, },
"persistentKeepalive": { "PersistentKeepalive": {
"type": "integer" "type": "integer"
}, },
"presharedKey": { "PresharedKey": {
"type": "string" "type": "string"
}, },
"privateKey": { "PrivateKey": {
"description": "Misc. WireGuard Settings", "description": "Misc. WireGuard Settings",
"type": "string" "type": "string"
}, },
"publicKey": { "PublicKey": {
"description": "Core WireGuard Settings", "description": "Core WireGuard Settings",
"type": "string" "type": "string"
}, },
"updatedAt": { "UpdatedAt": {
"type": "string" "type": "string"
}, },
"updatedBy": { "UpdatedBy": {
"type": "string" "type": "string"
} }
} }
@ -1513,6 +1516,13 @@ func (s *s) ReadDoc() string {
a, _ := json.Marshal(v) a, _ := json.Marshal(v)
return string(a) return string(a)
}, },
"escape": func(v interface{}) string {
// escape tabs
str := strings.Replace(v.(string), "\t", "\\t", -1)
// replace " with \", and if that results in \\", replace that with \\\"
str = strings.Replace(str, "\"", "\\\"", -1)
return strings.Replace(str, "\\\\\"", "\\\\\\\"", -1)
},
}).Parse(doc) }).Parse(doc)
if err != nil { if err != nil {
return doc return doc