diff --git a/ast/parser.go b/ast/parser.go index 31f09b2616..10dc088aaa 100644 --- a/ast/parser.go +++ b/ast/parser.go @@ -1616,6 +1616,9 @@ func (b *metadataParser) Parse() (*Annotations, error) { var errInvalidSchemaRef = fmt.Errorf("invalid schema reference") +// NOTE(tsandall): 'schema' is not registered as a root because it's not +// supported by the compiler or evaluator today. Once we fix that, we can remove +// this function. func parseSchemaRef(s string) (Ref, error) { term, err := ParseTerm(s) diff --git a/loader/loader.go b/loader/loader.go index 970a950edc..605f598c56 100644 --- a/loader/loader.go +++ b/loader/loader.go @@ -282,7 +282,7 @@ func loadSchemas(schemaPath string) (*ast.SchemaSet, error) { if err != nil { return nil, err } - ss.Put(ast.InputRootRef, schema) + ss.Put(ast.SchemaRootRef, schema) return ss, nil } diff --git a/loader/loader_test.go b/loader/loader_test.go index 9d52fce9f4..7ee26dcec8 100644 --- a/loader/loader_test.go +++ b/loader/loader_test.go @@ -765,7 +765,7 @@ func TestSchemas(t *testing.T) { "foo/bar/baz.json": `{"type": "string"}`, }, exp: map[string]string{ - "input": `{"type": "string"}`, + "schema": `{"type": "string"}`, }, }, { @@ -802,7 +802,12 @@ func TestSchemas(t *testing.T) { t.Fatal("unexpected error:", err) } for k, v := range tc.exp { - key := ast.MustParseRef(k) + var key ast.Ref + if k == "schema" { + key = ast.SchemaRootRef.Copy() + } else { + key = ast.MustParseRef(k) + } var schema interface{} util.Unmarshal([]byte(v), &schema) result := ss.Get(key)