Azure / azure-functions-openapi-extension

This extension provides an Azure Functions app with Open API capability for better discoverability to consuming parties
https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.OpenApi/
MIT License
375 stars 196 forks source link

ObjectTypeVisitor - cast to OpenApiSchemaAcceptor instead of IOpenApiSchemaAcceptor #654

Open Wozbo opened 6 months ago

Wozbo commented 6 months ago

Describe the issue azure-functions-openapi-extension/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors /ObjectTypeVisitor.cs

Line ~110 ish, there is a line that reads var instance = acceptor as OpenApiSchemaAcceptor;. When testing with a custom IOpenApiSchemaAcceptor, this was not processing, its because we cast to the concrete implementation type instead of the interface type. This stumped us recently, debugging attribute errors with duplicate keys.

Expected behavior I think this should be var instance = acceptor as IOpenApiSchemaAcceptor

Screenshots If applicable, add screenshots to help explain your issue. image

Wozbo commented 6 months ago

Adding to this, seems like this is also an issue in TypeVisitor.cs, line ~126 ish