forked from loafle/openapi-generator-original
[R][Client] Fix api response, JSON for maps and let httr2 api client handle empty response bodies (#18049)
* changed files from rebuilding project and updating samples * change default value of from_encoding to empty string - from_encoding = NULL is invalid and produces an error, as only strings are allowed, see https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/iconv - defaulting to an empty string fixes this issue * fix map being surrounded by quotes in json * allow httr2 client to deal with empty response body * changed files from rebuilding project and updating samples * added PetMap schema for test of correct map serialization in toJSONString and regenerated samples
This commit is contained in:
@@ -56,7 +56,7 @@ ApiResponse <- R6::R6Class(
|
||||
#' @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") {
|
||||
response_as_text = function(from_encoding = "", 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.")
|
||||
|
||||
Reference in New Issue
Block a user