rstudio / plumbertableau

R package for creating Plumber APIs that function as Tableau Analytics Extensions
https://rstudio.github.io/plumbertableau/
Other
30 stars 1 forks source link

OpenAPI documentation `curl` command seems to mix Tableau-style and regular-style invocation #43

Closed toph-allen closed 3 years ago

toph-allen commented 3 years ago

I'm running the stringutils example, and I see this CURL command under "Try it out":

Screen Shot 2021-07-16 at 3 59 08 PM
curl -X POST "http://127.0.0.1:8215/lowercase" -H  "accept: */*" -H  "Content-Type: application/json" -d "{\"script\":\"/lowercase\",\"data\":{\"_arg1\":[\"string\"]}}"

Notice that the URL's path component is /lowercase, but the JSON blob also contains the redundant "script": "lowercase". This doesn't match calls we'd expect from Tableau, which would, unless I'm having a brain fart, be more like:

curl -X POST "http://127.0.0.1:8215/evaluate" -H  "accept: */*" -H  "Content-Type: application/json" -d "{\"script\":\"/lowercase\",\"data\":{\"_arg1\":[\"string\"]}}"

Probably best to go one way or the other? Or am I overthinking this?

blairj09 commented 3 years ago

I agree it would be nice to have a "true' Tableau request here. However, this curl command is autogenerated from the OpenAPI spec, and from what I can see, we couldn't modify it without making a drastic departure from standard OpenAPI behavior. Perhaps this is best handled with documentation?

toph-allen commented 3 years ago

Hmm, we should probably document it. I don't think it's that much of a big deal. What this is really about is the payload, right? The package handles routing requests to /evaluate to /script, but the data payload is handled the same in either case. Might be worth putting into an appendix or note in the docs at some point.

blairj09 commented 3 years ago

Yes, it's really about ensuring the payload is formatted correctly, with the curl command does :grin: I'll add a line to the documentation

blairj09 commented 3 years ago

Addressed here: https://github.com/rstudio/plumbertableau/pull/66/commits/a7e161b4a202fe6a4da64893f542ca3a0a288e91