From 076009c82f21194ba9157dd040febcf4f9061a0f Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 16 Nov 2023 11:07:36 +0300 Subject: [PATCH] Clean up code --- .../V3/OpenApiExampleDeserializer.cs | 5 +---- .../V3/OpenApiHeaderDeserializer.cs | 5 +---- .../V3/OpenApiLinkDeserializer.cs | 5 +---- .../V3/OpenApiParameterDeserializer.cs | 5 +---- .../V3/OpenApiPathItemDeserializer.cs | 5 +---- .../V3/OpenApiRequestBodyDeserializer.cs | 5 +---- .../V3/OpenApiResponseDeserializer.cs | 6 +----- .../V3/OpenApiV3VersionService.cs | 11 ++--------- 8 files changed, 9 insertions(+), 38 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiExampleDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiExampleDeserializer.cs index 26e8e89be..1e114ad73 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiExampleDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiExampleDeserializer.cs @@ -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(ReferenceType.Example, pointer, summary, description); + return mapNode.GetReferencedObject(ReferenceType.Example, pointer); } var example = new OpenApiExample(); diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiHeaderDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiHeaderDeserializer.cs index 9caafc407..1616d67f0 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiHeaderDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiHeaderDeserializer.cs @@ -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(ReferenceType.Header, pointer, summary, description); + return mapNode.GetReferencedObject(ReferenceType.Header, pointer); } var header = new OpenApiHeader(); diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiLinkDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiLinkDeserializer.cs index 4209a9322..7bf4c650b 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiLinkDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiLinkDeserializer.cs @@ -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(ReferenceType.Link, pointer, summary, description); + return mapNode.GetReferencedObject(ReferenceType.Link, pointer); } ParseMap(mapNode, link, _linkFixedFields, _linkPatternFields); diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiParameterDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiParameterDeserializer.cs index 04c100fa1..9d65dfad1 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiParameterDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiParameterDeserializer.cs @@ -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(ReferenceType.Parameter, pointer, summary, description); + return mapNode.GetReferencedObject(ReferenceType.Parameter, pointer); } var parameter = new OpenApiParameter(); diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiPathItemDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiPathItemDeserializer.cs index ed1dae14d..458f29228 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiPathItemDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiPathItemDeserializer.cs @@ -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) }; } diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiRequestBodyDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiRequestBodyDeserializer.cs index c4fa4997f..a2633028e 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiRequestBodyDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiRequestBodyDeserializer.cs @@ -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(ReferenceType.RequestBody, pointer, summary, description); + return mapNode.GetReferencedObject(ReferenceType.RequestBody, pointer); } var requestBody = new OpenApiRequestBody(); diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiResponseDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiResponseDeserializer.cs index 3ada7df5d..45b8a3efb 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiResponseDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiResponseDeserializer.cs @@ -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(ReferenceType.Response, pointer, summary, description); + return mapNode.GetReferencedObject(ReferenceType.Response, pointer); } var response = new OpenApiResponse(); diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs index 7401b7d26..bd9e54985 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs @@ -86,8 +86,6 @@ public OpenApiReference ConvertToOpenApiReference( { return new OpenApiReference { - Summary = summary, - Description = description, Type = type, Id = reference }; @@ -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] }; @@ -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) { @@ -165,7 +161,6 @@ public T LoadElement(ParseNode node) where T : IOpenApiElement return (T)_loaders[typeof(T)](node); } - /// public string GetReferenceScalarValues(MapNode mapNode, string scalarValue) { @@ -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)) { @@ -202,8 +197,6 @@ private OpenApiReference ParseLocalReference(string localReference, string summa var parsedReference = new OpenApiReference { - Summary = summary, - Description = description, Type = referenceType, Id = refId };