diff --git a/modules/openapi-generator/src/main/resources/r/api_client.mustache b/modules/openapi-generator/src/main/resources/r/api_client.mustache index eb70bad3447..22fd994ab64 100644 --- a/modules/openapi-generator/src/main/resources/r/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/r/api_client.mustache @@ -151,10 +151,12 @@ ApiClient <- R6::R6Class( } } } else { - returnObj <- vector("list", length = nrow(obj)) - if (nrow(obj) > 0) { - for (row in 1:nrow(obj)) { - returnObj[[row]] <- self$deserializeObj(obj[row, , drop = FALSE], innerReturnType, pkgEnv) + if(!is.null(nrow(obj))){ + returnObj <- vector("list", length = nrow(obj)) + if (nrow(obj) > 0) { + for (row in 1:nrow(obj)) { + returnObj[[row]] <- self$deserializeObj(obj[row, , drop = FALSE], innerReturnType, pkgEnv) + } } } } diff --git a/samples/client/petstore/R/R/api_client.R b/samples/client/petstore/R/R/api_client.R index 45396b84391..f6b8544aacd 100644 --- a/samples/client/petstore/R/R/api_client.R +++ b/samples/client/petstore/R/R/api_client.R @@ -149,10 +149,12 @@ ApiClient <- R6::R6Class( } } } else { - returnObj <- vector("list", length = nrow(obj)) - if (nrow(obj) > 0) { - for (row in 1:nrow(obj)) { - returnObj[[row]] <- self$deserializeObj(obj[row, , drop = FALSE], innerReturnType, pkgEnv) + if(!is.null(nrow(obj))){ + returnObj <- vector("list", length = nrow(obj)) + if (nrow(obj) > 0) { + for (row in 1:nrow(obj)) { + returnObj[[row]] <- self$deserializeObj(obj[row, , drop = FALSE], innerReturnType, pkgEnv) + } } } }