Skip to content

Commit 5678b05

Browse files
committed
Addessing PR comments
1 parent 2d98098 commit 5678b05

File tree

6 files changed

+6
-10
lines changed

6 files changed

+6
-10
lines changed

src/Microsoft.OpenApi/Extensions/OpenApiElementExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public static class OpenApiElementExtensions
2020
/// <param name="element">Element to validate</param>
2121
/// <param name="ruleSet">Optional set of rules to use for validation</param>
2222
/// <returns>An IEnumerable of errors. This function will never return null.</returns>
23-
public static IEnumerable<OpenApiError> Validate(this IOpenApiElement element, ValidationRuleSet ruleSet = null) {
23+
public static IEnumerable<OpenApiError> Validate(this IOpenApiElement element, ValidationRuleSet ruleSet = null)
24+
{
2425
var validator = new OpenApiValidator(ruleSet);
2526
var walker = new OpenApiWalker(validator);
2627
walker.Walk(element);

src/Microsoft.OpenApi/Models/OpenApiError.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ public class OpenApiError
1515
/// </summary>
1616
public OpenApiError(OpenApiException exception) : this(exception.Pointer, exception.Message)
1717
{
18-
Message = exception.Message;
19-
Pointer = exception.Pointer;
2018
}
2119

2220
/// <summary>

src/Microsoft.OpenApi/Validations/IValidationContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public interface IValidationContext
1919
/// Register an error with the validation context.
2020
/// </summary>
2121
/// <param name="error">Error to register.</param>
22-
void AddError(OpenApiError error);
22+
void AddError(OpenApiValidatorError error);
2323

2424

2525
/// <summary>

src/Microsoft.OpenApi/Validations/OpenApiValidator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Microsoft.OpenApi.Validations
1616
public class OpenApiValidator : OpenApiVisitorBase, IValidationContext
1717
{
1818
private readonly ValidationRuleSet _ruleSet;
19-
private readonly IList<OpenApiError> _errors = new List<OpenApiError>();
19+
private readonly IList<OpenApiValidatorError> _errors = new List<OpenApiValidatorError>();
2020

2121
/// <summary>
2222
/// Create a vistor that will validate an OpenAPIDocument
@@ -42,7 +42,7 @@ public IEnumerable<OpenApiError> Errors
4242
/// Register an error with the validation context.
4343
/// </summary>
4444
/// <param name="error">Error to register.</param>
45-
public void AddError(OpenApiError error)
45+
public void AddError(OpenApiValidatorError error)
4646
{
4747
if (error == null)
4848
{

src/Microsoft.OpenApi/Validations/OpenApiValidatorError.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace Microsoft.OpenApi.Validations
1212
{
1313
/// <summary>
14-
/// Errors detected when validating a OpenAPI Element
14+
/// Errors detected when validating an OpenAPI Element
1515
/// </summary>
1616
public class OpenApiValidatorError : OpenApiError
1717
{
@@ -20,8 +20,6 @@ public class OpenApiValidatorError : OpenApiError
2020
/// </summary>
2121
public OpenApiValidatorError(string ruleName, string pointer, string message) : base(pointer, message)
2222
{
23-
Pointer = pointer;
24-
Message = message;
2523
RuleName = ruleName;
2624
}
2725

src/Microsoft.OpenApi/Validations/Rules/OpenApiResponsesRules.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public static class OpenApiResponsesRules
4141
if (key != "default" && !Regex.IsMatch(key, "^[1-5]([0-9][0-9]|XX)$"))
4242
{
4343
context.CreateError(nameof(ResponsesMustBeIdentifiedByDefaultOrStatusCode),
44-
4544
"Responses key must be 'default', an HTTP status code, " +
4645
"or one of the following strings representing a range of HTTP status codes: " +
4746
"'1XX', '2XX', '3XX', '4XX', '5XX'");

0 commit comments

Comments
 (0)