Moved v3 code from NginxProxyManager/nginx-proxy-manager-3 to NginxProxyManager/nginx-proxy-manager
This commit is contained in:
209
backend/internal/api/schema/certificates.go
Normal file
209
backend/internal/api/schema/certificates.go
Normal file
@ -0,0 +1,209 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"npm/internal/entity/certificate"
|
||||
)
|
||||
|
||||
// This validation is strictly for Custom certificates
|
||||
// and the combination of values that must be defined
|
||||
func createCertificateCustom() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"type",
|
||||
"name",
|
||||
"domain_names"
|
||||
],
|
||||
"properties": {
|
||||
"type": %s,
|
||||
"name": %s,
|
||||
"domain_names": %s,
|
||||
"meta": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}`, strictString("custom"), stringMinMax(1, 100), domainNames())
|
||||
}
|
||||
|
||||
// This validation is strictly for HTTP certificates
|
||||
// and the combination of values that must be defined
|
||||
func createCertificateHTTP() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"type",
|
||||
"certificate_authority_id",
|
||||
"name",
|
||||
"domain_names"
|
||||
],
|
||||
"properties": {
|
||||
"type": %s,
|
||||
"certificate_authority_id": %s,
|
||||
"name": %s,
|
||||
"domain_names": %s,
|
||||
"meta": {
|
||||
"type": "object"
|
||||
},
|
||||
"is_ecc": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 1
|
||||
}
|
||||
}
|
||||
}`, strictString("http"), intMinOne, stringMinMax(1, 100), domainNames())
|
||||
}
|
||||
|
||||
// This validation is strictly for DNS certificates
|
||||
// and the combination of values that must be defined
|
||||
func createCertificateDNS() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"type",
|
||||
"certificate_authority_id",
|
||||
"dns_provider_id",
|
||||
"name",
|
||||
"domain_names"
|
||||
],
|
||||
"properties": {
|
||||
"type": %s,
|
||||
"certificate_authority_id": %s,
|
||||
"dns_provider_id": %s,
|
||||
"name": %s,
|
||||
"domain_names": %s,
|
||||
"meta": {
|
||||
"type": "object"
|
||||
},
|
||||
"is_ecc": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 1
|
||||
}
|
||||
}
|
||||
}`, strictString("dns"), intMinOne, intMinOne, stringMinMax(1, 100), domainNames())
|
||||
}
|
||||
|
||||
// This validation is strictly for MKCERT certificates
|
||||
// and the combination of values that must be defined
|
||||
func createCertificateMkcert() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"type",
|
||||
"name",
|
||||
"domain_names"
|
||||
],
|
||||
"properties": {
|
||||
"type": %s,
|
||||
"name": %s,
|
||||
"domain_names": %s,
|
||||
"meta": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}`, strictString("mkcert"), stringMinMax(1, 100), domainNames())
|
||||
}
|
||||
|
||||
func updateCertificateHTTP() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"minProperties": 1,
|
||||
"properties": {
|
||||
"certificate_authority_id": %s,
|
||||
"name": %s,
|
||||
"domain_names": %s,
|
||||
"meta": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}`, intMinOne, stringMinMax(1, 100), domainNames())
|
||||
}
|
||||
|
||||
func updateCertificateDNS() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"minProperties": 1,
|
||||
"properties": {
|
||||
"certificate_authority_id": %s,
|
||||
"dns_provider_id": %s,
|
||||
"name": %s,
|
||||
"domain_names": %s,
|
||||
"meta": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}`, intMinOne, intMinOne, stringMinMax(1, 100), domainNames())
|
||||
}
|
||||
|
||||
func updateCertificateCustom() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"minProperties": 1,
|
||||
"properties": {
|
||||
"name": %s,
|
||||
"domain_names": %s,
|
||||
"meta": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}`, stringMinMax(1, 100), domainNames())
|
||||
}
|
||||
|
||||
func updateCertificateMkcert() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"minProperties": 1,
|
||||
"properties": {
|
||||
"name": %s,
|
||||
"domain_names": %s,
|
||||
"meta": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}`, stringMinMax(1, 100), domainNames())
|
||||
}
|
||||
|
||||
// CreateCertificate is the schema for incoming data validation
|
||||
func CreateCertificate() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"oneOf": [%s, %s, %s, %s]
|
||||
}`, createCertificateHTTP(), createCertificateDNS(), createCertificateCustom(), createCertificateMkcert())
|
||||
}
|
||||
|
||||
// UpdateCertificate is the schema for incoming data validation
|
||||
func UpdateCertificate(certificateType string) string {
|
||||
switch certificateType {
|
||||
case certificate.TypeHTTP:
|
||||
return updateCertificateHTTP()
|
||||
case certificate.TypeDNS:
|
||||
return updateCertificateDNS()
|
||||
case certificate.TypeCustom:
|
||||
return updateCertificateCustom()
|
||||
case certificate.TypeMkcert:
|
||||
return updateCertificateMkcert()
|
||||
default:
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"oneOf": [%s, %s, %s, %s]
|
||||
}`, updateCertificateHTTP(), updateCertificateDNS(), updateCertificateCustom(), updateCertificateMkcert())
|
||||
}
|
||||
}
|
70
backend/internal/api/schema/common.go
Normal file
70
backend/internal/api/schema/common.go
Normal file
@ -0,0 +1,70 @@
|
||||
package schema
|
||||
|
||||
import "fmt"
|
||||
|
||||
func strictString(value string) string {
|
||||
return fmt.Sprintf(`{
|
||||
"type": "string",
|
||||
"pattern": "^%s$"
|
||||
}`, value)
|
||||
}
|
||||
|
||||
const intMinOne = `
|
||||
{
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
}
|
||||
`
|
||||
|
||||
const boolean = `
|
||||
{
|
||||
"type": "boolean"
|
||||
}
|
||||
`
|
||||
|
||||
func stringMinMax(minLength, maxLength int) string {
|
||||
return fmt.Sprintf(`{
|
||||
"type": "string",
|
||||
"minLength": %d,
|
||||
"maxLength": %d
|
||||
}`, minLength, maxLength)
|
||||
}
|
||||
|
||||
func capabilties() string {
|
||||
return `{
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
}`
|
||||
}
|
||||
|
||||
func domainNames() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": %s
|
||||
}`, stringMinMax(4, 255))
|
||||
}
|
||||
|
||||
const anyType = `
|
||||
{
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"type": "integer"
|
||||
}
|
||||
]
|
||||
}
|
||||
`
|
25
backend/internal/api/schema/create_certificate_authority.go
Normal file
25
backend/internal/api/schema/create_certificate_authority.go
Normal file
@ -0,0 +1,25 @@
|
||||
package schema
|
||||
|
||||
import "fmt"
|
||||
|
||||
// CreateCertificateAuthority is the schema for incoming data validation
|
||||
func CreateCertificateAuthority() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"name",
|
||||
"acmesh_server",
|
||||
"max_domains"
|
||||
],
|
||||
"properties": {
|
||||
"name": %s,
|
||||
"acmesh_server": %s,
|
||||
"max_domains": %s,
|
||||
"ca_bundle": %s,
|
||||
"is_wildcard_supported": %s
|
||||
}
|
||||
}
|
||||
`, stringMinMax(1, 100), stringMinMax(2, 255), intMinOne, stringMinMax(2, 255), boolean)
|
||||
}
|
51
backend/internal/api/schema/create_dns_provider.go
Normal file
51
backend/internal/api/schema/create_dns_provider.go
Normal file
@ -0,0 +1,51 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"npm/internal/dnsproviders"
|
||||
"npm/internal/util"
|
||||
)
|
||||
|
||||
// CreateDNSProvider is the schema for incoming data validation
|
||||
func CreateDNSProvider() string {
|
||||
allProviders := dnsproviders.GetAll()
|
||||
fmtStr := fmt.Sprintf(`{"oneOf": [%s]}`, strings.TrimRight(strings.Repeat("\n%s,", len(allProviders)), ","))
|
||||
|
||||
allSchemasWrapped := make([]string, 0)
|
||||
for providerName, provider := range allProviders {
|
||||
allSchemasWrapped = append(allSchemasWrapped, createDNSProviderType(providerName, provider.Schema))
|
||||
}
|
||||
|
||||
return fmt.Sprintf(fmtStr, util.ConvertStringSliceToInterface(allSchemasWrapped)...)
|
||||
}
|
||||
|
||||
func createDNSProviderType(name, metaSchema string) string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"acmesh_name",
|
||||
"name",
|
||||
"meta"
|
||||
],
|
||||
"properties": {
|
||||
"acmesh_name": {
|
||||
"type": "string",
|
||||
"pattern": "^%s$"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 100
|
||||
},
|
||||
"dns_sleep": {
|
||||
"type": "integer"
|
||||
},
|
||||
"meta": %s
|
||||
}
|
||||
}
|
||||
`, name, metaSchema)
|
||||
}
|
80
backend/internal/api/schema/create_host.go
Normal file
80
backend/internal/api/schema/create_host.go
Normal file
@ -0,0 +1,80 @@
|
||||
package schema
|
||||
|
||||
import "fmt"
|
||||
|
||||
// CreateHost is the schema for incoming data validation
|
||||
// This schema supports 3 possible types with different data combinations:
|
||||
// - proxy
|
||||
// - redirection
|
||||
// - dead
|
||||
func CreateHost() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"type",
|
||||
"domain_names",
|
||||
"host_template_id"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"pattern": "^proxy$"
|
||||
},
|
||||
"host_template_id": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"listen_interface": %s,
|
||||
"domain_names": %s,
|
||||
"upstream_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"certificate_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"access_list_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ssl_forced": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"caching_enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"block_exploits": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"allow_websocket_upgrade": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"http2_support": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hsts_enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hsts_subdomains": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"paths": {
|
||||
"type": "string"
|
||||
},
|
||||
"upstream_options": {
|
||||
"type": "string"
|
||||
},
|
||||
"advanced_config": {
|
||||
"type": "string"
|
||||
},
|
||||
"is_disabled": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
`, stringMinMax(0, 255), domainNames())
|
||||
}
|
30
backend/internal/api/schema/create_host_template.go
Normal file
30
backend/internal/api/schema/create_host_template.go
Normal file
@ -0,0 +1,30 @@
|
||||
package schema
|
||||
|
||||
// CreateHostTemplate is the schema for incoming data validation
|
||||
func CreateHostTemplate() string {
|
||||
return `
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"name",
|
||||
"host_type",
|
||||
"template"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"host_type": {
|
||||
"type": "string",
|
||||
"pattern": "^proxy|redirect|dead|stream$"
|
||||
},
|
||||
"template": {
|
||||
"type": "string",
|
||||
"minLength": 20
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
}
|
21
backend/internal/api/schema/create_setting.go
Normal file
21
backend/internal/api/schema/create_setting.go
Normal file
@ -0,0 +1,21 @@
|
||||
package schema
|
||||
|
||||
import "fmt"
|
||||
|
||||
// CreateSetting is the schema for incoming data validation
|
||||
func CreateSetting() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"name",
|
||||
"value"
|
||||
],
|
||||
"properties": {
|
||||
"name": %s,
|
||||
"value": %s
|
||||
}
|
||||
}
|
||||
`, stringMinMax(2, 100), anyType)
|
||||
}
|
27
backend/internal/api/schema/create_stream.go
Normal file
27
backend/internal/api/schema/create_stream.go
Normal file
@ -0,0 +1,27 @@
|
||||
package schema
|
||||
|
||||
import "fmt"
|
||||
|
||||
// CreateStream is the schema for incoming data validation
|
||||
func CreateStream() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"provider",
|
||||
"name",
|
||||
"domain_names"
|
||||
],
|
||||
"properties": {
|
||||
"provider": %s,
|
||||
"name": %s,
|
||||
"domain_names": %s,
|
||||
"expires_on": %s,
|
||||
"meta": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
`, stringMinMax(2, 100), stringMinMax(1, 100), domainNames(), intMinOne)
|
||||
}
|
42
backend/internal/api/schema/create_user.go
Normal file
42
backend/internal/api/schema/create_user.go
Normal file
@ -0,0 +1,42 @@
|
||||
package schema
|
||||
|
||||
import "fmt"
|
||||
|
||||
// CreateUser is the schema for incoming data validation
|
||||
func CreateUser() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"name",
|
||||
"email",
|
||||
"is_disabled",
|
||||
"capabilities"
|
||||
],
|
||||
"properties": {
|
||||
"name": %s,
|
||||
"nickname": %s,
|
||||
"email": %s,
|
||||
"is_disabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"auth": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type",
|
||||
"secret"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"pattern": "^password$"
|
||||
},
|
||||
"secret": %s
|
||||
}
|
||||
},
|
||||
"capabilities": %s
|
||||
}
|
||||
}
|
||||
`, stringMinMax(2, 100), stringMinMax(2, 100), stringMinMax(5, 150), stringMinMax(8, 255), capabilties())
|
||||
}
|
28
backend/internal/api/schema/get_token.go
Normal file
28
backend/internal/api/schema/get_token.go
Normal file
@ -0,0 +1,28 @@
|
||||
package schema
|
||||
|
||||
import "fmt"
|
||||
|
||||
// GetToken is the schema for incoming data validation
|
||||
// nolint: gosec
|
||||
func GetToken() string {
|
||||
stdField := stringMinMax(1, 255)
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"type",
|
||||
"identity",
|
||||
"secret"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"pattern": "^password$"
|
||||
},
|
||||
"identity": %s,
|
||||
"secret": %s
|
||||
}
|
||||
}
|
||||
`, stdField, stdField)
|
||||
}
|
25
backend/internal/api/schema/set_auth.go
Normal file
25
backend/internal/api/schema/set_auth.go
Normal file
@ -0,0 +1,25 @@
|
||||
package schema
|
||||
|
||||
import "fmt"
|
||||
|
||||
// SetAuth is the schema for incoming data validation
|
||||
func SetAuth() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"type",
|
||||
"secret"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"pattern": "^password$"
|
||||
},
|
||||
"secret": %s,
|
||||
"current_secret": %s
|
||||
}
|
||||
}
|
||||
`, stringMinMax(8, 225), stringMinMax(8, 225))
|
||||
}
|
21
backend/internal/api/schema/update_certificate_authority.go
Normal file
21
backend/internal/api/schema/update_certificate_authority.go
Normal file
@ -0,0 +1,21 @@
|
||||
package schema
|
||||
|
||||
import "fmt"
|
||||
|
||||
// UpdateCertificateAuthority is the schema for incoming data validation
|
||||
func UpdateCertificateAuthority() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"minProperties": 1,
|
||||
"properties": {
|
||||
"name": %s,
|
||||
"acmesh_server": %s,
|
||||
"max_domains": %s,
|
||||
"ca_bundle": %s,
|
||||
"is_wildcard_supported": %s
|
||||
}
|
||||
}
|
||||
`, stringMinMax(1, 100), stringMinMax(2, 255), intMinOne, stringMinMax(2, 255), boolean)
|
||||
}
|
20
backend/internal/api/schema/update_dns_provider.go
Normal file
20
backend/internal/api/schema/update_dns_provider.go
Normal file
@ -0,0 +1,20 @@
|
||||
package schema
|
||||
|
||||
import "fmt"
|
||||
|
||||
// UpdateDNSProvider is the schema for incoming data validation
|
||||
func UpdateDNSProvider() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"minProperties": 1,
|
||||
"properties": {
|
||||
"name": %s,
|
||||
"meta": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
`, stringMinMax(1, 100))
|
||||
}
|
27
backend/internal/api/schema/update_host.go
Normal file
27
backend/internal/api/schema/update_host.go
Normal file
@ -0,0 +1,27 @@
|
||||
package schema
|
||||
|
||||
import "fmt"
|
||||
|
||||
// UpdateHost is the schema for incoming data validation
|
||||
func UpdateHost() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"minProperties": 1,
|
||||
"properties": {
|
||||
"host_template_id": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"provider": %s,
|
||||
"name": %s,
|
||||
"domain_names": %s,
|
||||
"expires_on": %s,
|
||||
"meta": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
`, stringMinMax(2, 100), stringMinMax(1, 100), domainNames(), intMinOne)
|
||||
}
|
22
backend/internal/api/schema/update_host_template.go
Normal file
22
backend/internal/api/schema/update_host_template.go
Normal file
@ -0,0 +1,22 @@
|
||||
package schema
|
||||
|
||||
// UpdateHostTemplate is the schema for incoming data validation
|
||||
func UpdateHostTemplate() string {
|
||||
return `
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"minProperties": 1,
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"template": {
|
||||
"type": "string",
|
||||
"minLength": 20
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
}
|
17
backend/internal/api/schema/update_setting.go
Normal file
17
backend/internal/api/schema/update_setting.go
Normal file
@ -0,0 +1,17 @@
|
||||
package schema
|
||||
|
||||
import "fmt"
|
||||
|
||||
// UpdateSetting is the schema for incoming data validation
|
||||
func UpdateSetting() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"minProperties": 1,
|
||||
"properties": {
|
||||
"value": %s
|
||||
}
|
||||
}
|
||||
`, anyType)
|
||||
}
|
23
backend/internal/api/schema/update_stream.go
Normal file
23
backend/internal/api/schema/update_stream.go
Normal file
@ -0,0 +1,23 @@
|
||||
package schema
|
||||
|
||||
import "fmt"
|
||||
|
||||
// UpdateStream is the schema for incoming data validation
|
||||
func UpdateStream() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"minProperties": 1,
|
||||
"properties": {
|
||||
"provider": %s,
|
||||
"name": %s,
|
||||
"domain_names": %s,
|
||||
"expires_on": %s,
|
||||
"meta": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
`, stringMinMax(2, 100), stringMinMax(1, 100), domainNames(), intMinOne)
|
||||
}
|
23
backend/internal/api/schema/update_user.go
Normal file
23
backend/internal/api/schema/update_user.go
Normal file
@ -0,0 +1,23 @@
|
||||
package schema
|
||||
|
||||
import "fmt"
|
||||
|
||||
// UpdateUser is the schema for incoming data validation
|
||||
func UpdateUser() string {
|
||||
return fmt.Sprintf(`
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"minProperties": 1,
|
||||
"properties": {
|
||||
"name": %s,
|
||||
"nickname": %s,
|
||||
"email": %s,
|
||||
"is_disabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"capabilities": %s
|
||||
}
|
||||
}
|
||||
`, stringMinMax(2, 100), stringMinMax(2, 100), stringMinMax(5, 150), capabilties())
|
||||
}
|
Reference in New Issue
Block a user