-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
Describe the bug
I think the jsonschema for the helm values in the cert-manager chart may demonstrate a bug with an edge case in resolution where the root object has a "$ref".
To Reproduce
Something like:
package main
import (
"encoding/json"
"os"
"github.com/google/jsonschema-go/jsonschema"
)
func main() {
schemaData, _ := os.ReadFile("values.schema.json")
var schema jsonschema.Schema
json.Unmarshal(schemaData, &schema)
// This is the workaround I used:
// if strings.HasPrefix(schema.Ref, "#/$defs/") {
// key := strings.TrimPrefix(schema.Ref, "#/$defs/")
// def, ok := schema.Defs[key]
// if ok {
// root := schema
// schema = *def
// schema.Defs = make(map[string]*jsonschema.Schema)
// for k, v := range root.Defs {
// if k != key {
// schema.Defs[k] = v
// }
// }
// }
// }
resolved, err := schema.Resolve(&jsonschema.ResolveOptions{})
if err != nil {
panic(err)
}
if resolved.Schema().Type != "object" {
panic("bug")
}
println("ok")
}That workaround only seemed to work at the root level. The child properties (e.g. root.properties.acmesolver) were still unresolved for some reason.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels