An API client connects an application to a service through its API. It sends requests or asynchronous messages, processes incoming responses or messages, serializes outbound payloads, and deserializes inbound data into domain objects. section 8.1.7
Choose how the client models exchanged messages by weighing development effort, schema correctness, and type safety:
- Use untyped structures such as maps or dictionaries, handwritten classes, code-generated classes, or libraries provided by the service team. section 8.1.7
- Binary payload formats almost always use generated DTOs; text-based formats allow handwritten or generated DTOs, or untyped structures. section 8.1.7
- Model only the message types or fields relevant to the client when a projection of the full schema is sufficient. section 8.1.7
Figure 8.3 An API client must have a data model of the messages that it exchanges with the service. The data model must serialize and deserialize correctly as defined by the schema. It can either be untyped (e.g. hash maps) or consist of handwritten or code-generated classes.
The diagram compares untyped and class-based message models and shows their serialization and deserialization responsibilities. section 8.1.7
