ui should be either a logical or a character value matching a registered ui. When TRUE or a function, multiple handles will be added to plumber object. OpenAPI json file will be served on paths /openapi.json and /swagger.json. Swagger UI will be served on paths /__swagger__/index.html and /__swagger__/. When using a function, it will receive the Plumber router as the first parameter and current OpenAPI Specification as the second. This function should return a list containing OpenAPI Specification. See http://spec.openapis.org/oas/v3.0.3

pr_set_ui(pr, ui = getOption("plumber.ui", TRUE), ...)

Arguments

pr

A Plumber API. Note: The supplied Plumber API object will also be updated in place as well as returned by the function.

ui

a character value or a logical value. If using options_plumber(), the value must be set before initializing your Plumber router.

...

Other params to be passed to ui functions.

Value

The Plumber router with the new UI settings.

Examples

if (FALSE) { ## View API using Swagger UI # Official Website: https://swagger.io/tools/swagger-ui/ # install.packages("swagger") if (require(swagger)) { pr() %>% pr_set_ui("swagger") %>% pr_get("/plus/<a:int>/<b:int>", function(a, b) { a + b }) %>% pr_run() } ## View API using Redoc # Official Website: https://github.com/Redocly/redoc # remotes::install_github("https://github.com/meztez/redoc/") if (require(redoc)) { pr() %>% pr_set_ui("redoc") %>% pr_get("/plus/<a:int>/<b:int>", function(a, b) { a + b }) %>% pr_run() } ## View API using RapiDoc # Official Website: https://github.com/mrin9/RapiDoc # remotes::install_github("https://github.com/meztez/rapidoc/") if (require(rapidoc)) { pr() %>% pr_set_ui("rapidoc") %>% pr_get("/plus/<a:int>/<b:int>", function(a, b) { a + b }) %>% pr_run() } ## Disable the OpenAPI Spec UI pr() %>% pr_set_ui(FALSE) %>% pr_get("/plus/<a:int>/<b:int>", function(a, b) { a + b }) %>% pr_run() }