From 1bdb3791d6f849247c6af2a84290eef3c3464889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20Roch=C3=A9?= Date: Tue, 27 Feb 2024 10:31:13 +0100 Subject: [PATCH] tests: add json schema with defs --- tests/mocks/jsonchema_defs.json | 23 +++++++++++++++++++++++ tests/smoke.t | 11 +++++++++++ 2 files changed, 34 insertions(+) create mode 100644 tests/mocks/jsonchema_defs.json diff --git a/tests/mocks/jsonchema_defs.json b/tests/mocks/jsonchema_defs.json new file mode 100644 index 0000000..ef79c1a --- /dev/null +++ b/tests/mocks/jsonchema_defs.json @@ -0,0 +1,23 @@ +{ + "$id": "https://example.com/schemas/customer", + "type": "object", + "properties": { + "first_name": { + "$ref": "#/$defs/name" + }, + "last_name": { + "$ref": "#/$defs/name" + } + }, + "required": [ + "first_name", + "last_name", + "shipping_address", + "billing_address" + ], + "$defs": { + "name": { + "type": "string" + } + } +} diff --git a/tests/smoke.t b/tests/smoke.t index f7eb263..a73a6c8 100644 --- a/tests/smoke.t +++ b/tests/smoke.t @@ -43,3 +43,14 @@ Generate ATD out of OpenAPI doc with -f attribute type product = { ?productId: int option; } + +Generate ATD out of JSON Schema that contains defs + $ jsonschema2atd --format=jsonschema ./mocks/jsonchema_defs.json + (* Generated by jsonschema2atd *) + type json = abstract + type int64 = int + + type root = { + first_name: name; + last_name: name; + }