コード例 #1
0
 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]);
     }
 }
コード例 #2
0
        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);
            }
コード例 #3
0
        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++;
            }
        }