Closed hartmair closed 1 year ago
As you have a big refactoring for the OperationFilterContextExtensions, maybe you can fix issue #225 (PR: #226 ) ?
There's a need just to change DeclaringType
to ReflectedType
@mattfrear PR is ready
I just tried to run your feature branch with my test/WebApi3.1 test project, and it throws an exception:
System.ArgumentException
HResult=0x80070057
Message=An item with the same key has already been added. Key: CustomHeader
Source=System.Private.CoreLib
StackTrace:
at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException[T](T key)
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at Swashbuckle.AspNetCore.Filters.AddResponseHeadersFilter.Apply(OpenApiOperation operation, OperationFilterContext context) in C:\code\github\Swashbuckle.AspNetCore.Filters\src\Swashbuckle.AspNetCore.Filters\ResponseHeaders\AddResponseHeadersFilter.cs:line 29
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperation(ApiDescription apiDescription, SchemaRepository schemaRepository)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperations(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GeneratePaths(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.<Invoke>d__4.MoveNext()
I haven't had time to investigate, but it seems strange, because you haven't changed the AddResponseHeadersFilter
which is throwing the exception.
@mattfrear
I just tried to run your feature branch with my test/WebApi3.1 test project, and it throws an exception:
I have added integration tests and updated the implementation which led to much better solution :)
Just a note to say I haven't forgotten about this.
I am on holiday with my family, and I was hoping I would have a chance to look at it during my holiday, but that is unrealistic. So I won't be able to look at this until early September.
Sorry about the delay.
Thanks again for this - as discussed here https://github.com/mattfrear/Swashbuckle.AspNetCore.Filters/issues/227#issuecomment-1707502143
What's in this PR:
MethodInfo
andApiDescription.ActionDescriptor.EndpointMetadata
are provided introduced in https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/2356, i.e. Swashbuckle.AspNetCore.SwaggerGen Version 6.3.0 or later Fixes #227