I have to implement this kind of Api Controller in C#:
requestBody:
description: A JSON object containing pet information
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Dog'
- $ref: '#/components/schemas/Hamster'
oneOf docs: https://swagger.io/docs/specification/describing-request-body/ Expected output:
I'm using: <PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="6.5.0" />
I have already tried with dynamic or Interface but the swagger generator didn't do oneOf schema as in the image.
Do you have a C# example?

Here is the tutorial for you, hope it can help you.
1. Create a Basic WebApi Project like below.
2. Using below settings in Program.cs
3. Modify the WeatherForecast.cs file.
4. Modify the method on controller.
5. Test Result