Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions openspec/changes/add-estimated-delivery-date/.openspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-10-09
7 changes: 7 additions & 0 deletions openspec/changes/add-estimated-delivery-date/design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Design

No technical decision between real alternatives. Each entry in the existing
DataWeave `orders` variable holds a status and an estimated delivery date
(`null` for `DELIVERED`); the success branch adds `estimatedDeliveryDate` to the
body. The date is kept as a `YYYY-MM-DD` string so it is returned exactly as
stored. Validation, `404` and `405` branches are unchanged.
61 changes: 61 additions & 0 deletions openspec/changes/add-estimated-delivery-date/proposal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## Why

The product owner asked: "Agora precisamos mostrar também a data prevista de
entrega." The delivery-status endpoint returns only `orderNumber` and `status`;
clients cannot see when an order is expected to arrive.

## What Changes

- The successful response of `GET /api/orders/{orderNumber}/delivery-status`
gains a third field with the estimated delivery date.
- The sample orders gain an estimated delivery date each.
- Error responses, validation, `404` and `405` behaviour do not change.

Decided with the product owner (2026-10-09):

- Field name `estimatedDeliveryDate`, a date string `YYYY-MM-DD` (no time, no
time zone).
- The date is stored with each sample order, not calculated.
- The field is always present. `PENDING` and `IN_TRANSIT` orders always have a
date; only a `DELIVERED` order has `null`.
- Sample data: `1001` `IN_TRANSIT` `2026-10-15`, `1002` `PENDING`
`2026-10-20`, `1003` `DELIVERED` `null`.

## Decisions on the open questions

1. **Delivered orders**: `null`. An estimate for something already delivered
means nothing, and the actual delivery date is a different requirement
nobody asked for.
2. **Unknown estimate**: not allowed. `PENDING` and `IN_TRANSIT` always carry
a date.
3. **Format and precision**: date only, `YYYY-MM-DD`.
4. **Source**: fixed per order in the sample data.
5. **Field name**: `estimatedDeliveryDate`.
6. **Breaking change** (raised by the proposal itself): accepted on purpose.
The previous spec promised "exactly two fields", so clients that reject
unknown fields will break. For this example, versioning the API would be
more change than the request asks for.

## Out of Scope

- Actual delivery date, delivery history, tracking events, carrier details.
- Calculating or updating estimates; any new endpoint or query parameter.
- Changes to error responses, validation or supported methods.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

- `delivery-status`: the successful response includes the estimated delivery
date.

## Impact

- `src/main/mule/delivery-status.xml`: sample data and success body.
- `README.md`: updated curl evidence for the success scenarios.
- Breaking for clients that reject unknown fields: the body no longer has
"exactly two fields". Accepted by the product owner (decision 6).
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## MODIFIED Requirements

### Requirement: Return delivery status by order number
The API SHALL return the current delivery status of an order when called with
`GET /api/orders/{orderNumber}/delivery-status` for an order number it knows.
The order number is an identifier matched exactly as sent: leading zeros are
part of it and are not removed. A successful response SHALL have status `200`,
header `Content-Type: application/json` and a body with exactly three fields:
`orderNumber` (string, as sent), `status` (one of `PENDING`, `IN_TRANSIT`,
`DELIVERED`) and `estimatedDeliveryDate`, which SHALL be a `YYYY-MM-DD` string
for `PENDING` and `IN_TRANSIT` and SHALL be `null` for `DELIVERED`.

#### Scenario: Known order in transit
- **WHEN** a client sends `GET /api/orders/1001/delivery-status` and order `1001` has status `IN_TRANSIT` and estimated delivery date `2026-10-15`
- **THEN** the API responds `200` with `Content-Type: application/json`
- **AND** the body is `{"orderNumber": "1001", "status": "IN_TRANSIT", "estimatedDeliveryDate": "2026-10-15"}`

#### Scenario: Known order pending
- **WHEN** a client sends `GET /api/orders/1002/delivery-status` and order `1002` has status `PENDING` and estimated delivery date `2026-10-20`
- **THEN** the API responds `200` with `Content-Type: application/json`
- **AND** the body is `{"orderNumber": "1002", "status": "PENDING", "estimatedDeliveryDate": "2026-10-20"}`

#### Scenario: Known order delivered
- **WHEN** a client sends `GET /api/orders/1003/delivery-status` and order `1003` has status `DELIVERED`
- **THEN** the API responds `200` with `Content-Type: application/json`
- **AND** the body is `{"orderNumber": "1003", "status": "DELIVERED", "estimatedDeliveryDate": null}`
13 changes: 13 additions & 0 deletions openspec/changes/add-estimated-delivery-date/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Tasks

## 1. Application

- [ ] 1.1 Add the estimated delivery date to the sample orders and `estimatedDeliveryDate` to the success body in `src/main/mule/delivery-status.xml`; verified by `mvn clean package` succeeding (HTTP behaviour is verified in group 2)

## 2. Evidence

Run the application locally. For each task, update `README.md` with the curl call and the real response (status line, `Content-Type` and body). A task is done only when the captured status and `Content-Type` match its scenario and the JSON body matches it structurally (same field names, types and values; whitespace and field order do not matter).

- [ ] 2.1 Scenarios "Known order in transit", "Known order pending" and "Known order delivered"
- [ ] 2.2 Re-run one call per unchanged error scenario (`404`, `400`, `405`) and confirm the responses are unchanged
- [ ] 2.3 Run `openspec validate --all --strict`; verified by it passing
Loading