| // This test tests the conversion and ordering of definitions. |
| |
| -- definition.json -- |
| { |
| "$schema": "http://json-schema.org/draft-07/schema#", |
| |
| "$id": "http://cuelang.org/go/encoding/openapi/testdata/order.json", |
| |
| "definitions": { |
| "address": { |
| "type": "object", |
| "properties": { |
| "street_address": { "type": "string" }, |
| "city": { "type": "string" }, |
| "state": { "type": "string" } |
| }, |
| "required": ["street_address", "city", "state"] |
| }, |
| "person": { |
| "type": "object", |
| "properties": { |
| "name": { "type": "string" }, |
| "children": { |
| "type": "array", |
| "items": { "$ref": "#/definitions/person" }, |
| "default": [] |
| } |
| } |
| } |
| }, |
| |
| "type": "object", |
| |
| "properties": { |
| "person": { "$ref": "#/definitions/person" }, |
| "billing_address": { "$ref": "#/definitions/address" }, |
| "shipping_address": { "$ref": "#/definitions/address" } |
| } |
| } |
| |
| -- out.cue -- |
| Schema :: _ @jsonschema(schema="http://json-schema.org/draft-07/schema#",id="http://cuelang.org/go/encoding/openapi/testdata/order.json") |
| Schema :: { |
| person?: def.person |
| billing_address?: def.address |
| shipping_address?: def.address |
| ... |
| } |
| |
| def: address :: { |
| street_address: string |
| city: string |
| state: string |
| ... |
| } |
| |
| def: person :: { |
| name?: string |
| children?: [...def.person] |
| ... |
| } |