Skip to contents

HTTP API package generator

Usage

generate_pkg(
  pkg_path,
  template_path = NULL,
  http_lib = "crul",
  base_url = NULL
)

Arguments

pkg_path

(character) Path to the new package, where last part will be the package name

template_path

(character) path to your yaml template file. by default, we use a demo template yaml file

http_lib

(character) one of crul (default) or httr

base_url

(character) Base URL. If NULL, defaults to baseUrl or is formed from schemes, host, basePath as specified in the template file.

Examples

if (FALSE) { # \dontrun{
generate_pkg(pkg_path = "mypkg")

# from a Swagger spec
url <- "https://raw.githubusercontent.com/ropenscilabs/apispecs/master/swagger/crossref.yml"
# x <- paste0(readLines(url), collapse = "\n")
# yaml::yaml.load(string = x)
download.file(url, "crossref.yml")
my_dir <- file.path(tempdir(), "apples")
generate_pkg(pkg_path = my_dir, template_path = "crossref.yml")
} # }