[R] fix to-list and to-json functionality (#20132)

* [r client] fix to-list and to-json functionality

* fix type of json string

* wip

* refactor pr

* regenerate samples

* update to-dataframe example to use non-superceded tidyverse functions

* fix typo
This commit is contained in:
Matt Pollock
2024-11-28 03:31:21 -05:00
committed by GitHub
parent 037cb12f34
commit e3e06af5f4
111 changed files with 3072 additions and 3381 deletions

View File

@@ -40,10 +40,35 @@ Bird <- R6::R6Class(
},
#' @description
#' To JSON String
#'
#' @return Bird in JSON format
#' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
toJSON = function() {
.Deprecated(new = "toSimpleType", msg = "Use the '$toSimpleType()' method instead since that is more clearly named. Use '$toJSONString()' to get a JSON string")
return(self$toSimpleType())
},
#' @description
#' Convert to a List
#'
#' Convert the R6 object to a list to work more easily with other tooling.
#'
#' @return Bird as a base R list.
#' @examples
#' # convert array of Bird (x) to a data frame
#' \dontrun{
#' library(purrr)
#' library(tibble)
#' df <- x |> map(\(y)y$toList()) |> map(as_tibble) |> list_rbind()
#' df
#' }
toList = function() {
return(self$toSimpleType())
},
#' @description
#' Convert Bird to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
BirdObject <- list()
if (!is.null(self$`size`)) {
BirdObject[["size"]] <-
@@ -53,7 +78,7 @@ Bird <- R6::R6Class(
BirdObject[["color"]] <-
self$`color`
}
BirdObject
return(BirdObject)
},
#' @description
@@ -74,29 +99,13 @@ Bird <- R6::R6Class(
#' @description
#' To JSON String
#'
#'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Bird in JSON format
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`size`)) {
sprintf(
'"size":
"%s"
',
self$`size`
)
},
if (!is.null(self$`color`)) {
sprintf(
'"color":
"%s"
',
self$`color`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
toJSONString = function(...) {
simple <- self$toSimpleType()
json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
},
#' @description

View File

@@ -304,7 +304,7 @@ BodyApi <- R6::R6Class(
if (!is.null(`body`)) {
local_var_body <- `body`$toJSONString()
} else {
body <- NULL
local_var_body <- NULL
}
local_var_url_path <- "/body/application/octetstream/binary"
@@ -586,7 +586,7 @@ BodyApi <- R6::R6Class(
if (!is.null(`pet`)) {
local_var_body <- `pet`$toJSONString()
} else {
body <- NULL
local_var_body <- NULL
}
local_var_url_path <- "/echo/body/allOf/Pet"
@@ -682,7 +682,7 @@ BodyApi <- R6::R6Class(
if (!is.null(`body`)) {
local_var_body <- `body`$toJSONString()
} else {
body <- NULL
local_var_body <- NULL
}
local_var_url_path <- "/echo/body/FreeFormObject/response_string"
@@ -778,7 +778,7 @@ BodyApi <- R6::R6Class(
if (!is.null(`pet`)) {
local_var_body <- `pet`$toJSONString()
} else {
body <- NULL
local_var_body <- NULL
}
local_var_url_path <- "/echo/body/Pet"
@@ -874,7 +874,7 @@ BodyApi <- R6::R6Class(
if (!is.null(`pet`)) {
local_var_body <- `pet`$toJSONString()
} else {
body <- NULL
local_var_body <- NULL
}
local_var_url_path <- "/echo/body/Pet/response_string"
@@ -970,7 +970,7 @@ BodyApi <- R6::R6Class(
if (!is.null(`body`)) {
local_var_body <- `body`$toJSONString()
} else {
body <- NULL
local_var_body <- NULL
}
local_var_url_path <- "/echo/body/string_enum"
@@ -1066,7 +1066,7 @@ BodyApi <- R6::R6Class(
if (!is.null(`tag`)) {
local_var_body <- `tag`$toJSONString()
} else {
body <- NULL
local_var_body <- NULL
}
local_var_url_path <- "/echo/body/Tag/response_string"

View File

@@ -40,10 +40,35 @@ Category <- R6::R6Class(
},
#' @description
#' To JSON String
#'
#' @return Category in JSON format
#' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
toJSON = function() {
.Deprecated(new = "toSimpleType", msg = "Use the '$toSimpleType()' method instead since that is more clearly named. Use '$toJSONString()' to get a JSON string")
return(self$toSimpleType())
},
#' @description
#' Convert to a List
#'
#' Convert the R6 object to a list to work more easily with other tooling.
#'
#' @return Category as a base R list.
#' @examples
#' # convert array of Category (x) to a data frame
#' \dontrun{
#' library(purrr)
#' library(tibble)
#' df <- x |> map(\(y)y$toList()) |> map(as_tibble) |> list_rbind()
#' df
#' }
toList = function() {
return(self$toSimpleType())
},
#' @description
#' Convert Category to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
CategoryObject <- list()
if (!is.null(self$`id`)) {
CategoryObject[["id"]] <-
@@ -53,7 +78,7 @@ Category <- R6::R6Class(
CategoryObject[["name"]] <-
self$`name`
}
CategoryObject
return(CategoryObject)
},
#' @description
@@ -74,29 +99,13 @@ Category <- R6::R6Class(
#' @description
#' To JSON String
#'
#'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Category in JSON format
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`name`)) {
sprintf(
'"name":
"%s"
',
self$`name`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
toJSONString = function(...) {
simple <- self$toSimpleType()
json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
},
#' @description

View File

@@ -67,10 +67,35 @@ DataQuery <- R6::R6Class(
},
#' @description
#' To JSON String
#'
#' @return DataQuery in JSON format
#' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
toJSON = function() {
.Deprecated(new = "toSimpleType", msg = "Use the '$toSimpleType()' method instead since that is more clearly named. Use '$toJSONString()' to get a JSON string")
return(self$toSimpleType())
},
#' @description
#' Convert to a List
#'
#' Convert the R6 object to a list to work more easily with other tooling.
#'
#' @return DataQuery as a base R list.
#' @examples
#' # convert array of DataQuery (x) to a data frame
#' \dontrun{
#' library(purrr)
#' library(tibble)
#' df <- x |> map(\(y)y$toList()) |> map(as_tibble) |> list_rbind()
#' df
#' }
toList = function() {
return(self$toSimpleType())
},
#' @description
#' Convert DataQuery to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
DataQueryObject <- list()
if (!is.null(self$`id`)) {
DataQueryObject[["id"]] <-
@@ -92,7 +117,7 @@ DataQuery <- R6::R6Class(
DataQueryObject[["date"]] <-
self$`date`
}
DataQueryObject
return(DataQueryObject)
},
#' @description
@@ -122,53 +147,13 @@ DataQuery <- R6::R6Class(
#' @description
#' To JSON String
#'
#'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return DataQuery in JSON format
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`outcomes`)) {
sprintf(
'"outcomes":
[%s]
',
paste(unlist(lapply(self$`outcomes`, function(x) paste0('"', x, '"'))), collapse = ",")
)
},
if (!is.null(self$`suffix`)) {
sprintf(
'"suffix":
"%s"
',
self$`suffix`
)
},
if (!is.null(self$`text`)) {
sprintf(
'"text":
"%s"
',
self$`text`
)
},
if (!is.null(self$`date`)) {
sprintf(
'"date":
"%s"
',
self$`date`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
toJSONString = function(...) {
simple <- self$toSimpleType()
json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
},
#' @description

View File

@@ -87,14 +87,39 @@ DefaultValue <- R6::R6Class(
},
#' @description
#' To JSON String
#'
#' @return DefaultValue in JSON format
#' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
toJSON = function() {
.Deprecated(new = "toSimpleType", msg = "Use the '$toSimpleType()' method instead since that is more clearly named. Use '$toJSONString()' to get a JSON string")
return(self$toSimpleType())
},
#' @description
#' Convert to a List
#'
#' Convert the R6 object to a list to work more easily with other tooling.
#'
#' @return DefaultValue as a base R list.
#' @examples
#' # convert array of DefaultValue (x) to a data frame
#' \dontrun{
#' library(purrr)
#' library(tibble)
#' df <- x |> map(\(y)y$toList()) |> map(as_tibble) |> list_rbind()
#' df
#' }
toList = function() {
return(self$toSimpleType())
},
#' @description
#' Convert DefaultValue to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
DefaultValueObject <- list()
if (!is.null(self$`array_string_enum_ref_default`)) {
DefaultValueObject[["array_string_enum_ref_default"]] <-
lapply(self$`array_string_enum_ref_default`, function(x) x$toJSON())
lapply(self$`array_string_enum_ref_default`, function(x) x$toSimpleType())
}
if (!is.null(self$`array_string_enum_default`)) {
DefaultValueObject[["array_string_enum_default"]] <-
@@ -124,7 +149,7 @@ DefaultValue <- R6::R6Class(
DefaultValueObject[["string_nullable"]] <-
self$`string_nullable`
}
DefaultValueObject
return(DefaultValueObject)
},
#' @description
@@ -163,77 +188,13 @@ DefaultValue <- R6::R6Class(
#' @description
#' To JSON String
#'
#'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return DefaultValue in JSON format
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`array_string_enum_ref_default`)) {
sprintf(
'"array_string_enum_ref_default":
[%s]
',
paste(sapply(self$`array_string_enum_ref_default`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox = TRUE, digits = NA)), collapse = ",")
)
},
if (!is.null(self$`array_string_enum_default`)) {
sprintf(
'"array_string_enum_default":
[%s]
',
paste(unlist(lapply(self$`array_string_enum_default`, function(x) paste0('"', x, '"'))), collapse = ",")
)
},
if (!is.null(self$`array_string_default`)) {
sprintf(
'"array_string_default":
[%s]
',
paste(unlist(lapply(self$`array_string_default`, function(x) paste0('"', x, '"'))), collapse = ",")
)
},
if (!is.null(self$`array_integer_default`)) {
sprintf(
'"array_integer_default":
[%s]
',
paste(unlist(lapply(self$`array_integer_default`, function(x) paste0('"', x, '"'))), collapse = ",")
)
},
if (!is.null(self$`array_string`)) {
sprintf(
'"array_string":
[%s]
',
paste(unlist(lapply(self$`array_string`, function(x) paste0('"', x, '"'))), collapse = ",")
)
},
if (!is.null(self$`array_string_nullable`)) {
sprintf(
'"array_string_nullable":
[%s]
',
paste(unlist(lapply(self$`array_string_nullable`, function(x) paste0('"', x, '"'))), collapse = ",")
)
},
if (!is.null(self$`array_string_extension_nullable`)) {
sprintf(
'"array_string_extension_nullable":
[%s]
',
paste(unlist(lapply(self$`array_string_extension_nullable`, function(x) paste0('"', x, '"'))), collapse = ",")
)
},
if (!is.null(self$`string_nullable`)) {
sprintf(
'"string_nullable":
"%s"
',
self$`string_nullable`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
toJSONString = function(...) {
simple <- self$toSimpleType()
json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
},
#' @description

View File

@@ -46,10 +46,35 @@ NumberPropertiesOnly <- R6::R6Class(
},
#' @description
#' To JSON String
#'
#' @return NumberPropertiesOnly in JSON format
#' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
toJSON = function() {
.Deprecated(new = "toSimpleType", msg = "Use the '$toSimpleType()' method instead since that is more clearly named. Use '$toJSONString()' to get a JSON string")
return(self$toSimpleType())
},
#' @description
#' Convert to a List
#'
#' Convert the R6 object to a list to work more easily with other tooling.
#'
#' @return NumberPropertiesOnly as a base R list.
#' @examples
#' # convert array of NumberPropertiesOnly (x) to a data frame
#' \dontrun{
#' library(purrr)
#' library(tibble)
#' df <- x |> map(\(y)y$toList()) |> map(as_tibble) |> list_rbind()
#' df
#' }
toList = function() {
return(self$toSimpleType())
},
#' @description
#' Convert NumberPropertiesOnly to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
NumberPropertiesOnlyObject <- list()
if (!is.null(self$`number`)) {
NumberPropertiesOnlyObject[["number"]] <-
@@ -63,7 +88,7 @@ NumberPropertiesOnly <- R6::R6Class(
NumberPropertiesOnlyObject[["double"]] <-
self$`double`
}
NumberPropertiesOnlyObject
return(NumberPropertiesOnlyObject)
},
#' @description
@@ -87,37 +112,13 @@ NumberPropertiesOnly <- R6::R6Class(
#' @description
#' To JSON String
#'
#'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return NumberPropertiesOnly in JSON format
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`number`)) {
sprintf(
'"number":
%d
',
self$`number`
)
},
if (!is.null(self$`float`)) {
sprintf(
'"float":
%d
',
self$`float`
)
},
if (!is.null(self$`double`)) {
sprintf(
'"double":
%d
',
self$`double`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
toJSONString = function(...) {
simple <- self$toSimpleType()
json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
},
#' @description

View File

@@ -75,10 +75,35 @@ Pet <- R6::R6Class(
},
#' @description
#' To JSON String
#'
#' @return Pet in JSON format
#' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
toJSON = function() {
.Deprecated(new = "toSimpleType", msg = "Use the '$toSimpleType()' method instead since that is more clearly named. Use '$toJSONString()' to get a JSON string")
return(self$toSimpleType())
},
#' @description
#' Convert to a List
#'
#' Convert the R6 object to a list to work more easily with other tooling.
#'
#' @return Pet as a base R list.
#' @examples
#' # convert array of Pet (x) to a data frame
#' \dontrun{
#' library(purrr)
#' library(tibble)
#' df <- x |> map(\(y)y$toList()) |> map(as_tibble) |> list_rbind()
#' df
#' }
toList = function() {
return(self$toSimpleType())
},
#' @description
#' Convert Pet to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
PetObject <- list()
if (!is.null(self$`id`)) {
PetObject[["id"]] <-
@@ -90,7 +115,7 @@ Pet <- R6::R6Class(
}
if (!is.null(self$`category`)) {
PetObject[["category"]] <-
self$`category`$toJSON()
self$`category`$toSimpleType()
}
if (!is.null(self$`photoUrls`)) {
PetObject[["photoUrls"]] <-
@@ -98,13 +123,13 @@ Pet <- R6::R6Class(
}
if (!is.null(self$`tags`)) {
PetObject[["tags"]] <-
lapply(self$`tags`, function(x) x$toJSON())
lapply(self$`tags`, function(x) x$toSimpleType())
}
if (!is.null(self$`status`)) {
PetObject[["status"]] <-
self$`status`
}
PetObject
return(PetObject)
},
#' @description
@@ -142,61 +167,13 @@ Pet <- R6::R6Class(
#' @description
#' To JSON String
#'
#'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Pet in JSON format
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`name`)) {
sprintf(
'"name":
"%s"
',
self$`name`
)
},
if (!is.null(self$`category`)) {
sprintf(
'"category":
%s
',
jsonlite::toJSON(self$`category`$toJSON(), auto_unbox = TRUE, digits = NA)
)
},
if (!is.null(self$`photoUrls`)) {
sprintf(
'"photoUrls":
[%s]
',
paste(unlist(lapply(self$`photoUrls`, function(x) paste0('"', x, '"'))), collapse = ",")
)
},
if (!is.null(self$`tags`)) {
sprintf(
'"tags":
[%s]
',
paste(sapply(self$`tags`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox = TRUE, digits = NA)), collapse = ",")
)
},
if (!is.null(self$`status`)) {
sprintf(
'"status":
"%s"
',
self$`status`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
toJSONString = function(...) {
simple <- self$toSimpleType()
json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
},
#' @description

View File

@@ -39,10 +39,35 @@ Query <- R6::R6Class(
},
#' @description
#' To JSON String
#'
#' @return Query in JSON format
#' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
toJSON = function() {
.Deprecated(new = "toSimpleType", msg = "Use the '$toSimpleType()' method instead since that is more clearly named. Use '$toJSONString()' to get a JSON string")
return(self$toSimpleType())
},
#' @description
#' Convert to a List
#'
#' Convert the R6 object to a list to work more easily with other tooling.
#'
#' @return Query as a base R list.
#' @examples
#' # convert array of Query (x) to a data frame
#' \dontrun{
#' library(purrr)
#' library(tibble)
#' df <- x |> map(\(y)y$toList()) |> map(as_tibble) |> list_rbind()
#' df
#' }
toList = function() {
return(self$toSimpleType())
},
#' @description
#' Convert Query to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
QueryObject <- list()
if (!is.null(self$`id`)) {
QueryObject[["id"]] <-
@@ -52,7 +77,7 @@ Query <- R6::R6Class(
QueryObject[["outcomes"]] <-
self$`outcomes`
}
QueryObject
return(QueryObject)
},
#' @description
@@ -73,29 +98,13 @@ Query <- R6::R6Class(
#' @description
#' To JSON String
#'
#'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Query in JSON format
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`outcomes`)) {
sprintf(
'"outcomes":
[%s]
',
paste(unlist(lapply(self$`outcomes`, function(x) paste0('"', x, '"'))), collapse = ",")
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
toJSONString = function(...) {
simple <- self$toSimpleType()
json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
},
#' @description

View File

@@ -37,11 +37,18 @@ StringEnumRef <- R6::R6Class(
},
#' @description
#' To JSON String
#'
#' @return StringEnumRef in JSON format
#' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
toJSON = function() {
jsonlite::toJSON(private$value, auto_unbox = TRUE)
.Deprecated(new = "toSimpleType", msg = "Use the '$toSimpleType()' method instead since that is more clearly named. Use '$toJSONString()' to get a JSON string")
return(self$toSimpleType())
},
#' @description
#' Convert StringEnumRef to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
return(private$value)
},
#' @description
@@ -59,10 +66,11 @@ StringEnumRef <- R6::R6Class(
#' @description
#' To JSON String
#'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return StringEnumRef in JSON format
toJSONString = function() {
as.character(jsonlite::toJSON(private$value,
auto_unbox = TRUE))
toJSONString = function(...) {
json <- jsonlite::toJSON(self$toSimpleType(), auto_unbox = TRUE, ...)
return(as.character(jsonlite::minify(json)))
},
#' @description

View File

@@ -40,10 +40,35 @@ Tag <- R6::R6Class(
},
#' @description
#' To JSON String
#'
#' @return Tag in JSON format
#' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
toJSON = function() {
.Deprecated(new = "toSimpleType", msg = "Use the '$toSimpleType()' method instead since that is more clearly named. Use '$toJSONString()' to get a JSON string")
return(self$toSimpleType())
},
#' @description
#' Convert to a List
#'
#' Convert the R6 object to a list to work more easily with other tooling.
#'
#' @return Tag as a base R list.
#' @examples
#' # convert array of Tag (x) to a data frame
#' \dontrun{
#' library(purrr)
#' library(tibble)
#' df <- x |> map(\(y)y$toList()) |> map(as_tibble) |> list_rbind()
#' df
#' }
toList = function() {
return(self$toSimpleType())
},
#' @description
#' Convert Tag to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
TagObject <- list()
if (!is.null(self$`id`)) {
TagObject[["id"]] <-
@@ -53,7 +78,7 @@ Tag <- R6::R6Class(
TagObject[["name"]] <-
self$`name`
}
TagObject
return(TagObject)
},
#' @description
@@ -74,29 +99,13 @@ Tag <- R6::R6Class(
#' @description
#' To JSON String
#'
#'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Tag in JSON format
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`name`)) {
sprintf(
'"name":
"%s"
',
self$`name`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
toJSONString = function(...) {
simple <- self$toSimpleType()
json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
},
#' @description

View File

@@ -31,16 +31,41 @@ TestFormObjectMultipartRequestMarker <- R6::R6Class(
},
#' @description
#' To JSON String
#'
#' @return TestFormObjectMultipartRequestMarker in JSON format
#' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
toJSON = function() {
.Deprecated(new = "toSimpleType", msg = "Use the '$toSimpleType()' method instead since that is more clearly named. Use '$toJSONString()' to get a JSON string")
return(self$toSimpleType())
},
#' @description
#' Convert to a List
#'
#' Convert the R6 object to a list to work more easily with other tooling.
#'
#' @return TestFormObjectMultipartRequestMarker as a base R list.
#' @examples
#' # convert array of TestFormObjectMultipartRequestMarker (x) to a data frame
#' \dontrun{
#' library(purrr)
#' library(tibble)
#' df <- x |> map(\(y)y$toList()) |> map(as_tibble) |> list_rbind()
#' df
#' }
toList = function() {
return(self$toSimpleType())
},
#' @description
#' Convert TestFormObjectMultipartRequestMarker to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
TestFormObjectMultipartRequestMarkerObject <- list()
if (!is.null(self$`name`)) {
TestFormObjectMultipartRequestMarkerObject[["name"]] <-
self$`name`
}
TestFormObjectMultipartRequestMarkerObject
return(TestFormObjectMultipartRequestMarkerObject)
},
#' @description
@@ -58,21 +83,13 @@ TestFormObjectMultipartRequestMarker <- R6::R6Class(
#' @description
#' To JSON String
#'
#'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return TestFormObjectMultipartRequestMarker in JSON format
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`name`)) {
sprintf(
'"name":
"%s"
',
self$`name`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
toJSONString = function(...) {
simple <- self$toSimpleType()
json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
},
#' @description

View File

@@ -58,10 +58,35 @@ TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter <- R6::R6Clas
},
#' @description
#' To JSON String
#'
#' @return TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter in JSON format
#' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
toJSON = function() {
.Deprecated(new = "toSimpleType", msg = "Use the '$toSimpleType()' method instead since that is more clearly named. Use '$toJSONString()' to get a JSON string")
return(self$toSimpleType())
},
#' @description
#' Convert to a List
#'
#' Convert the R6 object to a list to work more easily with other tooling.
#'
#' @return TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter as a base R list.
#' @examples
#' # convert array of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter (x) to a data frame
#' \dontrun{
#' library(purrr)
#' library(tibble)
#' df <- x |> map(\(y)y$toList()) |> map(as_tibble) |> list_rbind()
#' df
#' }
toList = function() {
return(self$toSimpleType())
},
#' @description
#' Convert TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject <- list()
if (!is.null(self$`size`)) {
TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject[["size"]] <-
@@ -79,7 +104,7 @@ TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter <- R6::R6Clas
TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject[["name"]] <-
self$`name`
}
TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject
return(TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject)
},
#' @description
@@ -106,45 +131,13 @@ TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter <- R6::R6Clas
#' @description
#' To JSON String
#'
#'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter in JSON format
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`size`)) {
sprintf(
'"size":
"%s"
',
self$`size`
)
},
if (!is.null(self$`color`)) {
sprintf(
'"color":
"%s"
',
self$`color`
)
},
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`name`)) {
sprintf(
'"name":
"%s"
',
self$`name`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
toJSONString = function(...) {
simple <- self$toSimpleType()
json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
},
#' @description

View File

@@ -30,16 +30,41 @@ TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter <- R6::R6Class(
},
#' @description
#' To JSON String
#'
#' @return TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter in JSON format
#' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
toJSON = function() {
.Deprecated(new = "toSimpleType", msg = "Use the '$toSimpleType()' method instead since that is more clearly named. Use '$toJSONString()' to get a JSON string")
return(self$toSimpleType())
},
#' @description
#' Convert to a List
#'
#' Convert the R6 object to a list to work more easily with other tooling.
#'
#' @return TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter as a base R list.
#' @examples
#' # convert array of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter (x) to a data frame
#' \dontrun{
#' library(purrr)
#' library(tibble)
#' df <- x |> map(\(y)y$toList()) |> map(as_tibble) |> list_rbind()
#' df
#' }
toList = function() {
return(self$toSimpleType())
},
#' @description
#' Convert TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterObject <- list()
if (!is.null(self$`values`)) {
TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterObject[["values"]] <-
self$`values`
}
TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterObject
return(TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterObject)
},
#' @description
@@ -57,21 +82,13 @@ TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter <- R6::R6Class(
#' @description
#' To JSON String
#'
#'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter in JSON format
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`values`)) {
sprintf(
'"values":
[%s]
',
paste(unlist(lapply(self$`values`, function(x) paste0('"', x, '"'))), collapse = ",")
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
toJSONString = function(...) {
simple <- self$toSimpleType()
json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
},
#' @description