Skip to content

An item with the same key has already been added when hiding inherited member #556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
techfg opened this issue Feb 19, 2023 · 0 comments

Comments

@techfg
Copy link

techfg commented Feb 19, 2023

Describe the issue
When a derived class hides an inherited member of its base, "An item with the same key has already been added" is encountered.

To Reproduce
Steps to reproduce the behavior:

  1. Clone https://github.com/techfg/azure-functions-openapi-extension
  2. Checkout brach hide-inherited-repro
  3. Run sample project Microsoft.Azure.WebJobs.Extensions.OpenApi.FunctionApp.InProc
  4. Open http://localhost:7071/api/swagger/ui in browser

Expected behavior
Swagger should display with MyDerivedClass.Data of type MyData property visible on MyDerivedClass

Environment (please complete the following information, if applicable):

  • OS: Windows
  • Browser: Edge
  • Version: 1.5.1

Additional context
The problem occurs in ObjectTypeVisitor where it detects Data property on both derived and base class. Using JsonIgnore on base class resolves issue but that creates issues when using MyBase directly in other areas. Common use case for this scenario is deriving a base class into a generic replacing the Data property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant