diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 3a7fdbd57..ec2f9a6dd 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -1682,11 +1682,6 @@ namespace Microsoft.OpenApi.Validations.Rules public static Microsoft.OpenApi.Validations.ValidationRule UrlIsRequired { get; } } [Microsoft.OpenApi.Validations.Rules.OpenApiRule] - public static class OpenApiHeaderRules - { - public static Microsoft.OpenApi.Validations.ValidationRule HeaderMismatchedDataType { get; } - } - [Microsoft.OpenApi.Validations.Rules.OpenApiRule] public static class OpenApiInfoRules { public static Microsoft.OpenApi.Validations.ValidationRule InfoRequiredFields { get; } @@ -1697,11 +1692,6 @@ namespace Microsoft.OpenApi.Validations.Rules public static Microsoft.OpenApi.Validations.ValidationRule LicenseRequiredFields { get; } } [Microsoft.OpenApi.Validations.Rules.OpenApiRule] - public static class OpenApiMediaTypeRules - { - public static Microsoft.OpenApi.Validations.ValidationRule MediaTypeMismatchedDataType { get; } - } - [Microsoft.OpenApi.Validations.Rules.OpenApiRule] public static class OpenApiOAuthFlowRules { public static Microsoft.OpenApi.Validations.ValidationRule OAuthFlowRequiredFields { get; } @@ -1709,7 +1699,6 @@ namespace Microsoft.OpenApi.Validations.Rules [Microsoft.OpenApi.Validations.Rules.OpenApiRule] public static class OpenApiParameterRules { - public static Microsoft.OpenApi.Validations.ValidationRule ParameterMismatchedDataType { get; } public static Microsoft.OpenApi.Validations.ValidationRule ParameterRequiredFields { get; } public static Microsoft.OpenApi.Validations.ValidationRule PathParameterShouldBeInThePath { get; } public static Microsoft.OpenApi.Validations.ValidationRule RequiredMustBeTrueWhenInIsPath { get; } @@ -1739,7 +1728,6 @@ namespace Microsoft.OpenApi.Validations.Rules [Microsoft.OpenApi.Validations.Rules.OpenApiRule] public static class OpenApiSchemaRules { - public static Microsoft.OpenApi.Validations.ValidationRule SchemaMismatchedDataType { get; } public static Microsoft.OpenApi.Validations.ValidationRule ValidateSchemaDiscriminator { get; } public static bool TraverseSchemaElements(string discriminatorName, System.Collections.Generic.IList childSchema) { } public static bool ValidateChildSchemaAgainstDiscriminator(Microsoft.OpenApi.Models.OpenApiSchema schema, string discriminatorName) { } diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs index bbc9dfe35..e8a66e351 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs @@ -40,15 +40,7 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema() var result = !warnings.Any(); // Assert - result.Should().BeFalse(); - warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] - { - RuleHelpers.DataTypeMismatchedErrorMessage - }); - warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] - { - "#/example", - }); + result.Should().BeTrue(); } [Fact] @@ -107,21 +99,7 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() var result = !warnings.Any(); // Assert - result.Should().BeFalse(); - warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] - { - RuleHelpers.DataTypeMismatchedErrorMessage, - RuleHelpers.DataTypeMismatchedErrorMessage, - RuleHelpers.DataTypeMismatchedErrorMessage, - }); - warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] - { - // #enum/0 is not an error since the spec allows - // representing an object using a string. - "#/examples/example1/value/y", - "#/examples/example1/value/z", - "#/examples/example2/value" - }); + result.Should().BeTrue(); } } } diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs index 9f42cb21b..29bd199e1 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs @@ -39,15 +39,7 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema() var result = !warnings.Any(); // Assert - result.Should().BeFalse(); - warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] - { - RuleHelpers.DataTypeMismatchedErrorMessage - }); - warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] - { - "#/example", - }); + result.Should().BeTrue(); } [Fact] @@ -106,21 +98,7 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() var result = !warnings.Any(); // Assert - result.Should().BeFalse(); - warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] - { - RuleHelpers.DataTypeMismatchedErrorMessage, - RuleHelpers.DataTypeMismatchedErrorMessage, - RuleHelpers.DataTypeMismatchedErrorMessage, - }); - warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] - { - // #enum/0 is not an error since the spec allows - // representing an object using a string. - "#/examples/example1/value/y", - "#/examples/example1/value/z", - "#/examples/example2/value" - }); + result.Should().BeTrue(); } } } diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs index beac66d74..b21ddb7eb 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs @@ -88,15 +88,7 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema() var result = !warnings.Any(); // Assert - result.Should().BeFalse(); - warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] - { - RuleHelpers.DataTypeMismatchedErrorMessage - }); - warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] - { - "#/{parameter1}/example", - }); + result.Should().BeTrue(); } [Fact] @@ -158,21 +150,7 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() var result = !warnings.Any(); // Assert - result.Should().BeFalse(); - warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] - { - RuleHelpers.DataTypeMismatchedErrorMessage, - RuleHelpers.DataTypeMismatchedErrorMessage, - RuleHelpers.DataTypeMismatchedErrorMessage, - }); - warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] - { - // #enum/0 is not an error since the spec allows - // representing an object using a string. - "#/{parameter1}/examples/example1/value/y", - "#/{parameter1}/examples/example1/value/z", - "#/{parameter1}/examples/example2/value" - }); + result.Should().BeTrue(); } [Fact] diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs index 5885377ed..f6b42c91d 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs @@ -39,15 +39,7 @@ public void ValidateDefaultShouldNotHaveDataTypeMismatchForSimpleSchema() var result = !warnings.Any(); // Assert - result.Should().BeFalse(); - warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] - { - RuleHelpers.DataTypeMismatchedErrorMessage - }); - warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] - { - "#/default", - }); + result.Should().BeTrue(); } [Fact] @@ -72,15 +64,7 @@ public void ValidateExampleAndDefaultShouldNotHaveDataTypeMismatchForSimpleSchem var expectedWarnings = warnings.Select(e => e.Message).ToList(); // Assert - result.Should().BeFalse(); - warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] - { - RuleHelpers.DataTypeMismatchedErrorMessage - }); - warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] - { - "#/example", - }); + result.Should().BeTrue(); } [Fact] @@ -122,21 +106,7 @@ public void ValidateEnumShouldNotHaveDataTypeMismatchForSimpleSchema() var result = !warnings.Any(); // Assert - result.Should().BeFalse(); - warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] - { - RuleHelpers.DataTypeMismatchedErrorMessage, - RuleHelpers.DataTypeMismatchedErrorMessage, - RuleHelpers.DataTypeMismatchedErrorMessage, - }); - warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] - { - // #enum/0 is not an error since the spec allows - // representing an object using a string. - "#/enum/1/y", - "#/enum/1/z", - "#/enum/2" - }); + result.Should().BeTrue(); } [Fact] @@ -212,19 +182,7 @@ public void ValidateDefaultShouldNotHaveDataTypeMismatchForComplexSchema() bool result = !warnings.Any(); // Assert - result.Should().BeFalse(); - warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] - { - RuleHelpers.DataTypeMismatchedErrorMessage, - RuleHelpers.DataTypeMismatchedErrorMessage, - RuleHelpers.DataTypeMismatchedErrorMessage - }); - warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] - { - "#/default/property1/2", - "#/default/property2/0", - "#/default/property2/1/z" - }); + result.Should().BeTrue(); } [Fact] diff --git a/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs b/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs index 15ef6b07f..6b4a920cf 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -55,8 +55,8 @@ public void RuleSetConstructorsReturnsTheCorrectRules() Assert.Empty(ruleSet_4.Rules); // Update the number if you add new default rule(s). - Assert.Equal(23, ruleSet_1.Rules.Count); - Assert.Equal(23, ruleSet_2.Rules.Count); + Assert.Equal(19, ruleSet_1.Rules.Count); + Assert.Equal(19, ruleSet_2.Rules.Count); Assert.Equal(3, ruleSet_3.Rules.Count); }