Catalog API Replaces Zero Page Size with Default
Level 2 · node · API · Zero page size overwritten by default
Scenario
A fictional parts catalog API returns the requested number of products. A preview screen requests size=0 to validate filters without loading any products. The service currently replaces zero with its default size and returns unnecessary data. Follow page-size parsing in the controller and slicing in the service.
Requirements
Use the default page size of 2 only when size is omitted. Accept integer zero and return an empty list. Positive integers return that many products, while negative and nonnumeric values return 400. count must equal the returned list length.
Acceptance criteria
- Omitted size returns the default two products.
- Size zero returns an empty list with count zero.
- Size one returns exactly one product.
- Negative and nonnumeric sizes are rejected with 400.