get_operations | R Documentation |
Creates a list of functions from API operations definition. Names in a list are operationIDs from API.
get_operations(
api,
.headers = NULL,
path = NULL,
handle_response = identity,
auto_unbox = FALSE
)
api |
API object (see |
.headers |
Optional headers passed to httr functions. See
|
path |
(optional) filter by path from API specification |
handle_response |
(optional) A function with a single argument: httr response |
auto_unbox |
automatically |
All functions return a response object from httr package or a
value returned by handle_response
function if specified. When
path
is defined, only operations with the specified API path root are
created. Use .headers
parameters to send additional headers when
sending a request.
A list of functions.
If no response handler function is defined, operation functions return response object (httr package). See httr content documentation for extracting content from a request, and functions http_error and http_status how to handle http errors and error messages.
When using simple result_handlers
, operations will return the
content of response instead of httr response object (or handle error as
exception or warning in case of error).
To handle response automatically with custom function, define a function
with httr response object as argument and pass it as handle_response
argument to get_operations
function.
## Not run:
# create operation and schema functions
api_url <- "http://petstore.swagger.io/v2/swagger.json"
api <- get_api(api_url)
operations <- get_operations(api)
schemas <- get_schemas(api)
# get operations which return content or stop on error
operations <- get_operations(api, handle_response = content_or_stop)
# use .headers when operations must send additional headers when sending
operations <-
get_operations(api, .headers = c("api-key" = Sys.getenv("SOME_API_KEY")))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.