Skip to content

Add QUERY Support For application/vnd.apichallenges.todo-query+json #106

Description

@eviltester

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:
    • id
    • title
    • doneStatus
  • Supported pagination:
    • limit
    • offset
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions