public void WriteTo_ExclusiveMinimum_ExclusiveMaximum_Draf4() { JSchema schema = new JSchema(); schema.ExclusiveMinimum = true; schema.ExclusiveMaximum = true; schema.Minimum = 100; schema.Maximum = 101; StringWriter writer = new StringWriter(); JsonTextWriter jsonWriter = new JsonTextWriter(writer); jsonWriter.Formatting = Formatting.Indented; JSchemaWriterSettings settings = new JSchemaWriterSettings { Version = SchemaVersion.Draft4 }; schema.WriteTo(jsonWriter, settings); string json = writer.ToString(); StringAssert.AreEqual(@"{ ""$schema"": ""http://json-schema.org/draft-04/schema#"", ""minimum"": 100.0, ""maximum"": 101.0, ""exclusiveMinimum"": true, ""exclusiveMaximum"": true }", json); }
public void WriteTo_CircularReference_WithRootId() { string json = @"{ ""id"":""CircularReferenceArray"", ""description"":""CircularReference"", ""type"":[""array""], ""items"":{""$ref"":""CircularReferenceArray""} }"; JSchema schema = JSchema.Parse(json); StringWriter writer = new StringWriter(); JsonTextWriter jsonWriter = new JsonTextWriter(writer); jsonWriter.Formatting = Formatting.Indented; JSchemaWriterSettings settings = new JSchemaWriterSettings { Version = SchemaVersion.Draft4 }; schema.WriteTo(jsonWriter, settings); string writtenJson = writer.ToString(); StringAssert.AreEqual(@"{ ""$schema"": ""http://json-schema.org/draft-04/schema#"", ""id"": ""CircularReferenceArray"", ""description"": ""CircularReference"", ""type"": ""array"", ""items"": { ""$ref"": ""CircularReferenceArray"" } }", writtenJson); }
public JSchemaWriter(JsonWriter writer, JSchemaWriterSettings settings) { ValidationUtils.ArgumentNotNull(writer, "writer"); _writer = writer; _knownSchemas = new List <KnownSchema>(); if (settings != null) { _externalSchemas = settings.ExternalSchemas; } }
public JSchemaWriter(JsonWriter writer, JSchemaWriterSettings settings) { ValidationUtils.ArgumentNotNull(writer, nameof(writer)); _writer = writer; _knownSchemas = new KnownSchemaCollection(); if (settings != null) { _externalSchemas = settings.ExternalSchemas; _referenceHandling = settings.ReferenceHandling; } if (_referenceHandling != JSchemaWriterReferenceHandling.Always) { _schemaStack = new List <JSchema>(); } }