support binary response for R api client (#17626)

* support binary response for R api

* rework

* autogenerated samples
This commit is contained in:
Matt Pollock
2024-01-23 03:28:37 -05:00
committed by GitHub
parent b2f622cd98
commit 1e17712f25
22 changed files with 119 additions and 51 deletions

View File

@@ -38,6 +38,23 @@ ApiResponse <- R6::R6Class(
self$status_code <- status_code
self$status_code_desc <- status_code_desc
self$headers <- headers
},
#' Return the response as text
#'
#' @description
#' The response is stored as a raw vector. Use this to access the response after
#' converting it to text. If the response is not coercible to text NA is returned.
#'
#' @param from_encoding The encoding of the raw response.
#' @param to_encoding The target encoding of the return value.
#' @export
response_as_text = function(from_encoding = NULL, to_encoding = "UTF-8") {
text_response <- iconv(readBin(self$response, character()), from = from_encoding, to = to_encoding)
if (is.na(text_response)) {
warning("The response is binary and will not be converted to text.")
}
return(text_response)
}
)
)

View File

@@ -637,7 +637,7 @@
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "{{returnType}}", loadNamespace("{{packageName}}")),
self$api_client$deserialize(local_var_resp$response_as_text(), "{{returnType}}", loadNamespace("{{packageName}}")),
error = function(e) {
{{#useDefaultExceptionHandling}}
stop("Failed to deserialize response")

View File

@@ -318,7 +318,7 @@ ApiClient <- R6::R6Class(
api_response <- ApiResponse$new()
api_response$status_code <- httr::status_code(httr_response)
api_response$status_code_desc <- httr::http_status(httr_response)$reason
api_response$response <- httr::content(httr_response, "text", encoding = "UTF-8")
api_response$response <- httr::content(httr_response, "raw")
api_response$headers <- httr::headers(httr_response)
api_response

View File

@@ -323,7 +323,7 @@ ApiClient <- R6::R6Class(
api_response <- ApiResponse$new()
api_response$status_code <- resp %>% resp_status()
api_response$status_code_desc <- resp %>% resp_status_desc()
api_response$response <- resp %>% resp_body_string()
api_response$response <- resp %>% resp_body_raw()
api_response$headers <- resp %>% resp_headers()
api_response

View File

@@ -312,7 +312,7 @@ ApiClient <- R6::R6Class(
api_response <- ApiResponse$new()
api_response$status_code <- resp %>% resp_status()
api_response$status_code_desc <- resp %>% resp_status_desc()
api_response$response <- resp %>% resp_body_string()
api_response$response <- resp %>% resp_body_raw()
api_response$headers <- resp %>% resp_headers()
api_response

View File

@@ -44,6 +44,23 @@ ApiResponse <- R6::R6Class(
self$status_code <- status_code
self$status_code_desc <- status_code_desc
self$headers <- headers
},
#' Return the response as text
#'
#' @description
#' The response is stored as a raw vector. Use this to access the response after
#' converting it to text. If the response is not coercible to text NA is returned.
#'
#' @param from_encoding The encoding of the raw response.
#' @param to_encoding The target encoding of the return value.
#' @export
response_as_text = function(from_encoding = NULL, to_encoding = "UTF-8") {
text_response <- iconv(readBin(self$response, character()), from = from_encoding, to = to_encoding)
if (is.na(text_response)) {
warning("The response is binary and will not be converted to text.")
}
return(text_response)
}
)
)

View File

@@ -365,7 +365,7 @@ FakeApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -485,7 +485,7 @@ FakeApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "User", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "User", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",

View File

@@ -746,7 +746,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -984,7 +984,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "array[Pet]", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "array[Pet]", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1100,7 +1100,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "array[Pet]", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "array[Pet]", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1221,7 +1221,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1353,7 +1353,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1483,7 +1483,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1605,7 +1605,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1843,7 +1843,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "ModelApiResponse", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "ModelApiResponse", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",

View File

@@ -438,7 +438,7 @@ StoreApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "map(integer)", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "map(integer)", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -567,7 +567,7 @@ StoreApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Order", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Order", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -686,7 +686,7 @@ StoreApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Order", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Order", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",

View File

@@ -970,7 +970,7 @@ UserApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "User", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "User", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1103,7 +1103,7 @@ UserApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",

View File

@@ -312,7 +312,7 @@ ApiClient <- R6::R6Class(
api_response <- ApiResponse$new()
api_response$status_code <- resp %>% resp_status()
api_response$status_code_desc <- resp %>% resp_status_desc()
api_response$response <- resp %>% resp_body_string()
api_response$response <- resp %>% resp_body_raw()
api_response$headers <- resp %>% resp_headers()
api_response

View File

@@ -44,6 +44,23 @@ ApiResponse <- R6::R6Class(
self$status_code <- status_code
self$status_code_desc <- status_code_desc
self$headers <- headers
},
#' Return the response as text
#'
#' @description
#' The response is stored as a raw vector. Use this to access the response after
#' converting it to text. If the response is not coercible to text NA is returned.
#'
#' @param from_encoding The encoding of the raw response.
#' @param to_encoding The target encoding of the return value.
#' @export
response_as_text = function(from_encoding = NULL, to_encoding = "UTF-8") {
text_response <- iconv(readBin(self$response, character()), from = from_encoding, to = to_encoding)
if (is.na(text_response)) {
warning("The response is binary and will not be converted to text.")
}
return(text_response)
}
)
)

View File

@@ -365,7 +365,7 @@ FakeApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -485,7 +485,7 @@ FakeApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "User", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "User", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",

View File

@@ -746,7 +746,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -984,7 +984,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "array[Pet]", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "array[Pet]", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1100,7 +1100,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "array[Pet]", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "array[Pet]", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1221,7 +1221,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1353,7 +1353,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1483,7 +1483,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1605,7 +1605,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1843,7 +1843,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "ModelApiResponse", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "ModelApiResponse", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",

View File

@@ -438,7 +438,7 @@ StoreApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "map(integer)", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "map(integer)", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -567,7 +567,7 @@ StoreApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Order", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Order", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -686,7 +686,7 @@ StoreApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Order", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Order", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",

View File

@@ -970,7 +970,7 @@ UserApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "User", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "User", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1103,7 +1103,7 @@ UserApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",

View File

@@ -299,7 +299,7 @@ ApiClient <- R6::R6Class(
api_response <- ApiResponse$new()
api_response$status_code <- httr::status_code(httr_response)
api_response$status_code_desc <- httr::http_status(httr_response)$reason
api_response$response <- httr::content(httr_response, "text", encoding = "UTF-8")
api_response$response <- httr::content(httr_response, "raw")
api_response$headers <- httr::headers(httr_response)
api_response

View File

@@ -44,6 +44,23 @@ ApiResponse <- R6::R6Class(
self$status_code <- status_code
self$status_code_desc <- status_code_desc
self$headers <- headers
},
#' Return the response as text
#'
#' @description
#' The response is stored as a raw vector. Use this to access the response after
#' converting it to text. If the response is not coercible to text NA is returned.
#'
#' @param from_encoding The encoding of the raw response.
#' @param to_encoding The target encoding of the return value.
#' @export
response_as_text = function(from_encoding = NULL, to_encoding = "UTF-8") {
text_response <- iconv(readBin(self$response, character()), from = from_encoding, to = to_encoding)
if (is.na(text_response)) {
warning("The response is binary and will not be converted to text.")
}
return(text_response)
}
)
)

View File

@@ -365,7 +365,7 @@ FakeApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -485,7 +485,7 @@ FakeApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "User", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "User", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",

View File

@@ -746,7 +746,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -984,7 +984,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "array[Pet]", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "array[Pet]", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1100,7 +1100,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "array[Pet]", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "array[Pet]", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1221,7 +1221,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1353,7 +1353,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1483,7 +1483,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1605,7 +1605,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1843,7 +1843,7 @@ PetApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "ModelApiResponse", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "ModelApiResponse", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",

View File

@@ -438,7 +438,7 @@ StoreApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "map(integer)", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "map(integer)", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -567,7 +567,7 @@ StoreApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Order", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Order", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -686,7 +686,7 @@ StoreApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "Order", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "Order", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",

View File

@@ -970,7 +970,7 @@ UserApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "User", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "User", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
@@ -1103,7 +1103,7 @@ UserApi <- R6::R6Class(
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("petstore")),
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",