Skip to content
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

OpenAPI - Polymorphism class does not work for response #59214

Open
1 task done
mickaelropars opened this issue Nov 28, 2024 · 0 comments
Open
1 task done

OpenAPI - Polymorphism class does not work for response #59214

mickaelropars opened this issue Nov 28, 2024 · 0 comments
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-openapi

Comments

@mickaelropars
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have a method that produce
and I am using the Microsoft.AspNetCore.OpenApi package in order to produce the openapi json file

here is my code

[ProducesResponseType(typeof(ConcreteClass1),StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ConcreteClass2), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ConcreteClass3), StatusCodes.Status200OK)]
public ActionResult<BaseClass> Get(int id)
{
    var dto= service.Get(id);
    return Ok(dto);
}

The tree ConcreteClass implement the same BaseClass

But in the json produce openAI only ConcreteClass3 is present

Expected Behavior

what I am expecting is in the OpenApiOperation Response to have the 3 schemas described using the "oneOf" properties in order to store the 3 schemas

Steps To Reproduce

[ProducesResponseType(typeof(ConcreteClass1),StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ConcreteClass2), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ConcreteClass3), StatusCodes.Status200OK)]
public ActionResult<BaseClass> Get(int id)
{
    var dto= service.Get(id);
    return Ok(dto);
}

Exceptions (if any)

No response

.NET Version

9.0

Anything else?

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels label Nov 28, 2024
@mickaelropars mickaelropars changed the title OpenAPI - Polymorphism cmass does not work for response OpenAPI - Polymorphism class does not work for response Nov 28, 2024
@martincostello martincostello added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-openapi and removed area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels labels Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-openapi
Projects
None yet
Development

No branches or pull requests

2 participants