I\'m working in a Spring Boot project, as my implement at the moment, almost for each API I have request and response classes.
For example:
Don't subclass the req/resp objects.
Use an auto de/serialiser like Jackson in your frame work to convert message payloads into business object.
However, you will still end up with a large number of business objects.
I will suggest you to use JSON format instead of creating class and returning its instance every time. But still if you need a class hierarchy you can create a class and put a variable which will store JSON.
Using tailored DTOs for request and response will give you more flexibility in the long run. Actually, nothing prevents you from using inheritance and inner classes, but I would just avoid it.
I already answered a similar question here, highlighting the benefits of using DTOs over persistence entities in REST APIs. Below you'll find a few benefits of this approach: