Azure / Azure/azure-functions-openapi-extension

ObjectTypeVisitor - cast to OpenApiSchemaAcceptor instead of IOpenApiSchemaAcceptor

Open
#654 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
388
Forks
202
PR merge metrics
No merged PRs in 30d

Description

**Describe the issue**
[azure-functions-openapi-extension](https://github.com/Azure/azure-functions-openapi-extension/tree/main)/[src](https://github.com/Azure/azure-functions-openapi-extension/tree/main/src)/[Microsoft.Azure.WebJobs.Extensions.OpenApi.Core](https://github.com/Azure/azure-functions-openapi-extension/tree/main/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core)/[Visitors](https://github.com/Azure/azure-functions-openapi-extension/tree/main/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](https://github.com/Azure/azure-functions-openapi-extension/assets/2660050/a9ffe3e9-f5d9-478a-8fe1-278bb6010900)

Contributor guide

Open the contributing guide

Research direction

Open src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ObjectTypeVisitor.cs around line 110 and inspect how the acceptor is cast and processed. Reproduce or review the custom IOpenApiSchemaAcceptor scenario described in the issue, then verify that interface-based acceptors are processed and the duplicate-key attribute behavior is corrected.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.