Skip to content

Commit

Permalink
Fixing breaking change when applying filters for WithOpenApi extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier García de la Noceda Argüelles committed Sep 30, 2024
1 parent 8b0e896 commit a08a082
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ private async Task<OpenApiOperation> GenerateOpenApiOperationFromMetadataAsync(A
{
var (parameterAndContext, filterContext) = GenerateParameterAndContext(apiParameter, schemaRepository);
parameter.Schema = parameterAndContext.Schema;
parameter.Description = parameterAndContext.Description;
parameter.Description ??= parameterAndContext.Description;

foreach (var filter in _options.ParameterAsyncFilters)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,17 @@
"tags": [
"WithOpenApi"
],
"parameters": [
{
"name": "queryParameter",
"in": "query",
"description": "queryParameter Description",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"multipart/form-data": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,17 @@
"tags": [
"WithOpenApi"
],
"parameters": [
{
"name": "queryParameter",
"in": "query",
"description": "queryParameter Description",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"multipart/form-data": {
Expand Down
14 changes: 11 additions & 3 deletions test/WebSites/WebApi/EndPoints/OpenApiEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,18 @@ public static IEndpointRouteBuilder MapWithOpenApiEndpoints(this IEndpointRouteB
})
.WithOpenApi();

group.MapPost("/IFromFile", (IFormFile file) =>
group.MapPost("/IFromFile", (IFormFile file, string queryParameter) =>
{
return file.FileName;
}).WithOpenApi();
return $"{file.FileName}{queryParameter}";
}).WithOpenApi(o =>
{
var parameter = o.Parameters.FirstOrDefault(p => p.Name.Equals("queryParameter", StringComparison.InvariantCulture));
if (parameter is not null)
{
parameter.Description = $"{parameter.Name} Description";
}
return o;
});

group.MapPost("/IFromFileCollection", (IFormFileCollection collection) =>
{
Expand Down

0 comments on commit a08a082

Please sign in to comment.