move schema to an internal package

This commit is contained in:
Joel Wetzell
2026-03-23 12:51:26 -05:00
parent 256eeac6a8
commit 9a50ca8cfe
12 changed files with 223 additions and 159 deletions

View File

@@ -45,45 +45,3 @@ var (
processorRegistryMu sync.RWMutex
ProcessorRegistry = make(map[string]ProcessorRegistration)
)
func GetProcessorsSchema() *jsonschema.Schema {
processorRegistryMu.RLock()
defer processorRegistryMu.RUnlock()
schema := &jsonschema.Schema{
Schema: "https://json-schema.org/draft/2020-12/schema",
ID: "https://showbridge.io/processors.schema.json",
Title: "Processors",
Description: "processor configurations",
Type: "array",
}
processorDefinitionSchemas := []*jsonschema.Schema{}
for _, proc := range ProcessorRegistry {
processorSchema := &jsonschema.Schema{
Type: "object",
Properties: map[string]*jsonschema.Schema{
"type": {
Const: jsonschema.Ptr[any](proc.Type),
},
},
Required: []string{"type"},
AdditionalProperties: nil,
}
if proc.Title != "" {
processorSchema.Title = proc.Title
}
if proc.Description != "" {
processorSchema.Description = proc.Description
}
if proc.ParamsSchema != nil {
processorSchema.Properties["params"] = proc.ParamsSchema
processorSchema.Required = append(processorSchema.Required, "params")
}
processorDefinitionSchemas = append(processorDefinitionSchemas, processorSchema)
}
schema.Items = &jsonschema.Schema{
OneOf: processorDefinitionSchemas,
}
return schema
}