Swirrl / drafter

A clojure service and a client to it for exposing data management operations to PMD
Other
0 stars 0 forks source link

accept query parameter as alternative to header #632

Closed callum-oakley closed 2 years ago

callum-oakley commented 2 years ago

Supports specification of media type via an accept query parameter, which takes the same values as the accept header, but can be used in contexts where the user has no control over headers.

In the original issue there was discussion of using a format parameter and mapping back to a media type from there, but I'm not sure there's any advantage to introducing this extra logic over reusing the existing logic for the accept header? Open to be convinced.

e.g.

$ curl "localhost:3001/v1/sparql/live?accept=application/json&query=$(urlq 'select (count(*) as ?c) where { ?s ?p ?o }')"
{
  "head" : {
    "vars" : [
      "c"
    ]
  },
  "results" : {
    "bindings" : [
      {
        "c" : {
          "datatype" : "http://www.w3.org/2001/XMLSchema#integer",
          "type" : "literal",
          "value" : "28252"
        }
      }
    ]
  }
}

closes #625

callum-oakley commented 2 years ago

Good point, updated the swagger doc (and added another test for the get draftset data case).

RicSwirrl commented 2 years ago

I'm happy to just pass the header as a parameter called accept. Does the job!