api_spec | R Documentation |
Update the OpenAPI specification using model metadata
api_spec(spec, vetiver_model, path, all_docs = TRUE)
glue_spec_summary(prototype, return_type)
## Default S3 method:
glue_spec_summary(prototype, return_type = NULL)
## S3 method for class 'data.frame'
glue_spec_summary(prototype, return_type = "predictions")
## S3 method for class 'array'
glue_spec_summary(prototype, return_type = "predictions")
spec |
An OpenAPI Specification formatted list object |
vetiver_model |
A deployable |
path |
The endpoint path |
all_docs |
Should the interactive visual API documentation be created
for all POST endpoints in the router |
prototype |
An input data prototype from a model |
return_type |
Character string to describe what endpoint returns, such as "predictions" |
api_spec()
returns the updated OpenAPI Specification object. This
function uses glue_spec_summary()
internally, which returns a glue
character string.
library(plumber)
cars_lm <- lm(mpg ~ ., data = mtcars)
v <- vetiver_model(cars_lm, "cars_linear")
glue_spec_summary(v$prototype)
modify_spec <- function(spec) api_spec(spec, v, "/predict")
pr() %>% pr_set_api_spec(api = modify_spec)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.