When set, it will be called with a character string corresponding to the API UI url. This allows RStudio to open swagger UI when a Plumber router pr_run() method is executed using default plumber.ui.callback option.

pr_set_api_spec(pr, api)

Arguments

pr

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

api

This can be

  • an OpenAPI Specification formatted list object

  • a function that accepts the OpenAPI Specification autogenerated by plumber and returns a OpenAPI Specification formatted list object.

The value returned will not be validated for OAS compatibility.

Value

The Plumber router with the new OpenAPI Specification object or function.

Examples

if (FALSE) { # Set the API Spec to a function to use the auto-generated OAS object pr() %>% pr_set_api_spec(function(spec) { spec$info$title <- Sys.time() spec }) %>% pr_get("/plus/<a:int>/<b:int>", function(a, b) { a + b }) %>% pr_run() # Set the API Spec using an object pr() %>% pr_set_api_spec(my_custom_object) %>% pr_get("/plus/<a:int>/<b:int>", function(a, b) { a + b }) %>% pr_run() }