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++; } }