Skip to content

Commit aa009b1

Browse files
committed
PR review related fixes
1 parent deffca8 commit aa009b1

File tree

8 files changed

+7
-27
lines changed

8 files changed

+7
-27
lines changed

src/Microsoft.OpenApi/Models/OpenApiError.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class OpenApiError
1313
/// <summary>
1414
/// Initializes the <see cref="OpenApiError"/> class using the message and pointer from the given exception.
1515
/// </summary>
16-
public OpenApiError(OpenApiException exception)
16+
public OpenApiError(OpenApiException exception) : this(exception.Pointer, exception.Message)
1717
{
1818
Message = exception.Message;
1919
Pointer = exception.Pointer;

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,5 @@ public static class OpenApiContactRules
3333
context.Exit();
3434
});
3535

36-
/// <summary>
37-
/// Url field MUST be url format.
38-
/// </summary>
39-
public static ValidationRule<OpenApiContact> UrlMustBeUrlFormat =>
40-
new ValidationRule<OpenApiContact>(
41-
(context, item) =>
42-
{
43-
context.Enter("url");
44-
if (item != null && item.Url != null)
45-
{
46-
// TODO:
47-
}
48-
context.Exit();
49-
});
5036
}
5137
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static class OpenApiLicenseRules
2121
(context, license) =>
2222
{
2323
context.Enter("name");
24-
if (String.IsNullOrEmpty(license.Name))
24+
if (license.Name == null)
2525
{
2626
context.CreateError(nameof(LicenseRequiredFields),ErrorReason.Required,
2727
String.Format(SRResource.Validation_FieldIsRequired, "name", "license"));

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,7 @@ public static class OpenApiPathsRules
2424
{
2525
context.Enter(pathName);
2626

27-
if (string.IsNullOrEmpty(pathName))
28-
{
29-
// Add the error message
30-
// context.Add(...);
31-
}
32-
33-
if (!pathName.StartsWith("/"))
27+
if (pathName == null || !pathName.StartsWith("/"))
3428
{
3529
context.CreateError(nameof(PathNameMustBeginWithSlash),ErrorReason.Format,
3630
string.Format(SRResource.Validation_PathItemMustBeginWithSlash, pathName));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static class OpenApiResponseRules
2222
{
2323
// description
2424
context.Enter("description");
25-
if (String.IsNullOrEmpty(response.Description))
25+
if (response.Description == null)
2626
{
2727
context.CreateError(nameof(ResponseRequiredFields),ErrorReason.Required,
2828
String.Format(SRResource.Validation_FieldIsRequired, "description", "response"));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static class OpenApiServerRules
2121
(context, server) =>
2222
{
2323
context.Enter("url");
24-
if (String.IsNullOrEmpty(server.Url))
24+
if (server.Url == null)
2525
{
2626
context.CreateError(nameof(ServerRequiredFields),ErrorReason.Required,
2727
String.Format(SRResource.Validation_FieldIsRequired, "url", "server"));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static class OpenApiTagRules
2121
(context, tag) =>
2222
{
2323
context.Enter("name");
24-
if (String.IsNullOrEmpty(tag.Name))
24+
if (tag.Name == null)
2525
{
2626
context.CreateError(nameof(TagRequiredFields),ErrorReason.Required,
2727
String.Format(SRResource.Validation_FieldIsRequired, "name", "tag"));

test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void DefaultRuleSetPropertyReturnsTheCorrectRules()
4343
Assert.NotEmpty(rules);
4444

4545
// Update the number if you add new default rule(s).
46-
Assert.Equal(15, rules.Count);
46+
Assert.Equal(14, rules.Count);
4747
}
4848
}
4949
}

0 commit comments

Comments
 (0)