Closed jeffkeller87 closed 6 years ago
Single underscore on the end? I believe it should be /__swagger__/
(two underscores on either side)
Unfortunately, that was just a typo here on GitHub. http://hostname:port/__swagger__/
also throws a 404 error.
To clarify, running the contents of plumb.R
interactively in RStudio Server on the AWS EC2 instance works. Here's the set up using the base example:
# myfile.R
#* @get /mean
normalMean <- function(samples=10){
data <- rnorm(samples)
mean(data)
}
#* @post /sum
addTwo <- function(a, b){
as.numeric(a) + as.numeric(b)
}
# plumb.R
library(plumber)
r <- plumb("myfile.R") # Where 'myfile.R' is the location of the file shown above
r$run(port = 8000, host = "0.0.0.0")
pm2 service (no swagger @ http://hostname:port/__swagger__/
)
pm2 start --interpreter="Rscript" plumb.R
Try r$run(port = 8000, host = "0.0.0.0", swagger=TRUE)
I had a similar issue with my service working in Rstudio but not in docker. I looked through the code and the default for swagger is swagger=interactive()
so the swagger endpoint is only created if you explicitly request it except when running from an interactive session
Regards Dave
Oh, great point @WaterworthD . You'll want to set swagger=TRUE
if you want the swagger interface to be available in your production environment. (The motivation here is that we don't want anyone to be surprised by the fact that they just leaked all their endpoints with documentation to their clients).
Thanks @WaterworthD, That did it! @trestletech are there plans to flesh out the swagger documentation (https://www.rplumber.io/docs/tips-tricks.html#swagger)?
I am hosting an API with
pm2
on AWS but the Swagger UI page (http://hostname:port/__swagger_/
) returns a 404 error. The Swagger UI shows up just fine when run locally withr$run()
. Is this a limitation ofpm2
hosting? Section 9.4 of theplumber
documentation is unfortunately incomplete so I didn't get far very in trying to figure this out :(