Skip to content

Commit 4894845

Browse files
authored
small code refactoring
1 parent c269612 commit 4894845

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/QAToolKit.Source.Swagger.Test/SwaggerUrlSourceIntegrationTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.Extensions.Logging;
2+
using Newtonsoft.Json;
23
using QAToolKit.Core.Models;
34
using System;
45
using System.Threading.Tasks;
@@ -47,6 +48,8 @@ public async Task SwaggerUrlSourceWithOptionsV3Test_Successfull()
4748
new Uri("https://petstore3.swagger.io/api/v3/openapi.json")
4849
});
4950

51+
_logger.LogInformation(JsonConvert.SerializeObject(requests, Formatting.Indented));
52+
5053
Assert.NotNull(requests);
5154
}
5255

src/QAToolKit.Source.Swagger/SwaggerProcessor.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -259,19 +259,14 @@ private IEnumerable<Parameter> GetParameters(KeyValuePair<OperationType, OpenApi
259259

260260
private Location GetPlacement(ParameterLocation In)
261261
{
262-
switch (In)
262+
return In switch
263263
{
264-
case ParameterLocation.Query:
265-
return Location.Query;
266-
case ParameterLocation.Path:
267-
return Location.Path;
268-
case ParameterLocation.Header:
269-
return Location.Header;
270-
case ParameterLocation.Cookie:
271-
return Location.Cookie;
272-
default:
273-
throw new QAToolKitSwaggerException($"Invalid parameter location '{In}'.");
274-
}
264+
ParameterLocation.Query => Location.Query,
265+
ParameterLocation.Path => Location.Path,
266+
ParameterLocation.Header => Location.Header,
267+
ParameterLocation.Cookie => Location.Cookie,
268+
_ => throw new QAToolKitSwaggerException($"Invalid parameter location '{In}'."),
269+
};
275270
}
276271

277272
private List<RequestBody> GetRequestBodies(KeyValuePair<OperationType, OpenApiOperation> openApiOperation)

0 commit comments

Comments
 (0)