Skip to content

Commit

Permalink
Merge pull request #1415 from SimonCropp/discard-un-used-parameters
Browse files Browse the repository at this point in the history
discard un-used parameters
  • Loading branch information
baywet authored Oct 10, 2023
2 parents e6bec55 + bfcb6ae commit 7415500
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
12 changes: 6 additions & 6 deletions src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ internal static partial class OpenApiV2Deserializer
private static FixedFieldMap<OpenApiDocument> _openApiFixedFields = new()
{
{
"swagger", (o, n) =>
"swagger", (_, _) =>
{
} /* Version is valid field but we already parsed it */
},
{"info", (o, n) => o.Info = LoadInfo(n)},
{"host", (o, n) => n.Context.SetTempStorage("host", n.GetScalarValue())},
{"basePath", (o, n) => n.Context.SetTempStorage("basePath", n.GetScalarValue())},
{"host", (_, n) => n.Context.SetTempStorage("host", n.GetScalarValue())},
{"basePath", (_, n) => n.Context.SetTempStorage("basePath", n.GetScalarValue())},
{
"schemes", (o, n) => n.Context.SetTempStorage(
"schemes", (_, n) => n.Context.SetTempStorage(
"schemes",
n.CreateSimpleList(
s => s.GetScalarValue()))
},
{
"consumes",
(o, n) =>
(_, n) =>
{
var consumes = n.CreateSimpleList(s => s.GetScalarValue());
if (consumes.Count > 0)
Expand All @@ -46,7 +46,7 @@ internal static partial class OpenApiV2Deserializer
}
},
{
"produces", (o, n) => {
"produces", (_, n) => {
var produces = n.CreateSimpleList(s => s.GetScalarValue());
if (produces.Count > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ internal static partial class OpenApiV2Deserializer
}
},
{
"consumes", (o, n) => {
"consumes", (_, n) => {
var consumes = n.CreateSimpleList(s => s.GetScalarValue());
if (consumes.Count > 0) {
n.Context.SetTempStorage(TempStorageKeys.OperationConsumes,consumes);
}
}
},
{
"produces", (o, n) => {
"produces", (_, n) => {
var produces = n.CreateSimpleList(s => s.GetScalarValue());
if (produces.Count > 0) {
n.Context.SetTempStorage(TempStorageKeys.OperationProduces, produces);
Expand Down Expand Up @@ -185,7 +185,7 @@ private static OpenApiRequestBody CreateFormBody(ParsingContext context, List<Op
{
Content = consumes.ToDictionary(
k => k,
v => mediaType)
_ => mediaType)
};

return formBody;
Expand All @@ -205,7 +205,7 @@ internal static OpenApiRequestBody CreateRequestBody(
Required = bodyParameter.Required,
Content = consumes.ToDictionary(
k => k,
v => new OpenApiMediaType
_ => new OpenApiMediaType
{
Schema = bodyParameter.Schema
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,27 @@ internal static partial class OpenApiV2Deserializer
{"name", (o, n) => o.Name = n.GetScalarValue()},
{"in", (o, n) => o.In = n.GetScalarValue().GetEnumFromDisplayName<ParameterLocation>()},
{
"flow", (o, n) =>
"flow", (_, n) =>
{
_flowValue = n.GetScalarValue();
}
},
{
"authorizationUrl",
(o, n) =>
(_, n) =>
{
_flow.AuthorizationUrl = new(n.GetScalarValue(), UriKind.RelativeOrAbsolute);
}
},
{
"tokenUrl",
(o, n) =>
(_, n) =>
{
_flow.TokenUrl = new(n.GetScalarValue(), UriKind.RelativeOrAbsolute);
}
},
{
"scopes", (o, n) =>
"scopes", (_, n) =>
{
_flow.Scopes = n.CreateSimpleMap(LoadString);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal static partial class OpenApiV3Deserializer
private static FixedFieldMap<OpenApiDocument> _openApiFixedFields = new()
{
{
"openapi", (o, n) =>
"openapi", (_, _) =>
{
} /* Version is valid field but we already parsed it */
},
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Models/OpenApiComponents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void SerializeAsV3(IOpenApiWriter writer)
writer.WriteOptionalMap(
OpenApiConstants.Schemas,
Schemas,
(w, key, component) => {
(w, _, component) => {
component.SerializeAsV3WithoutReference(w);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Models/OpenApiDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void SerializeAsV2(IOpenApiWriter writer)
writer.WriteOptionalMap(
OpenApiConstants.Definitions,
openApiSchemas,
(w, key, component) =>
(w, _, component) =>
{
component.SerializeAsV2WithoutReference(w);
});
Expand Down
10 changes: 5 additions & 5 deletions src/Microsoft.OpenApi/Services/OpenApiFilterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,12 @@ private static void ValidateFilters(IDictionary<string, List<string>> requestUrl
{
if (operationIds == "*")
{
return (url, operationType, operation) => true; // All operations
return (_, _, _) => true; // All operations
}
else
{
var operationIdsArray = operationIds.Split(',');
return (url, operationType, operation) => operationIdsArray.Contains(operation.OperationId);
return (_, _, operation) => operationIdsArray.Contains(operation.OperationId);
}
}

Expand All @@ -319,11 +319,11 @@ private static void ValidateFilters(IDictionary<string, List<string>> requestUrl
if (tagsArray.Length == 1)
{
var regex = new Regex(tagsArray[0]);
return (url, operationType, operation) => operation.Tags.Any(tag => regex.IsMatch(tag.Name));
return (_, _, operation) => operation.Tags.Any(tag => regex.IsMatch(tag.Name));
}
else
{
return (url, operationType, operation) => operation.Tags.Any(tag => tagsArray.Contains(tag.Name));
return (_, _, operation) => operation.Tags.Any(tag => tagsArray.Contains(tag.Name));
}
}

Expand Down Expand Up @@ -357,7 +357,7 @@ private static void ValidateFilters(IDictionary<string, List<string>> requestUrl
}

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

private static List<string> GetOperationTypes(IDictionary<OperationType, OpenApiOperation> openApiOperations, List<string> url, string path)
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ private static void WriteMapInternal<T>(
IDictionary<string, T> elements,
Action<IOpenApiWriter, T> action)
{
WriteMapInternal(writer, name, elements, (w, k, s) => action(w, s));
WriteMapInternal(writer, name, elements, (w, _, s) => action(w, s));
}

private static void WriteMapInternal<T>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void ParseCustomExtension()
""";
var settings = new OpenApiReaderSettings
{
ExtensionParsers = { { "x-foo", (a,v) => {
ExtensionParsers = { { "x-foo", (a,_) => {
var fooNode = (OpenApiObject)a;
return new FooExtension
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void UnresolvedSchemaReferencedShouldNotBeValidated()

public class AlwaysFailRule<T> : ValidationRule<T> where T : IOpenApiElement
{
public AlwaysFailRule() : base((c, t) => c.CreateError("x", "y"))
public AlwaysFailRule() : base((c, _) => c.CreateError("x", "y"))
{
}
}
Expand Down

0 comments on commit 7415500

Please sign in to comment.