sort processor and module schemas by ID

This commit is contained in:
Joel Wetzell
2026-09-11 09:21:46 -05:00
parent f204b58763
commit 757612fd0e
3 changed files with 10 additions and 0 deletions
+2
View File
@@ -2,6 +2,7 @@ package schema
import (
"encoding/json"
"slices"
"github.com/google/jsonschema-go/jsonschema"
"github.com/jwetzell/showbridge-go/internal/module"
@@ -49,6 +50,7 @@ func GetModulesSchema() *jsonschema.Schema {
}
moduleDefinitionSchemas = append(moduleDefinitionSchemas, moduleSchema)
}
slices.SortFunc(moduleDefinitionSchemas, schemaCmp)
schema.Items = &jsonschema.Schema{
OneOf: moduleDefinitionSchemas,
}
+3
View File
@@ -2,6 +2,7 @@ package schema
import (
"encoding/json"
"slices"
"github.com/google/jsonschema-go/jsonschema"
"github.com/jwetzell/showbridge-go/internal/processor"
@@ -49,6 +50,8 @@ func GetProcessorsSchema() *jsonschema.Schema {
}
processorDefinitionSchemas = append(processorDefinitionSchemas, processorSchema)
}
slices.SortFunc(processorDefinitionSchemas, schemaCmp)
schema.Items = &jsonschema.Schema{
OneOf: processorDefinitionSchemas,
}
+5
View File
@@ -1,6 +1,7 @@
package schema
import (
"cmp"
"fmt"
"net/url"
@@ -24,3 +25,7 @@ func GetResolvedConfigSchema() (*jsonschema.Resolved, error) {
ValidateDefaults: true,
})
}
func schemaCmp(a, b *jsonschema.Schema) int {
return cmp.Compare(a.ID, b.ID)
}