public void SerializeSchemaWRequiredPropertiesAsV2JsonWorks() { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); var writer = new OpenApiJsonWriter(outputStringWriter); var expected = @"{ ""title"": ""title1"", ""required"": [ ""property1"" ], ""properties"": { ""property1"": { ""required"": [ ""property3"" ], ""properties"": { ""property2"": { ""type"": ""integer"" }, ""property3"": { ""maxLength"": 15, ""type"": ""string"" } } }, ""property4"": { ""properties"": { ""property5"": { ""properties"": { ""property6"": { ""type"": ""boolean"" } } }, ""property7"": { ""minLength"": 2, ""type"": ""string"" } }, ""readOnly"": true } }, ""externalDocs"": { ""url"": ""http://example.com/externalDocs"" } }"; // Act AdvancedSchemaWithRequiredPropertiesObject.SerializeAsV2(writer); writer.Flush(); var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert actual = actual.MakeLineBreaksEnvironmentNeutral(); expected = expected.MakeLineBreaksEnvironmentNeutral(); actual.Should().Be(expected); }
public async Task SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act AdvancedSchemaWithRequiredPropertiesObject.SerializeAsV2(writer); writer.Flush(); var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert await Verifier.Verify(actual).UseParameters(produceTerseOutput); }