From 414a3f51861b6760f97b1d4ee96fdebd1e21ca45 Mon Sep 17 00:00:00 2001 From: Paul Loyd Date: Sat, 13 Jan 2018 20:54:46 +0300 Subject: [PATCH] oneOf -> anyOf for maybe types --- src/generators/jsonSchema.js | 2 +- tests/samples/maybe/schema.json | 10 +++++----- tests/samples/nonMaybeType/schema.json | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/generators/jsonSchema.js b/src/generators/jsonSchema.js index 8d42c5b..62c1213 100644 --- a/src/generators/jsonSchema.js +++ b/src/generators/jsonSchema.js @@ -140,7 +140,7 @@ function convert(fund: Fund, type: ?Type): Schema { }; case 'maybe': return { - oneOf: [convert(fund, type.value), {type: 'null'}], + anyOf: [convert(fund, type.value), {type: 'null'}], }; case 'number': const {repr} = type; diff --git a/tests/samples/maybe/schema.json b/tests/samples/maybe/schema.json index bc19eb1..f597515 100644 --- a/tests/samples/maybe/schema.json +++ b/tests/samples/maybe/schema.json @@ -4,8 +4,8 @@ "maybe::X": { "type": "object", "properties": { - "x": {"oneOf": [{"type": "string"}, {"type": "null"}]}, - "xx": {"oneOf": [{"type": "string"}, {"type": "null"}]} + "x": {"anyOf": [{"type": "string"}, {"type": "null"}]}, + "xx": {"anyOf": [{"type": "string"}, {"type": "null"}]} }, "required": ["x", "xx"] }, @@ -13,12 +13,12 @@ "type": "object", "properties": { "y": { - "oneOf": [ + "anyOf": [ {"type": "array", "items": {"type": "string"}}, {"type": "null"} ] }, - "yy": {"oneOf": [{"type": "string"}, {"type": "null"}]} + "yy": {"anyOf": [{"type": "string"}, {"type": "null"}]} }, "required": ["y", "yy"] }, @@ -27,7 +27,7 @@ "properties": { "z": { "type": "array", - "items": {"oneOf": [{"type": "string"}, {"type": "null"}]} + "items": {"anyOf": [{"type": "string"}, {"type": "null"}]} } }, "required": ["z"] diff --git a/tests/samples/nonMaybeType/schema.json b/tests/samples/nonMaybeType/schema.json index 006c91e..2bff7fd 100644 --- a/tests/samples/nonMaybeType/schema.json +++ b/tests/samples/nonMaybeType/schema.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-06/schema#", "definitions": { - "nonMaybeType::X": {"oneOf": [{"type": "string"}, {"type": "null"}]}, + "nonMaybeType::X": {"anyOf": [{"type": "string"}, {"type": "null"}]}, "nonMaybeType::Y": {"type": "string"} } }