plumber
plumber copied to clipboard
"boolean" param not defaulting consistently
The selector pulldowns for :boolean
class will default to true
when true but --
(not false
) when false. Can this be fixed? My guess is that the FALSE
is being interpreted as "do not display the default value" instead of "display this of the candidate values".
Steps to demonstrate/reproduce
#* @get /quux
#* @param regex:boolean Whether the pattern is regex (true) or glob (false).
function(regex = FALSE) {
regex
}
#* @get /quux
#* @param regex:boolean Whether the pattern is regex (true) or glob (false).
function(regex = TRUE) {
regex
}
System details
Output of sessioninfo::session_info()()
:
sessioninfo::session_info()
# - Session info --------------------------------------------------------------
# hash: parrot, open hands: dark skin tone, man firefighter: medium skin tone
# setting value
# version R version 4.1.2 (2021-11-01)
# os Windows 10 x64 (build 22000)
# system x86_64, mingw32
# ui RTerm
# language (EN)
# collate English_United States.1252
# ctype English_United States.1252
# tz America/New_York
# date 2022-06-28
# pandoc 2.17.1.1 @ C:/Users/r2/AppData/Local/Pandoc/ (via rmarkdown)
# - Packages -------------------------------------------------------------------
# package * version date (UTC) lib source
# cli 3.3.0 2022-04-25 [1] CRAN (R 4.1.3)
# digest 0.6.28 2021-09-23 [1] CRAN (R 4.1.2)
# evaluate 0.14 2019-05-28 [1] CRAN (R 4.1.2)
# fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.1.2)
# htmltools 0.5.2 2021-08-25 [1] CRAN (R 4.1.2)
# jsonlite 1.8.0 2022-02-22 [1] CRAN (R 4.1.3)
# knitr 1.36 2021-09-29 [1] CRAN (R 4.1.2)
# later 1.3.0 2021-08-18 [1] CRAN (R 4.1.2)
# lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.1.2)
# magrittr 2.0.2 2022-01-26 [1] CRAN (R 4.1.2)
# plumber * 1.1.0 2021-03-24 [1] CRAN (R 4.1.2)
# promises 1.2.0.1 2021-02-11 [1] CRAN (R 4.1.2)
# r2 * 0.9.14 2022-05-16 [1] local
# R6 2.5.1 2021-08-19 [1] CRAN (R 4.1.2)
# Rcpp 1.0.7 2021-07-07 [1] CRAN (R 4.1.2)
# rlang 1.0.2 2022-03-04 [1] CRAN (R 4.1.3)
# rmarkdown 2.11 2021-09-14 [1] CRAN (R 4.1.2)
# sessioninfo 1.2.1 2021-11-02 [1] CRAN (R 4.1.2)
# stringi 1.7.5 2021-10-04 [1] CRAN (R 4.1.1)
# swagger 3.33.1 2020-10-02 [1] CRAN (R 4.1.2)
# webutils 1.1 2020-04-28 [1] CRAN (R 4.1.2)
# xfun 0.29 2021-12-14 [1] CRAN (R 4.1.2)
# [1] C:/Users/r2/R/win-library/4.1
# [2] C:/R/R-4.1.2/library
# ------------------------------------------------------------------------------
The openapi.json file seems to render correctly. When trying to load the reprex openapi.json (below) into https://editor.swagger.io/ the default false
is set properly. Could it be time for {swagger}
to update its swagger version; currently using 3.33.1, most recent version at the time of writing is 4.13.2?
{"servers":[{"url":""}],"openapi":"3.0.3","info":{"description":"API Description","title":"API Title","version":"1.0.0"},"paths":{"/quux":{"get":{"description":"","responses":{"200":{"description":"OK"},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"type":"string"}}}},"default":{"description":"Default response."}},"parameters":[{"name":"regex","description":"Whether the pattern is regex (true) or glob (false).","in":"query","required":false,"schema":{"type":"boolean","default":false}}]}}}}
I'm seeing a different but similar issue at the moment - I'm seeing that true
is displayed by default, but that an empty string is sent unless I first choose false
and then true
in the dropdown.
(This using the tip of main
in this repo)
It seems to work with an update swagger version.
See https://github.com/rstudio/swagger/pull/29. This would be a swagger side issue.