mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-09-12 08:29:25 +00:00
sort processor and module schemas by ID
This commit is contained in:
@@ -2,6 +2,7 @@ package schema
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"slices"
|
||||||
|
|
||||||
"github.com/google/jsonschema-go/jsonschema"
|
"github.com/google/jsonschema-go/jsonschema"
|
||||||
"github.com/jwetzell/showbridge-go/internal/module"
|
"github.com/jwetzell/showbridge-go/internal/module"
|
||||||
@@ -49,6 +50,7 @@ func GetModulesSchema() *jsonschema.Schema {
|
|||||||
}
|
}
|
||||||
moduleDefinitionSchemas = append(moduleDefinitionSchemas, moduleSchema)
|
moduleDefinitionSchemas = append(moduleDefinitionSchemas, moduleSchema)
|
||||||
}
|
}
|
||||||
|
slices.SortFunc(moduleDefinitionSchemas, schemaCmp)
|
||||||
schema.Items = &jsonschema.Schema{
|
schema.Items = &jsonschema.Schema{
|
||||||
OneOf: moduleDefinitionSchemas,
|
OneOf: moduleDefinitionSchemas,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package schema
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"slices"
|
||||||
|
|
||||||
"github.com/google/jsonschema-go/jsonschema"
|
"github.com/google/jsonschema-go/jsonschema"
|
||||||
"github.com/jwetzell/showbridge-go/internal/processor"
|
"github.com/jwetzell/showbridge-go/internal/processor"
|
||||||
@@ -49,6 +50,8 @@ func GetProcessorsSchema() *jsonschema.Schema {
|
|||||||
}
|
}
|
||||||
processorDefinitionSchemas = append(processorDefinitionSchemas, processorSchema)
|
processorDefinitionSchemas = append(processorDefinitionSchemas, processorSchema)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
slices.SortFunc(processorDefinitionSchemas, schemaCmp)
|
||||||
schema.Items = &jsonschema.Schema{
|
schema.Items = &jsonschema.Schema{
|
||||||
OneOf: processorDefinitionSchemas,
|
OneOf: processorDefinitionSchemas,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package schema
|
package schema
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmp"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
@@ -24,3 +25,7 @@ func GetResolvedConfigSchema() (*jsonschema.Resolved, error) {
|
|||||||
ValidateDefaults: true,
|
ValidateDefaults: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func schemaCmp(a, b *jsonschema.Schema) int {
|
||||||
|
return cmp.Compare(a.ID, b.ID)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user