blob: 5e0fce7a3326a878bd4cee963dda4ae75cf46dd9 [file] [log] [blame]
cue def jsonschema: schema.json -p schema -l '#Person:'
cmp stdout expect-stdout
# auto mode
cue def schema.json -p schema -l '#Person:'
cmp stdout expect-stdout
cue def jsonschema: bad.json
! cue def jsonschema: bad.json --strict
cmp stderr expect-stderr
! cue export data.yaml schema.json
cmp stderr expect-stderr2
! cue vet data.yaml schema.json
cmp stderr expect-stderr3
-- expect-stdout --
package schema
import "strings"
#Person: {
// The person's first name.
firstName?: string
// The person's last name.
lastName?: strings.MinRunes(1)
// Age in years which must be equal to or greater than zero.
age?: >=0
...
}
-- schema.json --
{
"$id": "https://example.com/person.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Person",
"type": "object",
"properties": {
"firstName": {
"type": "string",
"description": "The person's first name."
},
"lastName": {
"type": "string",
"description": "The person's last name.",
"minLength": 1
},
"age": {
"description": "Age in years which must be equal to or greater than zero.",
"type": "integer",
"minimum": 0
}
}
}
-- bad.json --
{
"type": "number",
"foo": "bar"
}
-- expect-stderr --
unsupported constraint "foo":
./bad.json:3:10
-- data.yaml --
age: twenty
-- expect-stderr2 --
age: conflicting values "twenty" and >=0 (mismatched types string and number):
14:7
./data.yaml:1:7
-- expect-stderr3 --
age: conflicting values "twenty" and >=0 (mismatched types string and number):
14:7
./data.yaml:1:7
-- cue.mod --