Skip to content

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

@techfg

Description

@techfg

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions