Skip to content

Commit

Permalink
Clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
MaggieKimani1 committed Nov 16, 2023
1 parent 236a48d commit 076009c
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ public static OpenApiExample LoadExample(ParseNode node)
var pointer = mapNode.GetReferencePointer();
if (pointer != null)
{
var description = node.Context.VersionService.GetReferenceScalarValues(mapNode, OpenApiConstants.Description);
var summary = node.Context.VersionService.GetReferenceScalarValues(mapNode, OpenApiConstants.Summary);

return mapNode.GetReferencedObject<OpenApiExample>(ReferenceType.Example, pointer, summary, description);
return mapNode.GetReferencedObject<OpenApiExample>(ReferenceType.Example, pointer);
}

var example = new OpenApiExample();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ public static OpenApiHeader LoadHeader(ParseNode node)
var pointer = mapNode.GetReferencePointer();
if (pointer != null)
{
var description = node.Context.VersionService.GetReferenceScalarValues(mapNode, OpenApiConstants.Description);
var summary = node.Context.VersionService.GetReferenceScalarValues(mapNode, OpenApiConstants.Summary);

return mapNode.GetReferencedObject<OpenApiHeader>(ReferenceType.Header, pointer, summary, description);
return mapNode.GetReferencedObject<OpenApiHeader>(ReferenceType.Header, pointer);
}

var header = new OpenApiHeader();
Expand Down
5 changes: 1 addition & 4 deletions src/Microsoft.OpenApi.Readers/V3/OpenApiLinkDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ public static OpenApiLink LoadLink(ParseNode node)
var pointer = mapNode.GetReferencePointer();
if (pointer != null)
{
var description = node.Context.VersionService.GetReferenceScalarValues(mapNode, OpenApiConstants.Description);
var summary = node.Context.VersionService.GetReferenceScalarValues(mapNode, OpenApiConstants.Summary);

return mapNode.GetReferencedObject<OpenApiLink>(ReferenceType.Link, pointer, summary, description);
return mapNode.GetReferencedObject<OpenApiLink>(ReferenceType.Link, pointer);
}

ParseMap(mapNode, link, _linkFixedFields, _linkPatternFields);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,7 @@ public static OpenApiParameter LoadParameter(ParseNode node)
var pointer = mapNode.GetReferencePointer();
if (pointer != null)
{
var description = node.Context.VersionService.GetReferenceScalarValues(mapNode, OpenApiConstants.Description);
var summary = node.Context.VersionService.GetReferenceScalarValues(mapNode, OpenApiConstants.Summary);

return mapNode.GetReferencedObject<OpenApiParameter>(ReferenceType.Parameter, pointer, summary, description);
return mapNode.GetReferencedObject<OpenApiParameter>(ReferenceType.Parameter, pointer);
}

var parameter = new OpenApiParameter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,10 @@ public static OpenApiPathItem LoadPathItem(ParseNode node)

if (pointer != null)
{
var description = node.Context.VersionService.GetReferenceScalarValues(mapNode, OpenApiConstants.Description);
var summary = node.Context.VersionService.GetReferenceScalarValues(mapNode, OpenApiConstants.Summary);

return new OpenApiPathItem()
{
UnresolvedReference = true,
Reference = node.Context.VersionService.ConvertToOpenApiReference(pointer, ReferenceType.PathItem, summary, description)
Reference = node.Context.VersionService.ConvertToOpenApiReference(pointer, ReferenceType.PathItem)
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ public static OpenApiRequestBody LoadRequestBody(ParseNode node)
var pointer = mapNode.GetReferencePointer();
if (pointer != null)
{
var description = node.Context.VersionService.GetReferenceScalarValues(mapNode, OpenApiConstants.Description);
var summary = node.Context.VersionService.GetReferenceScalarValues(mapNode, OpenApiConstants.Summary);

return mapNode.GetReferencedObject<OpenApiRequestBody>(ReferenceType.RequestBody, pointer, summary, description);
return mapNode.GetReferencedObject<OpenApiRequestBody>(ReferenceType.RequestBody, pointer);
}

var requestBody = new OpenApiRequestBody();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ public static OpenApiResponse LoadResponse(ParseNode node)
var pointer = mapNode.GetReferencePointer();
if (pointer != null)
{

var description = node.Context.VersionService.GetReferenceScalarValues(mapNode, OpenApiConstants.Description);
var summary = node.Context.VersionService.GetReferenceScalarValues(mapNode, OpenApiConstants.Summary);

return mapNode.GetReferencedObject<OpenApiResponse>(ReferenceType.Response, pointer, summary, description);
return mapNode.GetReferencedObject<OpenApiResponse>(ReferenceType.Response, pointer);
}

var response = new OpenApiResponse();
Expand Down
11 changes: 2 additions & 9 deletions src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ public OpenApiReference ConvertToOpenApiReference(
{
return new OpenApiReference
{
Summary = summary,
Description = description,
Type = type,
Id = reference
};
Expand All @@ -97,8 +95,6 @@ public OpenApiReference ConvertToOpenApiReference(
// or a simple string-style reference for tag and security scheme.
return new OpenApiReference
{
Summary = summary,
Description = description,
Type = type,
ExternalResource = segments[0]
};
Expand All @@ -110,7 +106,7 @@ public OpenApiReference ConvertToOpenApiReference(
// "$ref": "#/components/schemas/Pet"
try
{
return ParseLocalReference(segments[1], summary, description);
return ParseLocalReference(segments[1]);
}
catch (OpenApiException ex)
{
Expand Down Expand Up @@ -165,7 +161,6 @@ public T LoadElement<T>(ParseNode node) where T : IOpenApiElement
return (T)_loaders[typeof(T)](node);
}


/// <inheritdoc />
public string GetReferenceScalarValues(MapNode mapNode, string scalarValue)
{
Expand All @@ -180,7 +175,7 @@ public string GetReferenceScalarValues(MapNode mapNode, string scalarValue)
return null;
}

private OpenApiReference ParseLocalReference(string localReference, string summary = null, string description = null)
private OpenApiReference ParseLocalReference(string localReference)
{
if (string.IsNullOrWhiteSpace(localReference))
{
Expand All @@ -202,8 +197,6 @@ private OpenApiReference ParseLocalReference(string localReference, string summa

var parsedReference = new OpenApiReference
{
Summary = summary,
Description = description,
Type = referenceType,
Id = refId
};
Expand Down

0 comments on commit 076009c

Please sign in to comment.