openactive / open-booking-api

Repository for the Open Booking API specification
Other
2 stars 3 forks source link

Allow matching of error responses to correct OrderItems #129

Open nickevansuk opened 4 years ago

nickevansuk commented 4 years ago

Proposer

ODI

Why is this needed?

JSON-LD does not support array ordering so the specification doesn't mandate consistency in request/response array ordering, and hence there is currently no way for a Broker to reliably match the OrderItem error responses from C1 and C2 with their request, especially when they have multiple OrderItems for the same opportunity.

This primarily effects C1 and C2, as OrderItem level error responses are not available from the other endpoints. However there may also be use cases for B and P where the Broker is interested in matching a particular requested item with its response.

Design

Discounting the option where the Broker generates an @id (and hence the URL structure), which it does not do elsewhere except for the endpoint URLs.

Three approaches considered:

1. The Broker generates a UUID for each OrderItem as the identifier, but the Booking System does not use these for the @id

Pros:

Cons:

2. The Broker generates a UUID for each OrderItem as the identifier, and the Booking System uses these to reflect back the @id that it immediately generates

Pros:

Cons:

3. The Broker generates a sequence number for each OrderItem based on their position in the array and includes it in the request; then the Booking System simply reflects this back to the Broker in their response.

Pros:

Cons:

Proposal: Use Option 3

schema:position is defined as a REQUIRED schema:Integer on OrderItem, for C1, C2, P and B requests and responses

schema:position is described as an integer representing the order of OrderItems within the array, as JSON-LD does not support array ordering. This allows the Broker to match any errors provided in the response to their request. The position of an OrderItem in the response MUST match the position for the same OrderItem provided in request, and implementations MUST use this value to match responses with requests instead of relying on the order of the elements in the array. This is REQUIRED for C1, C2, P and B requests and responses, but MUST NOT be persisted or be present in the Orders Feed or other endpoints.