@Blair09M - the previous topic (link) was closed and I just briefly wanted to follow-up on the dynamic routes and parameters logic. I tried your solution but I'm getting a weird error:
Starting server to listen on port 5644
Error in if (type == "bool" || type == "logical") { :
missing value where TRUE/FALSE needed
I tried exactly your solution from before and that is the full code:
#* Check API readiness
#* @get /healthcheck
function(res) {
res$status <- 200
return("Give some data, I'm ready to predict")
}
#* Make a prediction for selected country
#* @param country Select model country code
#* @param check_it Should it be checked?
#* @post /<country>/predict
#* @serializer unboxedJSON
function(req, res, country, check_it = FALSE) {
if (check_it == FALSE){
checked <- "no"
} else {
checked <- "yes"
}
if (country == "au"){
country <- "selected_au"
} else if (country == "nl"){
country <- "selected_nl"
} else {
stop("Invalid country parameters. Currently supported countries are: au and nl")
}
res$body <- list(
checked,
country
)
}
Now, based on some online resources if I change the host to:
#* @post /<country::string>/predict
the API is able to start and swagger automatically generates such URL:
curl -X POST "http://127.0.0.1:5644/{country}/predict?check_it=TRUE&country=nl" -H "accept: application/json"
which I find confusing because I though that country wouldn't need to be specified after '?' similarly to 'check_it' if it's part of the host. The API returns 404. What's your view on that?