I want to send a structured JSON query body to QUERY /todos,
so that I can learn body-based safe querying without needing to learn JSONPath first.
Scope
Implement QUERY /todos with:
Content-Type: application/vnd.apichallenges.todo-query+json
Accept: application/json
The request body should be an API Challenges-defined JSON query object.
Example:
{
"filter": {
"doneStatus": false,
"title": {
"contains": "scan"
}
},
"sort": [
{
"field": "id",
"direction": "desc"
}
],
"limit": 10,
"offset": 0
}
Expected Behaviour
QUERY /todos is safe and idempotent.
- It must not mutate todo data.
- Supported
filter fields:
id
title
description
doneStatus
- Supported filter operations:
- exact match
contains for text fields
greaterThan / lessThan for id
- Supported sorting:
- Supported pagination:
- Response format is controlled by
Accept.
Accept-Query should advertise support:
Accept-Query: application/vnd.apichallenges.todo-query+json
Error Behaviour
- Missing
Content-Type returns 400.
- Unsupported
Content-Type returns 415.
- Malformed JSON returns
400.
- Unknown query fields or unsupported operators return
422.
- Invalid pagination values return
422.
- Unsupported response
Accept values still return 406.
Acceptance Criteria
- A query can filter todos by
doneStatus.
- A query can filter text using
contains.
- A query can sort and paginate results.
- Unknown fields are rejected rather than ignored.
- The
+json media type is parsed as JSON but only accepted when the full media type is supported.
OPTIONS /todos includes QUERY in Allow.
Accept-Query includes application/vnd.apichallenges.todo-query+json.
I want to send a structured JSON query body to
QUERY /todos,so that I can learn body-based safe querying without needing to learn JSONPath first.
Scope
Implement
QUERY /todoswith:The request body should be an API Challenges-defined JSON query object.
Example:
{ "filter": { "doneStatus": false, "title": { "contains": "scan" } }, "sort": [ { "field": "id", "direction": "desc" } ], "limit": 10, "offset": 0 }Expected Behaviour
QUERY /todosis safe and idempotent.filterfields:idtitledescriptiondoneStatuscontainsfor text fieldsgreaterThan/lessThanforididtitledoneStatuslimitoffsetAccept.Accept-Queryshould advertise support:Accept-Query: application/vnd.apichallenges.todo-query+jsonError Behaviour
Content-Typereturns400.Content-Typereturns415.400.422.422.Acceptvalues still return406.Acceptance Criteria
doneStatus.contains.+jsonmedia type is parsed as JSON but only accepted when the full media type is supported.OPTIONS /todosincludesQUERYinAllow.Accept-Queryincludesapplication/vnd.apichallenges.todo-query+json.