Allows to modify OpenAPI Specification autogenerated by plumber.
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.
a path to an OpenAPI Specification
The value returned will not be validated for OAS compatibility.
Returns
The Plumber router with the new OpenAPI Specification object or function.
Details
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.
Examples
## Not run:# Set the API Spec to a function to use the auto-generated OAS objectpr()%>% 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 objectpr()%>% pr_set_api_spec(my_custom_object)%>% pr_get("/plus/<a:int>/<b:int>",function(a, b){ a + b })%>% pr_run()## End(Not run)