| 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 |
| |
| -- expect-stdout -- |
| package schema |
| |
| Person :: { |
| // Person |
| Schema :: { |
| // The person's first name. |
| firstName?: string |
| |
| // The person's last name. |
| lastName?: string |
| |
| // Age in years which must be equal to or greater than zero. |
| age?: >=0 |
| ... |
| } @jsonschema(schema="http://json-schema.org/draft-07/schema#",id="https://example.com/person.schema.json") |
| } |
| -- 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." |
| }, |
| "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 |
| -- cue.mod -- |