mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-26 21:05:30 +00:00
fix additionProperties in JSONSchema and add IDs to everything
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
)
|
||||
|
||||
var ApiConfigSchema = jsonschema.Schema{
|
||||
ID: "https://showbridge.io/api.schema.json",
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"enabled": {
|
||||
@@ -22,6 +23,7 @@ var ApiConfigSchema = jsonschema.Schema{
|
||||
Default: json.RawMessage(`8080`),
|
||||
},
|
||||
},
|
||||
Required: []string{"port"},
|
||||
Default: json.RawMessage(`{"enabled": false, "port": 8080}`),
|
||||
Required: []string{"port"},
|
||||
Default: json.RawMessage(`{"enabled": false, "port": 8080}`),
|
||||
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ var ConfigSchema = jsonschema.Schema{
|
||||
Ref: "https://showbridge.io/routes.schema.json",
|
||||
},
|
||||
},
|
||||
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
|
||||
}
|
||||
|
||||
func ApplyDefaults(cfg *map[string]any) error {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/module"
|
||||
)
|
||||
@@ -13,11 +15,13 @@ func GetModulesSchema() *jsonschema.Schema {
|
||||
Title: "Modules",
|
||||
Description: "module configurations",
|
||||
Type: "array",
|
||||
Default: json.RawMessage(`[]`),
|
||||
}
|
||||
|
||||
moduleDefinitionSchemas := []*jsonschema.Schema{}
|
||||
for _, mod := range module.ModuleRegistry {
|
||||
moduleSchema := &jsonschema.Schema{
|
||||
ID: mod.Type,
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"id": {
|
||||
@@ -29,7 +33,7 @@ func GetModulesSchema() *jsonschema.Schema {
|
||||
},
|
||||
},
|
||||
Required: []string{"id", "type"},
|
||||
AdditionalProperties: nil,
|
||||
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
|
||||
}
|
||||
if mod.Title != "" {
|
||||
moduleSchema.Title = mod.Title
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/processor"
|
||||
)
|
||||
@@ -13,11 +15,13 @@ func GetProcessorsSchema() *jsonschema.Schema {
|
||||
Title: "Processors",
|
||||
Description: "processor configurations",
|
||||
Type: "array",
|
||||
Default: json.RawMessage(`[]`),
|
||||
}
|
||||
|
||||
processorDefinitionSchemas := []*jsonschema.Schema{}
|
||||
for _, proc := range processor.ProcessorRegistry {
|
||||
processorSchema := &jsonschema.Schema{
|
||||
ID: proc.Type,
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"type": {
|
||||
@@ -25,7 +29,7 @@ func GetProcessorsSchema() *jsonschema.Schema {
|
||||
},
|
||||
},
|
||||
Required: []string{"type"},
|
||||
AdditionalProperties: nil,
|
||||
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
|
||||
}
|
||||
if proc.Title != "" {
|
||||
processorSchema.Title = proc.Title
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package schema
|
||||
|
||||
import "github.com/google/jsonschema-go/jsonschema"
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
)
|
||||
|
||||
var RoutesConfigSchema = jsonschema.Schema{
|
||||
Schema: "https://json-schema.org/draft/2020-12/schema",
|
||||
@@ -19,6 +23,8 @@ var RoutesConfigSchema = jsonschema.Schema{
|
||||
Ref: "https://showbridge.io/processors.schema.json",
|
||||
},
|
||||
},
|
||||
Required: []string{"input"},
|
||||
Required: []string{"input"},
|
||||
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
|
||||
},
|
||||
Default: json.RawMessage(`[]`),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user