Skip to content

CrudApiPlugin: Support query string parameters in actions #1670

Description

@garrytrinder

Description

CrudApiPlugin actions currently only match on URL path segments. There's no way to filter data based on query string parameters, which is a very common API pattern (e.g. GET /jokes?category=azure).

Proposed solution

Allow action URLs to define query string parameters that can be used in JSONPath queries, similar to how path parameters work today.

Example configuration

{
  "action": "getMany",
  "url": "?category={category}",
  "query": "$.[?(@.categories[?(@ == '{category}')])]"
}

Expected behavior

GET /baseUrl?category=azure would extract azure as the {category} parameter and use it in the JSONPath query to filter matching items from the data file.

Use case

Simulating the MVP Jokes API which has:

  • GET /jokes?category=azure — returns jokes filtered by category query parameter
  • GET /jokes/by-category/{category} — returns jokes filtered by category path parameter (this also requires array membership filtering in JSONPath, which is unreliable with Newtonsoft's implementation)

Currently, neither pattern can be simulated with CrudApiPlugin because:

  1. Query string parameters aren't supported in action URL definitions
  2. Filtering by array membership (categories array contains a value) is difficult to express reliably in Newtonsoft JSONPath

Metadata

Metadata

Labels

No labels
No labels

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions