Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query: potential candidate for query format: jsonpath #2924

Open
reschke opened this issue Oct 20, 2024 · 11 comments
Open

query: potential candidate for query format: jsonpath #2924

reschke opened this issue Oct 20, 2024 · 11 comments

Comments

@reschke
Copy link
Contributor

reschke commented Oct 20, 2024

Spec: https://www.rfc-editor.org/rfc/rfc9535.html

  • how to augment the existing media type definition for QUERY (do we need to?
  • what response format to use? (application/json)?
@timbray
Copy link
Contributor

timbray commented Oct 20, 2024

If I'm building an API around the new QUERY method, surely I'd have to specify the media types for both query and response, right? So I'm not sure what's special about JSONPath.

@reschke
Copy link
Contributor Author

reschke commented Oct 20, 2024

The theory is that for a media type to be applicable for QUERY the semantics for QUERY should be specified somewhere. That idea dates back to the time when people just used application/json as payload format for PATCH, with different ideas what that actually means.

But I agree that the semantics for JsonPath with QUERY are pretty clear, maybe except for the question what the JSON document being queried actually is. But that can remain an implementation detail of the server. Any recommendations about what format we should use in the response? Maybe you even could suggest an example?

@timbray
Copy link
Contributor

timbray commented Oct 20, 2024 via email

@reschke
Copy link
Contributor Author

reschke commented Oct 20, 2024

Ok, just checking: we don't want to define a standard response format, because we want to leave it specific to the server? I agree with that.

But for an example, would you recommend a specific response format (iff that this is just an example)?

@timbray
Copy link
Contributor

timbray commented Oct 20, 2024 via email

@mnot
Copy link
Member

mnot commented Oct 20, 2024

I think the difference here is that PATCH has side effects on the resource, whereas QUERY should not (generally). PATCH needed definition to describe those side effects, so it doesn't become another POST escape hatch.

@reschke
Copy link
Contributor Author

reschke commented Oct 21, 2024

Ok, so we'll just add an example using jsonpath.

@reschke
Copy link
Contributor Author

reschke commented Nov 1, 2024

Proposal:

QUERY /errata.json HTTP/1.1
Host: example.org
Content-Type: application/jsonpath
Accept: application/json

$..[?@doc-id=="RFC9110" && @errata_status_code!="Rejected"].[errata_id, submit_date]

from a fictious RFC errata database, selects all errata for RFC9110 which have not been rejected, and returns id, submission_date for each

HTTP/1.1 200 OK
Content-Type: application/json

[
  "7105",
  "2022-08-26",
  "7109",
  "2022-08-31",
  "7138",
  "2022-09-23",
  "7306",
  "2023-01-13",
  "7419",
  "2023-04-11"
]

@timbray
Copy link
Contributor

timbray commented Nov 1, 2024 via email

@reschke
Copy link
Contributor Author

reschke commented Nov 1, 2024

Oh, indeed. Thanks for catching this. Will edit in place.

@reschke
Copy link
Contributor Author

reschke commented Nov 3, 2024

We could also use this as example of conneg:

HTTP/1.1 200 OK
Content-Type: text/csv

errata_id, submit_date
7105, 2022-08-26
7109, 2022-08-31
7138, 2022-09-23
7306, 2023-01-13
7419, 2023-04-11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants