Skip to content

Commit

Permalink
remove depracated validation rule
Browse files Browse the repository at this point in the history
  • Loading branch information
MaggieKimani1 committed Oct 23, 2024
1 parent c3373af commit 9bf3f08
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 453 deletions.
57 changes: 0 additions & 57 deletions src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs

This file was deleted.

63 changes: 0 additions & 63 deletions src/Microsoft.OpenApi/Validations/Rules/OpenApiMediaTypeRules.cs

This file was deleted.

39 changes: 0 additions & 39 deletions src/Microsoft.OpenApi/Validations/Rules/OpenApiParameterRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,45 +58,6 @@ public static class OpenApiParameterRules
context.Exit();
});

/// <summary>
/// Validate the data matches with the given data type.
/// </summary>
public static ValidationRule<OpenApiParameter> ParameterMismatchedDataType =>
new(nameof(ParameterMismatchedDataType),
(context, parameter) =>
{
// example
context.Enter("example");
if (parameter.Example != null)
{
RuleHelpers.ValidateDataTypeMismatch(context, nameof(ParameterMismatchedDataType), parameter.Example, parameter.Schema);
}
context.Exit();
// examples
context.Enter("examples");
if (parameter.Examples != null)
{
foreach (var key in parameter.Examples.Keys)
{
if (parameter.Examples[key] != null)
{
context.Enter(key);
context.Enter("value");
RuleHelpers.ValidateDataTypeMismatch(context,
nameof(ParameterMismatchedDataType), parameter.Examples[key]?.Value, parameter.Schema);
context.Exit();
context.Exit();
}
}
}
context.Exit();
});

/// <summary>
/// Validate that a path parameter should always appear in the path
/// </summary>
Expand Down
43 changes: 0 additions & 43 deletions src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,6 @@ namespace Microsoft.OpenApi.Validations.Rules
[OpenApiRule]
public static class OpenApiSchemaRules
{
/// <summary>
/// Validate the data matches with the given data type.
/// </summary>
public static ValidationRule<OpenApiSchema> SchemaMismatchedDataType =>
new(nameof(SchemaMismatchedDataType),
(context, schema) =>
{
// default
context.Enter("default");
if (schema.Default != null)
{
RuleHelpers.ValidateDataTypeMismatch(context, nameof(SchemaMismatchedDataType), schema.Default, schema);
}
context.Exit();
// example
context.Enter("example");
if (schema.Example != null)
{
RuleHelpers.ValidateDataTypeMismatch(context, nameof(SchemaMismatchedDataType), schema.Example, schema);
}
context.Exit();
// enum
context.Enter("enum");
if (schema.Enum != null)
{
for (var i = 0; i < schema.Enum.Count; i++)
{
context.Enter(i.ToString());
RuleHelpers.ValidateDataTypeMismatch(context, nameof(SchemaMismatchedDataType), schema.Enum[i], schema);
context.Exit();
}
}
context.Exit();
});

/// <summary>
/// Validates Schema Discriminator
/// </summary>
Expand Down
Loading

0 comments on commit 9bf3f08

Please sign in to comment.