Skip to content

Commit 5b321d1

Browse files
committed
unpack dataframes within a list
1 parent a40dc56 commit 5b321d1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

modules/openapi-generator/src/main/resources/r/api_client.mustache

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ ApiClient <- R6::R6Class(
351351
return_obj <- NULL
352352
primitive_types <- c("character", "numeric", "integer", "logical", "complex")
353353
354+
return_type <- gsub(pattern = "^(set|list)\\[",
355+
replacement = "array\\[",
356+
x = return_type)
357+
354358
# To handle the "map" type
355359
if (startsWith(return_type, "map(")) {
356360
inner_return_type <- regmatches(return_type,
@@ -371,6 +375,9 @@ ApiClient <- R6::R6Class(
371375
}
372376
}
373377
} else {
378+
if (is.list(obj) && length(obj) == 1 && is.data.frame(obj[[1]])) {
379+
obj <- obj[[1]]
380+
}
374381
if (!is.null(nrow(obj))) {
375382
return_obj <- vector("list", length = nrow(obj))
376383
if (nrow(obj) > 0) {

0 commit comments

Comments
 (0)