Skip to content

Commit 7415500

Browse files
authored
Merge pull request #1415 from SimonCropp/discard-un-used-parameters
discard un-used parameters
2 parents e6bec55 + bfcb6ae commit 7415500

File tree

10 files changed

+25
-25
lines changed

10 files changed

+25
-25
lines changed

src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ internal static partial class OpenApiV2Deserializer
2121
private static FixedFieldMap<OpenApiDocument> _openApiFixedFields = new()
2222
{
2323
{
24-
"swagger", (o, n) =>
24+
"swagger", (_, _) =>
2525
{
2626
} /* Version is valid field but we already parsed it */
2727
},
2828
{"info", (o, n) => o.Info = LoadInfo(n)},
29-
{"host", (o, n) => n.Context.SetTempStorage("host", n.GetScalarValue())},
30-
{"basePath", (o, n) => n.Context.SetTempStorage("basePath", n.GetScalarValue())},
29+
{"host", (_, n) => n.Context.SetTempStorage("host", n.GetScalarValue())},
30+
{"basePath", (_, n) => n.Context.SetTempStorage("basePath", n.GetScalarValue())},
3131
{
32-
"schemes", (o, n) => n.Context.SetTempStorage(
32+
"schemes", (_, n) => n.Context.SetTempStorage(
3333
"schemes",
3434
n.CreateSimpleList(
3535
s => s.GetScalarValue()))
3636
},
3737
{
3838
"consumes",
39-
(o, n) =>
39+
(_, n) =>
4040
{
4141
var consumes = n.CreateSimpleList(s => s.GetScalarValue());
4242
if (consumes.Count > 0)
@@ -46,7 +46,7 @@ internal static partial class OpenApiV2Deserializer
4646
}
4747
},
4848
{
49-
"produces", (o, n) => {
49+
"produces", (_, n) => {
5050
var produces = n.CreateSimpleList(s => s.GetScalarValue());
5151
if (produces.Count > 0)
5252
{

src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ internal static partial class OpenApiV2Deserializer
5757
}
5858
},
5959
{
60-
"consumes", (o, n) => {
60+
"consumes", (_, n) => {
6161
var consumes = n.CreateSimpleList(s => s.GetScalarValue());
6262
if (consumes.Count > 0) {
6363
n.Context.SetTempStorage(TempStorageKeys.OperationConsumes,consumes);
6464
}
6565
}
6666
},
6767
{
68-
"produces", (o, n) => {
68+
"produces", (_, n) => {
6969
var produces = n.CreateSimpleList(s => s.GetScalarValue());
7070
if (produces.Count > 0) {
7171
n.Context.SetTempStorage(TempStorageKeys.OperationProduces, produces);
@@ -185,7 +185,7 @@ private static OpenApiRequestBody CreateFormBody(ParsingContext context, List<Op
185185
{
186186
Content = consumes.ToDictionary(
187187
k => k,
188-
v => mediaType)
188+
_ => mediaType)
189189
};
190190

191191
return formBody;
@@ -205,7 +205,7 @@ internal static OpenApiRequestBody CreateRequestBody(
205205
Required = bodyParameter.Required,
206206
Content = consumes.ToDictionary(
207207
k => k,
208-
v => new OpenApiMediaType
208+
_ => new OpenApiMediaType
209209
{
210210
Schema = bodyParameter.Schema
211211
}),

src/Microsoft.OpenApi.Readers/V2/OpenApiSecuritySchemeDeserializer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,27 @@ internal static partial class OpenApiV2Deserializer
4747
{"name", (o, n) => o.Name = n.GetScalarValue()},
4848
{"in", (o, n) => o.In = n.GetScalarValue().GetEnumFromDisplayName<ParameterLocation>()},
4949
{
50-
"flow", (o, n) =>
50+
"flow", (_, n) =>
5151
{
5252
_flowValue = n.GetScalarValue();
5353
}
5454
},
5555
{
5656
"authorizationUrl",
57-
(o, n) =>
57+
(_, n) =>
5858
{
5959
_flow.AuthorizationUrl = new(n.GetScalarValue(), UriKind.RelativeOrAbsolute);
6060
}
6161
},
6262
{
6363
"tokenUrl",
64-
(o, n) =>
64+
(_, n) =>
6565
{
6666
_flow.TokenUrl = new(n.GetScalarValue(), UriKind.RelativeOrAbsolute);
6767
}
6868
},
6969
{
70-
"scopes", (o, n) =>
70+
"scopes", (_, n) =>
7171
{
7272
_flow.Scopes = n.CreateSimpleMap(LoadString);
7373
}

src/Microsoft.OpenApi.Readers/V3/OpenApiDocumentDeserializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal static partial class OpenApiV3Deserializer
1616
private static FixedFieldMap<OpenApiDocument> _openApiFixedFields = new()
1717
{
1818
{
19-
"openapi", (o, n) =>
19+
"openapi", (_, _) =>
2020
{
2121
} /* Version is valid field but we already parsed it */
2222
},

src/Microsoft.OpenApi/Models/OpenApiComponents.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void SerializeAsV3(IOpenApiWriter writer)
109109
writer.WriteOptionalMap(
110110
OpenApiConstants.Schemas,
111111
Schemas,
112-
(w, key, component) => {
112+
(w, _, component) => {
113113
component.SerializeAsV3WithoutReference(w);
114114
});
115115
}

src/Microsoft.OpenApi/Models/OpenApiDocument.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public void SerializeAsV2(IOpenApiWriter writer)
173173
writer.WriteOptionalMap(
174174
OpenApiConstants.Definitions,
175175
openApiSchemas,
176-
(w, key, component) =>
176+
(w, _, component) =>
177177
{
178178
component.SerializeAsV2WithoutReference(w);
179179
});

src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,12 @@ private static void ValidateFilters(IDictionary<string, List<string>> requestUrl
304304
{
305305
if (operationIds == "*")
306306
{
307-
return (url, operationType, operation) => true; // All operations
307+
return (_, _, _) => true; // All operations
308308
}
309309
else
310310
{
311311
var operationIdsArray = operationIds.Split(',');
312-
return (url, operationType, operation) => operationIdsArray.Contains(operation.OperationId);
312+
return (_, _, operation) => operationIdsArray.Contains(operation.OperationId);
313313
}
314314
}
315315

@@ -319,11 +319,11 @@ private static void ValidateFilters(IDictionary<string, List<string>> requestUrl
319319
if (tagsArray.Length == 1)
320320
{
321321
var regex = new Regex(tagsArray[0]);
322-
return (url, operationType, operation) => operation.Tags.Any(tag => regex.IsMatch(tag.Name));
322+
return (_, _, operation) => operation.Tags.Any(tag => regex.IsMatch(tag.Name));
323323
}
324324
else
325325
{
326-
return (url, operationType, operation) => operation.Tags.Any(tag => tagsArray.Contains(tag.Name));
326+
return (_, _, operation) => operation.Tags.Any(tag => tagsArray.Contains(tag.Name));
327327
}
328328
}
329329

@@ -357,7 +357,7 @@ private static void ValidateFilters(IDictionary<string, List<string>> requestUrl
357357
}
358358

359359
// predicate for matching url and operationTypes
360-
return (path, operationType, operation) => operationTypes.Contains(operationType + path);
360+
return (path, operationType, _) => operationTypes.Contains(operationType + path);
361361
}
362362

363363
private static List<string> GetOperationTypes(IDictionary<OperationType, OpenApiOperation> openApiOperations, List<string> url, string path)

src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ private static void WriteMapInternal<T>(
367367
IDictionary<string, T> elements,
368368
Action<IOpenApiWriter, T> action)
369369
{
370-
WriteMapInternal(writer, name, elements, (w, k, s) => action(w, s));
370+
WriteMapInternal(writer, name, elements, (w, _, s) => action(w, s));
371371
}
372372

373373
private static void WriteMapInternal<T>(

test/Microsoft.OpenApi.Readers.Tests/TestCustomExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void ParseCustomExtension()
2727
""";
2828
var settings = new OpenApiReaderSettings
2929
{
30-
ExtensionParsers = { { "x-foo", (a,v) => {
30+
ExtensionParsers = { { "x-foo", (a,_) => {
3131
var fooNode = (OpenApiObject)a;
3232
return new FooExtension
3333
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public void UnresolvedSchemaReferencedShouldNotBeValidated()
152152

153153
public class AlwaysFailRule<T> : ValidationRule<T> where T : IOpenApiElement
154154
{
155-
public AlwaysFailRule() : base((c, t) => c.CreateError("x", "y"))
155+
public AlwaysFailRule() : base((c, _) => c.CreateError("x", "y"))
156156
{
157157
}
158158
}

0 commit comments

Comments
 (0)