# Label expressions and --with-context under a JSON Schema interpretation,
# where the placed value is the converted schema rather than the source.
# Issue: https://cuelang.org/issue/3725

# A bare label is evaluated within the converted schema, where source fields
# such as "title" do not exist.
! exec cue import -o - -l title jsonschema: input.json
stderr 'error evaluating label title: reference "title" not found'

# --with-context exposes the source as data, so data.title resolves and places
# the schema under that name.
exec cue import -o - --with-context -l data.title jsonschema: input.json
cmp stdout expect-stdout

-- expect-stdout --
// Person
Person: {
	@jsonschema(schema="http://json-schema.org/draft-07/schema#")
	@jsonschema(id="https://example.com/person.schema.json")
	...
}
-- input.json --
{
	"$schema": "http://json-schema.org/draft-07/schema",
	"$id": "https://example.com/person.schema.json",
	"title": "Person",
	"type": "object"
}
-- cue.mod/module.cue --
module: "test.example"
language: version: "v0.9.0"
