.headers: Optional headers passed to httr functions. See add_headers documentation
path: (optional) filter by path from API specification
handle_response: (optional) A function with a single argument: httr response
auto_unbox: automatically unbox() all atomic vectors of length 1. It is usually safer to avoid this and instead use the unbox() function to unbox individual elements. An exception is that objects of class AsIs (i.e. wrapped in I()) are not automatically unboxed. This is a way to mark single values as length-1 arrays.
Returns
A list of functions.
Details
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.
Handling response
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.
Examples
## Not run:# create operation and schema functionsapi_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 erroroperations <- get_operations(api, handle_response = content_or_stop)# use .headers when operations must send additional headers when sendingoperations <- get_operations(api, .headers = c("api-key"= Sys.getenv("SOME_API_KEY")))## End(Not run)