Swagger UI does not show up when Plumber API is deployed as a service

I have developed a REST API using plumber. When I start the REST API from RStudio using the following command:

plumber::plumb("/PATH/TO/rest-api/scrnaseq-server.R")$run(port = 9000, host = "0.0.0.0")

... then I am able to view the Swagger UI at:
http://:9000/swagger/

However when I deploy the REST API as a service, I am unable to view the Swagger UI at the same URL.

My /etc/systemd/system/plumber-api.service looks like the following:

[Unit]
Description=Plumber API
# After=postgresql
# (or mariadb, mysql, etc if you use a DB with Plumber, otherwise leave this commented)

[Service]
ExecStart=/usr/bin/Rscript -e "api <- plumber::plumb('/PATH/TO/rest-api/scrnaseq-server.R'); api$run(port=9000, host='0.0.0.0')"
Restart=on-abnormal
WorkingDirectory=/PATH/TO/rest-api/

[Install]
WantedBy=multi-user.target

Please add swagger = TRUE to the $run method.

Ex:

plumber::plumb("/PATH/TO/rest-api/scrnaseq-server.R")$run(port = 9000, host = "0.0.0.0", swagger = TRUE)

I believe we will be changing the default behavior to always enable swagger in the future. (Not when it is interactive.)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.