Allows to modify OpenAPI Specification autogenerated by plumber
.
pr_set_api_spec(pr, api)
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
The value returned will not be validated for OAS compatibility. |
The Plumber router with the new OpenAPI Specification object or function.
Note, the returned value will be sent through serializer_unboxed_json()
which will turn all length 1 vectors into atomic values.
To force a vector to serialize to an array of size 1, be sure to call as.list()
on your value. list()
objects are always serialized to an array value.
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() }