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
Improved documentation on specifying param type #755
Comments
I agree. When I first started using plumber I was confused why plumber did not do this conversion. Plumber will do the conversion in the case of dynamic path parameter. #* @get /test/<double:dbl>
function(double = 0) {
class(double)
} which you call using But not in the case of query parameters, query parameters will always be sent back to the API as character. The only reason to define the type in this case is for the OpenAPI document generation. #* @param double:dbl
#* @get /test
function(double = 0) {
class(double)
} I think I had this explained to me at some point. I'll take a look if I can find it. Maybe specify it in the documentation. |
This has come up again in a (inflamitory, imo 😉 ) blog post. They make a valid point that the param type annotations are not checked or enforced. library(plumber)
#* @param n:int
#* @get /types
function(n) {
n * 2L
} In browser make a request with any valid Assertions and coersions do not work well here becuase |
If you can point me where to most likely more a change here, I'd be happy to submit a PR. |
@JosiahParry Check out |
Yes, the important part here is:
The following endpoint will correctly do type conversion: #* @param n
#* @get /type/<n:int>
function(n) {
n * 2L
} How can we get this same behavior for non-dynamic routes? |
@JosiahParry I believe this PR has it done: #905 . I'll start carving away time to get this through. |
The plumber documentation on specifying input parameters is limited (see https://www.rplumber.io/articles/annotations.html#more-details-on-param).
Take the following example:
When using the swagger interface with
double
set to0.5
the response isThe only way to achieve the type specification is with an override from R
Which returns
My intention with this example is that, given the documentation, it is not clear how to specify input types.
I am using plumber v1.0.0
The text was updated successfully, but these errors were encountered: