I am building a Spring Boot REST API for a tree structure. The project uses an OpenAPI contract-first approach, so my controller implements a generated interface: java @RestController public class TreeController implements TreeApi{ The API must support multiple storage implementations selected by configuration: app.storage=memory app.storage=postgres app.storage=mongo The response models come from OpenAPI, for example: NodeResponse TreeNodeResponse NodeListResponse NumberResponse ValidationResponse The problem is that each storage implementation returns a different internal model: CustomTreeNo