
Render one wrapper as R source text
render_operation.RdRender an operation record with explicit helper, request, hook, and documentation settings.
Details
This low-level function returns text only; it does not validate an entire project, run roxygen, write files, or check ownership. Prefer generate_client() for normal maintenance. The default helper takes method, path, path_params, query, and body. JSON array values should remain R lists to preserve one-element arrays. Set operation$guard_literals <- TRUE to wrap literal defaults as base::evalq(..., envir = base::baseenv()); generate_client() sets it only when the client's functions or imports shadow a base data constructor such as c or list. It defaults to FALSE, which matches generation for most clients.
Examples
schema <- system.file('catalogue/schema.json', package = 'specmill')
op <- read_operations(schema)$operations$get_item
cat(render_operation(op, list(helper = 'api_request')))
#> # Generated with specmill; do not edit by hand.
#> get_item <- function(item_id, language = NULL) {
#> if (base::is.null(item_id)) base::stop("Required input: item_id")
#> .api_validation$parameter_values(base::list("item_id" = item_id, "language" = language), list(item_id = list(type = "string"), language = list(type = "string", enum = list("en", "fr"))), .api_validation$body_value, c(item_id = "path", language = "query"))
#> params <- base::list("item_id" = item_id, "language" = language)
#> if (base::is.character(params[["language"]]) && base::any(!base::nzchar(params[["language"]]))) base::stop("Empty query parameter: language")
#> result <- api_request(method = "GET", path = "/items/{item_id}", path_params = base::list("item_id" = params[["item_id"]]), query = base::list("language" = params[["language"]]), body = NULL, server = list(diagnostic = "Relative server URL requires a recorded origin or explicit base URL override"))
#> result
#> }