Learn R Programming

vetiver (version 0.2.7)

api_spec: Update the OpenAPI specification using model metadata

Description

Update the OpenAPI specification using model metadata

Usage

api_spec(spec, vetiver_model, path, all_docs = TRUE)

glue_spec_summary(prototype, return_type)

# S3 method for default glue_spec_summary(prototype, return_type = NULL)

# S3 method for data.frame glue_spec_summary(prototype, return_type = "predictions")

# S3 method for array glue_spec_summary(prototype, return_type = "predictions")

Value

api_spec() returns the updated OpenAPI Specification object. This function uses glue_spec_summary() internally, which returns a glue

character string.

Arguments

spec

An OpenAPI Specification formatted list object

vetiver_model

A deployable vetiver_model() object

path

The endpoint path

all_docs

Should the interactive visual API documentation be created for all POST endpoints in the router pr? This defaults to TRUE, and assumes that all POST endpoints use the vetiver_model() input data prototype.

prototype

An input data prototype from a model

return_type

Character string to describe what endpoint returns, such as "predictions"

Examples

Run this code
if (FALSE) { # rlang::is_installed("plumber")
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)
}

Run the code above in your browser using DataLab