Feature Implementation Plan: Add Missing Fields to CoffeeBeanDTO¶
📋 Todo Checklist¶
- [ ] Add
suitableForEspressoandsuitableForFilterproperties to theCoffeeBeanDTO. - [ ] Update the
EntityToDtoMapperservice to map these new properties from the entity to the DTO. - [ ] Update integration tests to assert that these fields are now present in the API response for coffee bean lists.
- [ ] Final Review and Testing
🔍 Analysis & Investigation¶
Codebase Structure¶
- DTO: The file
src/DTO/Api/CoffeeBeanDTO.phpis the primary target for changes. - Mapper: The service
src/Service/Api/Mapper/EntityToDtoMapper.phpwill be updated to populate the new DTO fields.
Root Cause Analysis¶
The issue is a simple omission. When the CoffeeBeanDTO was created to solve the caching serialization problem, the suitableForEspresso and suitableForFilter fields were overlooked and not included in the DTO's properties. The API's list endpoints use this DTO to generate their response, so the fields are missing from the final JSON output, even though they are present on the source CoffeeBean entity and are filterable.
Dependencies & Integration Points¶
- This change is self-contained and has no external dependencies. It directly affects the data contract of the
/api/coffee-beanslist endpoint.
Considerations & Challenges¶
- This is a low-risk, high-value change. The only challenge is ensuring the mapping logic in the
EntityToDtoMapperis correctly implemented.
📝 Implementation Plan¶
Prerequisites¶
- No new external dependencies are required.
Step-by-Step Implementation¶
-
Update the
CoffeeBeanDTO- Files to modify:
src/DTO/Api/CoffeeBeanDTO.php - Changes needed: Add the two new boolean properties to the
__constructmethod.
- Files to modify:
-
Update the
EntityToDtoMapper- Files to modify:
src/Service/Api/Mapper/EntityToDtoMapper.php - Changes needed: In the
mapCoffeeBeansToDtosmethod (or equivalent), add the mapping for the new fields when constructing theCoffeeBeanDTO.
- Files to modify:
Testing Strategy¶
- Integration Tests:
- Modify the existing integration test for the
/api/coffee-beanslist endpoint. - Fetch the list of coffee beans.
- Take the first item from the
itemsarray. - Assert that the response now contains the keys
suitableForEspressoandsuitableForFilter. - Assert that their values are booleans.
- Modify the existing integration test for the
🎯 Success Criteria¶
- A
GETrequest to the/api/coffee-beanslist endpoint now includes thesuitableForEspressoandsuitableForFilterboolean fields in each coffee bean object. - The API response is now consistent with the API's filtering capabilities.
- The change is fully covered by integration tests.