This chapter covers
- Updating the domain model with new concepts
- Using subtypes and inheritance in the domain model
- Creating composite JSON schemas from the domain model
In the last chapter, José and his team identified new requirements from the initial tests and planned a new development sprint with the goal of sharing the API with an external team for mobile app development as well as working towards making the API ready for wider release. One functional requirement to tackle as part of the sprint is the support of multiple pets per job and also pets other than dogs. The requirement implied changes to the domain model.
By going through the user stories, the PetSitter team realized that many parts of the domain model and, thus, the API description, can remain the same. The affected segment of the model is the dog concept and its relationship with the job, which we’ll now update.
In this chapter, we consider different approaches for changing the dog concept to represent different pets in the domain model and the OpenAPI definition. We look at cats and dogs for now, but the goal is finding a system that is extensible for additional species. We learn about polymorphism in domain models and the OpenAPI composition keywords and apply them. At the end, by doing that, we’ll have an updated domain model and OpenAPI description that help implementing the new functional requirements.