api_spec: Update the OpenAPI specification using model metadata

Description Usage Arguments Value Examples

Description

Update the OpenAPI specification using model metadata

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
api_spec(spec, vetiver_model, path, all_docs = TRUE)

glue_spec_summary(ptype, return_type)

## Default S3 method:
glue_spec_summary(ptype, return_type = NULL)

## S3 method for class 'data.frame'
glue_spec_summary(ptype, return_type = "predictions")

## S3 method for class 'array'
glue_spec_summary(ptype, return_type = "predictions")

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$ptype input data prototype.

ptype

An input data prototype from a model

return_type

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

Value

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

Examples

1
2
3
4
5
6
7
8
library(plumber)
cars_lm <- lm(mpg ~ ., data = mtcars)
v <- vetiver_model(cars_lm, "cars_linear")

glue_spec_summary(v$ptype)

modify_spec <- function(spec) api_spec(spec, v, "/predict")
pr() %>% pr_set_api_spec(api = modify_spec)

tidymodels/vetiver documentation built on Jan. 14, 2022, 7:32 p.m.