Using inheritance in DTO switches to “consumes”: [“application/x-www-form-urlencoded”] instead of [“application/json”]
Example i have on DTO inhetring a base DTO (not to duplicate code).
[Route("/test",
Summary = "Create call",
Notes =
"Create Test.",
Verbs = "POST")]
[ApiResponse(HttpStatusCode.Unauthorized, "You were unauthorized to call this service")]
public class CreateTest : TestBase,IInterval,IReturn<TestResponse>
{
[ApiMember(
Description =
"The datetime you want to start the test.",
IsRequired = true)]
public DateTime From { get; set; }
}
public class TestBase
{
[ApiMember(
Description =
"The company id, if empty will use the company id for the user you are logged in with.",
IsRequired = false)]
public Guid? CompanyId { get; set; }
}
I’ve created a new empty project with these DTOs and I’m not seeing the change you’re reporting, with or without the base class, it’s always returning:
There’s a Consumes property on operation which maps to the same property in Open API format.
The entire Open API DTO can be modified by the Open API Filters before it’s returned and serialized so you can modify every Open API Scheme v2 property that’s serialized, e.g: