mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-26 21:05:30 +00:00
generate json-schema dynamically in Go
This commit is contained in:
@@ -2,6 +2,7 @@ package module
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -15,6 +16,7 @@ import (
|
||||
"github.com/emiago/diago/media"
|
||||
"github.com/emiago/sipgo"
|
||||
"github.com/emiago/sipgo/sip"
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
"github.com/jwetzell/showbridge-go/internal/processor"
|
||||
@@ -45,7 +47,44 @@ type SIPDTMFCall struct {
|
||||
|
||||
func init() {
|
||||
RegisterModule(ModuleRegistration{
|
||||
Type: "sip.dtmf.server",
|
||||
Type: "sip.dtmf.server",
|
||||
Title: "SIP DTMF Server",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"ip": {
|
||||
Title: "IP",
|
||||
Type: "string",
|
||||
Default: json.RawMessage(`"0.0.0.0"`),
|
||||
},
|
||||
"port": {
|
||||
Title: "Port",
|
||||
Type: "integer",
|
||||
Minimum: jsonschema.Ptr[float64](1024),
|
||||
Maximum: jsonschema.Ptr[float64](65535),
|
||||
Default: json.RawMessage(`5060`),
|
||||
},
|
||||
"transport": {
|
||||
Title: "Transport",
|
||||
Type: "string",
|
||||
Enum: []any{"udp", "tcp", "ws", "udp4", "tcp4"},
|
||||
Default: json.RawMessage(`"udp"`),
|
||||
},
|
||||
"userAgent": {
|
||||
Title: "User Agent",
|
||||
Type: "string",
|
||||
Default: json.RawMessage(`"showbridge"`),
|
||||
},
|
||||
"separator": {
|
||||
Title: "DTMF Separator",
|
||||
Type: "string",
|
||||
MinLength: jsonschema.Ptr(1),
|
||||
MaxLength: jsonschema.Ptr(1),
|
||||
},
|
||||
},
|
||||
Required: []string{"separator"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(moduleConfig config.ModuleConfig) (common.Module, error) {
|
||||
params := moduleConfig.Params
|
||||
|
||||
|
||||
Reference in New Issue
Block a user