forked from loafle/openapi-generator-original
update samples
This commit is contained in:
@@ -270,7 +270,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
|
||||
|
||||
@@ -45,6 +45,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)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -176,7 +176,7 @@ AuthApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
@@ -266,7 +266,7 @@ AuthApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ BodyApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "data.frame", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "data.frame", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
@@ -474,7 +474,7 @@ BodyApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
@@ -568,7 +568,7 @@ BodyApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
@@ -658,7 +658,7 @@ BodyApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
@@ -753,7 +753,7 @@ BodyApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
@@ -848,7 +848,7 @@ BodyApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
@@ -943,7 +943,7 @@ BodyApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "Pet", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
@@ -1038,7 +1038,7 @@ BodyApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
@@ -1133,7 +1133,7 @@ BodyApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ FormApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
@@ -305,7 +305,7 @@ FormApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ HeaderApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ PathApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ QueryApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
@@ -473,7 +473,7 @@ QueryApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
@@ -574,7 +574,7 @@ QueryApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
@@ -665,7 +665,7 @@ QueryApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
@@ -756,7 +756,7 @@ QueryApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
@@ -847,7 +847,7 @@ QueryApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
@@ -938,7 +938,7 @@ QueryApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
@@ -1029,7 +1029,7 @@ QueryApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user