Skip to content

Commit

Permalink
Merge pull request #1887 from microsoft/mk/simplify-null-check
Browse files Browse the repository at this point in the history
Simplify null/empty string checks
  • Loading branch information
MaggieKimani1 authored Oct 23, 2024
2 parents 264226b + 125bda9 commit c3373af
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ private OpenApiCallback Target
/// </param>
public OpenApiCallbackReference(string referenceId, OpenApiDocument hostDocument, string externalResource = null)
{
if (string.IsNullOrEmpty(referenceId))
{
Utils.CheckArgumentNullOrEmpty(referenceId);
}
Utils.CheckArgumentNullOrEmpty(referenceId);

_reference = new OpenApiReference()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Nodes;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Writers;

Expand Down Expand Up @@ -44,10 +43,7 @@ private OpenApiExample Target
/// </param>
public OpenApiExampleReference(string referenceId, OpenApiDocument hostDocument, string externalResource = null)
{
if (string.IsNullOrEmpty(referenceId))
{
Utils.CheckArgumentNullOrEmpty(referenceId);
}
Utils.CheckArgumentNullOrEmpty(referenceId);

_reference = new OpenApiReference()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Nodes;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Writers;

Expand Down Expand Up @@ -41,11 +40,8 @@ private OpenApiHeader Target
/// 2. a Url, for example: http://localhost/pet.json
/// </param>
public OpenApiHeaderReference(string referenceId, OpenApiDocument hostDocument, string externalResource = null)
{
if (string.IsNullOrEmpty(referenceId))
{
Utils.CheckArgumentNullOrEmpty(referenceId);
}
{
Utils.CheckArgumentNullOrEmpty(referenceId);

_reference = new OpenApiReference()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ private OpenApiLink Target
/// </param>
public OpenApiLinkReference(string referenceId, OpenApiDocument hostDocument, string externalResource = null)
{
if (string.IsNullOrEmpty(referenceId))
{
Utils.CheckArgumentNullOrEmpty(referenceId);
}
Utils.CheckArgumentNullOrEmpty(referenceId);

_reference = new OpenApiReference()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Nodes;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Writers;

Expand Down Expand Up @@ -44,10 +43,7 @@ private OpenApiParameter Target
/// </param>
public OpenApiParameterReference(string referenceId, OpenApiDocument hostDocument, string externalResource = null)
{
if (string.IsNullOrEmpty(referenceId))
{
Utils.CheckArgumentNullOrEmpty(referenceId);
}
Utils.CheckArgumentNullOrEmpty(referenceId);

_reference = new OpenApiReference()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ private OpenApiPathItem Target
/// </param>
public OpenApiPathItemReference(string referenceId, OpenApiDocument hostDocument, string externalResource = null)
{
if (string.IsNullOrEmpty(referenceId))
{
Utils.CheckArgumentNullOrEmpty(referenceId);
}
Utils.CheckArgumentNullOrEmpty(referenceId);

_reference = new OpenApiReference()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ private OpenApiRequestBody Target
/// </param>
public OpenApiRequestBodyReference(string referenceId, OpenApiDocument hostDocument, string externalResource = null)
{
if (string.IsNullOrEmpty(referenceId))
{
Utils.CheckArgumentNullOrEmpty(referenceId);
}
Utils.CheckArgumentNullOrEmpty(referenceId);

_reference = new OpenApiReference()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ private OpenApiResponse Target
/// </param>
public OpenApiResponseReference(string referenceId, OpenApiDocument hostDocument, string externalResource = null)
{
if (string.IsNullOrEmpty(referenceId))
{
Utils.CheckArgumentNullOrEmpty(referenceId);
}
Utils.CheckArgumentNullOrEmpty(referenceId);

_reference = new OpenApiReference()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ private OpenApiSchema Target
/// </param>
public OpenApiSchemaReference(string referenceId, OpenApiDocument hostDocument, string externalResource = null)
{
if (string.IsNullOrEmpty(referenceId))
{
Utils.CheckArgumentNullOrEmpty(referenceId);
}
Utils.CheckArgumentNullOrEmpty(referenceId);

_reference = new OpenApiReference()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ private OpenApiSecurityScheme Target
/// <param name="externalResource">The externally referenced file.</param>
public OpenApiSecuritySchemeReference(string referenceId, OpenApiDocument hostDocument, string externalResource = null)
{
if (string.IsNullOrEmpty(referenceId))
{
Utils.CheckArgumentNullOrEmpty(referenceId);
}
Utils.CheckArgumentNullOrEmpty(referenceId);

_reference = new OpenApiReference()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ private OpenApiTag Target
/// <param name="hostDocument">The host OpenAPI document.</param>
public OpenApiTagReference(string referenceId, OpenApiDocument hostDocument)
{
if (string.IsNullOrEmpty(referenceId))
{
Utils.CheckArgumentNullOrEmpty(referenceId);
}
Utils.CheckArgumentNullOrEmpty(referenceId);

_reference = new OpenApiReference()
{
Expand Down

0 comments on commit c3373af

Please sign in to comment.