private static void KeywordEqual(OneOfKeyword expected, OneOfKeyword actual) { Assert.Equal(expected.Schemas.Count, actual.Schemas.Count); for (int i = 0; i < expected.Schemas.Count; i++) { IsEquivalentTo(expected.Schemas[i], actual.Schemas[i]); } }
private static bool KeywordHasSingleNonNullSchema(OneOfKeyword keyword) { if (keyword.GetSubschemas().Count() > 1) { return(false); } if (keyword.GetSubschemas().First().TryGetKeyword <TypeKeyword>(out var typeKeyword) && typeKeyword.Type != SchemaValueType.Null) { return(true); }
private void ProcessOneOfKeyword(JsonPointer path, OneOfKeyword keyword, SchemaContext context) { // A oneOf keyword with only one subschema which isn't null makes it required if (KeywordHasSingleNonNullSchema(keyword)) { AddRequiredProperties(context.Id, new List <string>() { context.Name }); } int subSchemaIndex = 0; foreach (var subSchema in keyword.GetSubschemas()) { var subSchemaPath = path.Combine(JsonPointer.Parse($"/[{subSchemaIndex}]")); ProcessSubSchema(subSchemaPath, subSchema, context); subSchemaIndex++; } }