oasis-tcs / odata-specs

OASIS OData TC: Markdown sources for OData specification drafts. https://github.com/oasis-tcs/odata-specs
https://oasis-tcs.github.io/odata-specs/
Other
6 stars 2 forks source link

/$query with "structured" $filter in JSON body #1977

Open ralfhandl opened 2 months ago

ralfhandl commented 2 months ago

371 added JSON request bodies for requests to /$query where system query options can be passed as name-value pairs, restricting the system query option value to a string.

This works fine for service implementations that have a full-fledged query option parser, and it is an implementation hurdle for less fortunate teams.

These would benefit from a "pre-parsed" JSON representation of system query option values, especially for $filter.

Proposal

Allow CSDL JSON expressions as values for $filter.

Define similar "pre-parsed" JSON representations for other system query options:

Allow this also for action/function parameters whose value is an expression: "StartDate@expression":{...}

Add a Capabilities term to express which media types are supported for /$query, whether @expression is supported, and whether the expressions can be stringy or JSONy.

Example

Already allowed:

POST http://host/service/People/$query
Content-Type: application/json

{
  "$filter": "LastName eq 'P&G'",
  "$select": "FirstName,LastName"
}

Allow additionally:

POST http://host/service/People/$query
Content-Type: application/json

{
  "$filter": {
    "$Eq": [
      {
        "$Path": "LastName"
      },
      "P&G"
    ]
  },
  "$select": ["FirstName", "LastName"]
}
ralfhandl commented 2 months ago

TC 2024-08-28: nice idea, let's flesh it out in a pull request and then decide whether we want to go that route.

ralfhandl commented 2 months ago

More detailed proposal see

HeikoTheissen commented 2 months ago

Also allow such structured system query options in action payloads?

ralfhandl commented 2 months ago

Query options cannot be passed in action payloads so far, do you want to open an issue for that?

HeikoTheissen commented 2 months ago

Let's wait until there is a requirement for that.