Exemplo n.º 1
0
        private JsonSchema NormalizeSchema(JsonSchema schema)
        {
            if (schema.Keywords == null)
            {
                return(JsonSchema.True);
            }

            var builder = new JsonSchemaBuilder();

            foreach (var keyword in schema.Keywords)
            {
                foreach (var kw in NormalizeKeyword(schema, keyword))
                {
                    builder.Add(kw);
                }
            }

            return(builder.Build());
        }
 /// <summary>
 /// Adds a `data` keyword.
 /// </summary>
 /// <param name="builder">The builder.</param>
 /// <param name="data">The collection of keywords and references.</param>
 /// <returns>The builder.</returns>
 public static JsonSchemaBuilder Data(this JsonSchemaBuilder builder, IReadOnlyDictionary <string, string> data)
 {
     builder.Add(new DataKeyword(data.ToDictionary(x => x.Key, x => new Uri(x.Value, UriKind.RelativeOrAbsolute))));
     return(builder);
 }
 /// <summary>
 /// Adds a `data` keyword.
 /// </summary>
 /// <param name="builder">The builder.</param>
 /// <param name="data">The collection of keywords and references.</param>
 /// <returns>The builder.</returns>
 public static JsonSchemaBuilder Data(this JsonSchemaBuilder builder, IReadOnlyDictionary <string, Uri> data)
 {
     builder.Add(new DataKeyword(data));
     return(builder);
 }
Exemplo n.º 4
0
 public static JsonSchemaBuilder MinDate(this JsonSchemaBuilder builder, DateTime date)
 {
     builder.Add(new VocabularyTests.MinDateKeyword(date));
     return(builder);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Add <see cref="XsdAnyAttributeKeyword"/> keyword to the builder
 /// </summary>
 /// <param name="builder">The <see cref="JsonSchemaBuilder"/></param>
 /// <param name="id">The original id of the any attribute.</param>
 /// <param name="namespace">The original namespace value of the any attribute.</param>
 /// <param name="processContent">The original processContent value of the any attribute.</param>
 /// <returns>The <see cref="JsonSchemaBuilder"/> used for chaining</returns>
 public static JsonSchemaBuilder XsdAnyAttribute(this JsonSchemaBuilder builder, string id, string @namespace, string processContent)
 {
     builder.Add(new XsdAnyAttributeKeyword(id, @namespace, processContent));
     return(builder);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Add <see cref="XsdAttributeKeyword"/> keyword to the builder
 /// </summary>
 /// <param name="builder">The <see cref="JsonSchemaBuilder"/></param>
 /// <param name="attribute">True to set the attribute keyword</param>
 /// <returns>The <see cref="JsonSchemaBuilder"/> used for chaining</returns>
 public static JsonSchemaBuilder XsdAttribute(this JsonSchemaBuilder builder, bool attribute = true)
 {
     builder.Add(new XsdAttributeKeyword(attribute));
     return(builder);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Add <see cref="InfoKeyword"/> keyword to the builder
 /// </summary>
 /// <param name="builder">The <see cref="JsonSchemaBuilder"/></param>
 /// <param name="info">Info content as <see cref="JsonElement" /></param>
 /// <returns>The <see cref="JsonSchemaBuilder"/> used for chaining</returns>
 public static JsonSchemaBuilder Info(this JsonSchemaBuilder builder, JsonElement info)
 {
     builder.Add(new InfoKeyword(info));
     return(builder);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Adds a `uniqueKeys` keyword.
 /// </summary>
 /// <param name="builder">The builder.</param>
 /// <param name="keys">The collection of pointers to the keys which should be unique within the array.</param>
 /// <returns>The builder.</returns>
 public static JsonSchemaBuilder UniqueKeys(this JsonSchemaBuilder builder, params string[] keys)
 {
     builder.Add(new UniqueKeysKeyword(keys.Select(x => JsonPointer.Parse(x))));
     return(builder);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Adds a `uniqueKeys` keyword.
 /// </summary>
 /// <param name="builder">The builder.</param>
 /// <param name="keys">The collection of pointers to the keys which should be unique within the array.</param>
 /// <returns>The builder.</returns>
 public static JsonSchemaBuilder UniqueKeys(this JsonSchemaBuilder builder, params JsonPointer[] keys)
 {
     builder.Add(new UniqueKeysKeyword(keys));
     return(builder);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Adds a `uniqueKeys` keyword.
 /// </summary>
 /// <param name="builder">The builder.</param>
 /// <param name="keys">The collection of pointers to the keys which should be unique within the array.</param>
 /// <returns>The builder.</returns>
 public static JsonSchemaBuilder UniqueKeys(this JsonSchemaBuilder builder, IEnumerable <JsonPointer> keys)
 {
     builder.Add(new UniqueKeysKeyword(keys));
     return(builder);
 }