[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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
111 changed files with 3072 additions and 3381 deletions

View File

@ -456,7 +456,7 @@
local_var_body <- `{{paramName}}`$toJSONString() local_var_body <- `{{paramName}}`$toJSONString()
{{/isArray}} {{/isArray}}
} else { } else {
body <- NULL local_var_body <- NULL
} }
{{/bodyParams}} {{/bodyParams}}

View File

@ -86,27 +86,32 @@
}, },
#' @description #' @description
#' Serialize {{{classname}}} to JSON string. #' 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 {{{classname}}} to a base R type
#' #'
#' @return JSON string representation of the {{{classname}}}. #' @return A base R type, e.g. a list or numeric/character array.
toJSONString = function() { toSimpleType = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
as.character(jsonlite::minify((self$actual_instance$toJSONString()))) return(self$actual_instance$toSimpleType())
} else { } else {
NULL NULL
} }
}, },
#' @description #' @description
#' Serialize {{{classname}}} to JSON. #' Serialize {{{classname}}} to JSON string.
#' #'
#' @return JSON representation of the {{{classname}}}. #' @param ... Parameters passed to `jsonlite::toJSON`
toJSON = function() { #' @return JSON string representation of the {{{classname}}}.
if (!is.null(self$actual_instance)) { toJSONString = function(...) {
self$actual_instance$toJSON() json <- jsonlite::toJSON(self$toSimpleType(), auto_unbox = TRUE, ...)
} else { return(as.character(jsonlite::minify(json)))
NULL
}
}, },
#' @description #' @description

View File

@ -38,11 +38,18 @@
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return {{{classname}}} in JSON format
toJSON = function() { 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 {{{classname}}} to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
return(private$value)
}, },
#' @description #' @description
@ -60,10 +67,11 @@
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return {{{classname}}} in JSON format #' @return {{{classname}}} in JSON format
toJSONString = function() { toJSONString = function(...) {
as.character(jsonlite::toJSON(private$value, json <- jsonlite::toJSON(self$toSimpleType(), auto_unbox = TRUE, ...)
auto_unbox = TRUE)) return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -203,10 +203,35 @@
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return {{{classname}}} in JSON format
toJSON = function() { 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 {{{classname}}} as a base R list.
#' @examples
#' # convert array of {{{classname}}} (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 {{{classname}}} to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
{{classname}}Object <- list() {{classname}}Object <- list()
{{#vars}} {{#vars}}
if (!is.null(self$`{{name}}`)) { if (!is.null(self$`{{name}}`)) {
@ -217,7 +242,7 @@
self$`{{name}}` self$`{{name}}`
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{^isPrimitiveType}} {{^isPrimitiveType}}
lapply(self$`{{name}}`, function(x) x$toJSON()) lapply(self$`{{name}}`, function(x) x$toSimpleType())
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{/isArray}} {{/isArray}}
{{#isMap}} {{#isMap}}
@ -225,7 +250,7 @@
self$`{{name}}` self$`{{name}}`
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{^isPrimitiveType}} {{^isPrimitiveType}}
lapply(self$`{{name}}`, function(x) x$toJSON()) lapply(self$`{{name}}`, function(x) x$toSimpleType())
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{/isMap}} {{/isMap}}
{{/isContainer}} {{/isContainer}}
@ -234,7 +259,7 @@
self$`{{name}}` self$`{{name}}`
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{^isPrimitiveType}} {{^isPrimitiveType}}
self$`{{name}}`$toJSON() self$`{{name}}`$toSimpleType()
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{/isContainer}} {{/isContainer}}
} }
@ -245,7 +270,7 @@
} }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesTrue}}
{{classname}}Object return({{classname}}Object)
}, },
#' @description #' @description
@ -304,76 +329,18 @@
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return {{{classname}}} in JSON format #' @return {{{classname}}} in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
{{#vars}}
if (!is.null(self$`{{name}}`)) {
sprintf(
'"{{baseName}}":
{{#isContainer}}
{{#isArray}}
{{#isPrimitiveType}}
{{#isNumeric}}[%d]{{/isNumeric}}{{^isNumeric}}[%s]{{/isNumeric}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}[%s]
{{/isPrimitiveType}}
{{/isArray}}
{{#isMap}}
{{#isPrimitiveType}}
{{#isNumeric}}%d{{/isNumeric}}{{^isNumeric}}{{^isBoolean}}{{/isBoolean}}%s{{^isBoolean}}{{/isBoolean}}{{/isNumeric}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}%s
{{/isPrimitiveType}}
{{/isMap}}
{{/isContainer}}
{{^isContainer}}
{{#isPrimitiveType}}
{{#isNumeric}}%d{{/isNumeric}}{{^isNumeric}}{{^isBoolean}}"{{/isBoolean}}%s{{^isBoolean}}"{{/isBoolean}}{{/isNumeric}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}%s
{{/isPrimitiveType}}
{{/isContainer}}',
{{#isContainer}}
{{#isArray}}
{{#isPrimitiveType}}
paste(unlist(lapply(self$`{{{name}}}`, function(x) paste0('"', x, '"'))), collapse = ",")
{{/isPrimitiveType}}
{{^isPrimitiveType}}
paste(sapply(self$`{{{name}}}`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox = TRUE, digits = NA)), collapse = ",")
{{/isPrimitiveType}}
{{/isArray}}
{{#isMap}}
{{#isPrimitiveType}}
jsonlite::toJSON(lapply(self$`{{{name}}}`, function(x){ x }), auto_unbox = TRUE, digits = NA)
{{/isPrimitiveType}}
{{^isPrimitiveType}}
jsonlite::toJSON(lapply(self$`{{{name}}}`, function(x){ x$toJSON() }), auto_unbox = TRUE, digits = NA)
{{/isPrimitiveType}}
{{/isMap}}
{{/isContainer}}
{{^isContainer}}
{{#isPrimitiveType}}
{{#isBoolean}}tolower({{/isBoolean}}self$`{{name}}`{{#isBoolean}}){{/isBoolean}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}
jsonlite::toJSON(self$`{{name}}`$toJSON(), auto_unbox = TRUE, digits = NA)
{{/isPrimitiveType}}
{{/isContainer}}
)
}{{^-last}},{{/-last}}
{{/vars}}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesTrue}}
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA)))
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesTrue}}
json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -139,25 +139,35 @@
#' @description #' @description
#' Serialize {{{classname}}} to JSON string. #' Serialize {{{classname}}} to JSON string.
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return JSON string representation of the {{{classname}}}. #' @return JSON string representation of the {{{classname}}}.
toJSONString = function() { toJSONString = function(...) {
simple <- self$toSimpleType()
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
as.character(jsonlite::minify(self$actual_instance$toJSONString())) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, ...)
return(as.character(jsonlite::minify(json)))
} else { } else {
NULL return(NULL)
} }
}, },
#' @description #' @description
#' Serialize {{{classname}}} to JSON. #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return JSON representation of the {{{classname}}}.
toJSON = function() { 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 {{{classname}}} to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
self$actual_instance$toJSON() return(self$actual_instance$toSimpleType())
} else { } else {
NULL return(NULL)
} }
}, },

View File

@ -40,10 +40,35 @@ Bird <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Bird in JSON format
toJSON = function() { 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() BirdObject <- list()
if (!is.null(self$`size`)) { if (!is.null(self$`size`)) {
BirdObject[["size"]] <- BirdObject[["size"]] <-
@ -53,7 +78,7 @@ Bird <- R6::R6Class(
BirdObject[["color"]] <- BirdObject[["color"]] <-
self$`color` self$`color`
} }
BirdObject return(BirdObject)
}, },
#' @description #' @description
@ -74,29 +99,13 @@ Bird <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Bird in JSON format #' @return Bird in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`size`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"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 = "")))
}, },
#' @description #' @description

View File

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

View File

@ -40,10 +40,35 @@ Category <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Category in JSON format
toJSON = function() { 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() CategoryObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
CategoryObject[["id"]] <- CategoryObject[["id"]] <-
@ -53,7 +78,7 @@ Category <- R6::R6Class(
CategoryObject[["name"]] <- CategoryObject[["name"]] <-
self$`name` self$`name`
} }
CategoryObject return(CategoryObject)
}, },
#' @description #' @description
@ -74,29 +99,13 @@ Category <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Category in JSON format #' @return Category in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`id`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"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 = "")))
}, },
#' @description #' @description

View File

@ -67,10 +67,35 @@ DataQuery <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return DataQuery in JSON format
toJSON = function() { 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() DataQueryObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
DataQueryObject[["id"]] <- DataQueryObject[["id"]] <-
@ -92,7 +117,7 @@ DataQuery <- R6::R6Class(
DataQueryObject[["date"]] <- DataQueryObject[["date"]] <-
self$`date` self$`date`
} }
DataQueryObject return(DataQueryObject)
}, },
#' @description #' @description
@ -122,53 +147,13 @@ DataQuery <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return DataQuery in JSON format #' @return DataQuery in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`id`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"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 = "")))
}, },
#' @description #' @description

View File

@ -87,14 +87,39 @@ DefaultValue <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return DefaultValue in JSON format
toJSON = function() { 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() DefaultValueObject <- list()
if (!is.null(self$`array_string_enum_ref_default`)) { if (!is.null(self$`array_string_enum_ref_default`)) {
DefaultValueObject[["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`)) { if (!is.null(self$`array_string_enum_default`)) {
DefaultValueObject[["array_string_enum_default"]] <- DefaultValueObject[["array_string_enum_default"]] <-
@ -124,7 +149,7 @@ DefaultValue <- R6::R6Class(
DefaultValueObject[["string_nullable"]] <- DefaultValueObject[["string_nullable"]] <-
self$`string_nullable` self$`string_nullable`
} }
DefaultValueObject return(DefaultValueObject)
}, },
#' @description #' @description
@ -163,77 +188,13 @@ DefaultValue <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return DefaultValue in JSON format #' @return DefaultValue in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`array_string_enum_ref_default`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"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 = "")))
}, },
#' @description #' @description

View File

@ -46,10 +46,35 @@ NumberPropertiesOnly <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return NumberPropertiesOnly in JSON format
toJSON = function() { 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() NumberPropertiesOnlyObject <- list()
if (!is.null(self$`number`)) { if (!is.null(self$`number`)) {
NumberPropertiesOnlyObject[["number"]] <- NumberPropertiesOnlyObject[["number"]] <-
@ -63,7 +88,7 @@ NumberPropertiesOnly <- R6::R6Class(
NumberPropertiesOnlyObject[["double"]] <- NumberPropertiesOnlyObject[["double"]] <-
self$`double` self$`double`
} }
NumberPropertiesOnlyObject return(NumberPropertiesOnlyObject)
}, },
#' @description #' @description
@ -87,37 +112,13 @@ NumberPropertiesOnly <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return NumberPropertiesOnly in JSON format #' @return NumberPropertiesOnly in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`number`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"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 = "")))
}, },
#' @description #' @description

View File

@ -75,10 +75,35 @@ Pet <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Pet in JSON format
toJSON = function() { 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() PetObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
PetObject[["id"]] <- PetObject[["id"]] <-
@ -90,7 +115,7 @@ Pet <- R6::R6Class(
} }
if (!is.null(self$`category`)) { if (!is.null(self$`category`)) {
PetObject[["category"]] <- PetObject[["category"]] <-
self$`category`$toJSON() self$`category`$toSimpleType()
} }
if (!is.null(self$`photoUrls`)) { if (!is.null(self$`photoUrls`)) {
PetObject[["photoUrls"]] <- PetObject[["photoUrls"]] <-
@ -98,13 +123,13 @@ Pet <- R6::R6Class(
} }
if (!is.null(self$`tags`)) { if (!is.null(self$`tags`)) {
PetObject[["tags"]] <- PetObject[["tags"]] <-
lapply(self$`tags`, function(x) x$toJSON()) lapply(self$`tags`, function(x) x$toSimpleType())
} }
if (!is.null(self$`status`)) { if (!is.null(self$`status`)) {
PetObject[["status"]] <- PetObject[["status"]] <-
self$`status` self$`status`
} }
PetObject return(PetObject)
}, },
#' @description #' @description
@ -142,61 +167,13 @@ Pet <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Pet in JSON format #' @return Pet in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`id`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"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 = "")))
}, },
#' @description #' @description

View File

@ -39,10 +39,35 @@ Query <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Query in JSON format
toJSON = function() { 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() QueryObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
QueryObject[["id"]] <- QueryObject[["id"]] <-
@ -52,7 +77,7 @@ Query <- R6::R6Class(
QueryObject[["outcomes"]] <- QueryObject[["outcomes"]] <-
self$`outcomes` self$`outcomes`
} }
QueryObject return(QueryObject)
}, },
#' @description #' @description
@ -73,29 +98,13 @@ Query <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Query in JSON format #' @return Query in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`id`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"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 = "")))
}, },
#' @description #' @description

View File

@ -37,11 +37,18 @@ StringEnumRef <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return StringEnumRef in JSON format
toJSON = function() { 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 #' @description
@ -59,10 +66,11 @@ StringEnumRef <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return StringEnumRef in JSON format #' @return StringEnumRef in JSON format
toJSONString = function() { toJSONString = function(...) {
as.character(jsonlite::toJSON(private$value, json <- jsonlite::toJSON(self$toSimpleType(), auto_unbox = TRUE, ...)
auto_unbox = TRUE)) return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -40,10 +40,35 @@ Tag <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Tag in JSON format
toJSON = function() { 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() TagObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
TagObject[["id"]] <- TagObject[["id"]] <-
@ -53,7 +78,7 @@ Tag <- R6::R6Class(
TagObject[["name"]] <- TagObject[["name"]] <-
self$`name` self$`name`
} }
TagObject return(TagObject)
}, },
#' @description #' @description
@ -74,29 +99,13 @@ Tag <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Tag in JSON format #' @return Tag in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`id`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"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 = "")))
}, },
#' @description #' @description

View File

@ -31,16 +31,41 @@ TestFormObjectMultipartRequestMarker <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return TestFormObjectMultipartRequestMarker in JSON format
toJSON = function() { 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() TestFormObjectMultipartRequestMarkerObject <- list()
if (!is.null(self$`name`)) { if (!is.null(self$`name`)) {
TestFormObjectMultipartRequestMarkerObject[["name"]] <- TestFormObjectMultipartRequestMarkerObject[["name"]] <-
self$`name` self$`name`
} }
TestFormObjectMultipartRequestMarkerObject return(TestFormObjectMultipartRequestMarkerObject)
}, },
#' @description #' @description
@ -58,21 +83,13 @@ TestFormObjectMultipartRequestMarker <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return TestFormObjectMultipartRequestMarker in JSON format #' @return TestFormObjectMultipartRequestMarker in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`name`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"name":
"%s"
',
self$`name`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -58,10 +58,35 @@ TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter <- R6::R6Clas
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter in JSON format
toJSON = function() { 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() TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject <- list()
if (!is.null(self$`size`)) { if (!is.null(self$`size`)) {
TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject[["size"]] <- TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject[["size"]] <-
@ -79,7 +104,7 @@ TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter <- R6::R6Clas
TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject[["name"]] <- TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject[["name"]] <-
self$`name` self$`name`
} }
TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject return(TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject)
}, },
#' @description #' @description
@ -106,45 +131,13 @@ TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter <- R6::R6Clas
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter in JSON format #' @return TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`size`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"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 = "")))
}, },
#' @description #' @description

View File

@ -30,16 +30,41 @@ TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter in JSON format
toJSON = function() { 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() TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterObject <- list()
if (!is.null(self$`values`)) { if (!is.null(self$`values`)) {
TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterObject[["values"]] <- TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterObject[["values"]] <-
self$`values` self$`values`
} }
TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterObject return(TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterObject)
}, },
#' @description #' @description
@ -57,21 +82,13 @@ TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter in JSON format #' @return TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`values`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"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 = "")))
}, },
#' @description #' @description

View File

@ -77,10 +77,35 @@ AllofTagApiResponse <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return AllofTagApiResponse in JSON format
toJSON = function() { 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 AllofTagApiResponse as a base R list.
#' @examples
#' # convert array of AllofTagApiResponse (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 AllofTagApiResponse to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
AllofTagApiResponseObject <- list() AllofTagApiResponseObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
AllofTagApiResponseObject[["id"]] <- AllofTagApiResponseObject[["id"]] <-
@ -106,7 +131,7 @@ AllofTagApiResponse <- R6::R6Class(
AllofTagApiResponseObject[[key]] <- self$additional_properties[[key]] AllofTagApiResponseObject[[key]] <- self$additional_properties[[key]]
} }
AllofTagApiResponseObject return(AllofTagApiResponseObject)
}, },
#' @description #' @description
@ -143,58 +168,16 @@ AllofTagApiResponse <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return AllofTagApiResponse in JSON format #' @return AllofTagApiResponse in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`name`)) {
sprintf(
'"name":
"%s"
',
self$`name`
)
},
if (!is.null(self$`code`)) {
sprintf(
'"code":
%d
',
self$`code`
)
},
if (!is.null(self$`type`)) {
sprintf(
'"type":
"%s"
',
self$`type`
)
},
if (!is.null(self$`message`)) {
sprintf(
'"message":
"%s"
',
self$`message`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -52,10 +52,35 @@ Animal <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Animal in JSON format
toJSON = function() { 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 Animal as a base R list.
#' @examples
#' # convert array of Animal (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 Animal to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
AnimalObject <- list() AnimalObject <- list()
if (!is.null(self$`className`)) { if (!is.null(self$`className`)) {
AnimalObject[["className"]] <- AnimalObject[["className"]] <-
@ -69,7 +94,7 @@ Animal <- R6::R6Class(
AnimalObject[[key]] <- self$additional_properties[[key]] AnimalObject[[key]] <- self$additional_properties[[key]]
} }
AnimalObject return(AnimalObject)
}, },
#' @description #' @description
@ -97,34 +122,16 @@ Animal <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Animal in JSON format #' @return Animal in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`color`)) {
sprintf(
'"color":
"%s"
',
self$`color`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -91,27 +91,32 @@ AnyOfPig <- R6::R6Class(
}, },
#' @description #' @description
#' Serialize AnyOfPig to JSON string. #' 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 AnyOfPig to a base R type
#' #'
#' @return JSON string representation of the AnyOfPig. #' @return A base R type, e.g. a list or numeric/character array.
toJSONString = function() { toSimpleType = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
as.character(jsonlite::minify((self$actual_instance$toJSONString()))) return(self$actual_instance$toSimpleType())
} else { } else {
NULL NULL
} }
}, },
#' @description #' @description
#' Serialize AnyOfPig to JSON. #' Serialize AnyOfPig to JSON string.
#' #'
#' @return JSON representation of the AnyOfPig. #' @param ... Parameters passed to `jsonlite::toJSON`
toJSON = function() { #' @return JSON string representation of the AnyOfPig.
if (!is.null(self$actual_instance)) { toJSONString = function(...) {
self$actual_instance$toJSON() json <- jsonlite::toJSON(self$toSimpleType(), auto_unbox = TRUE, ...)
} else { return(as.character(jsonlite::minify(json)))
NULL
}
}, },
#' @description #' @description

View File

@ -111,25 +111,35 @@ AnyOfPrimitiveTypeTest <- R6::R6Class(
#' @description #' @description
#' Serialize AnyOfPrimitiveTypeTest to JSON string. #' Serialize AnyOfPrimitiveTypeTest to JSON string.
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return JSON string representation of the AnyOfPrimitiveTypeTest. #' @return JSON string representation of the AnyOfPrimitiveTypeTest.
toJSONString = function() { toJSONString = function(...) {
simple <- self$toSimpleType()
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
as.character(jsonlite::minify(self$actual_instance$toJSONString())) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, ...)
return(as.character(jsonlite::minify(json)))
} else { } else {
NULL return(NULL)
} }
}, },
#' @description #' @description
#' Serialize AnyOfPrimitiveTypeTest to JSON. #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return JSON representation of the AnyOfPrimitiveTypeTest.
toJSON = function() { 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 AnyOfPrimitiveTypeTest to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
self$actual_instance$toJSON() return(self$actual_instance$toSimpleType())
} else { } else {
NULL return(NULL)
} }
}, },

View File

@ -50,10 +50,35 @@ BasquePig <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return BasquePig in JSON format
toJSON = function() { 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 BasquePig as a base R list.
#' @examples
#' # convert array of BasquePig (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 BasquePig to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
BasquePigObject <- list() BasquePigObject <- list()
if (!is.null(self$`className`)) { if (!is.null(self$`className`)) {
BasquePigObject[["className"]] <- BasquePigObject[["className"]] <-
@ -67,7 +92,7 @@ BasquePig <- R6::R6Class(
BasquePigObject[[key]] <- self$additional_properties[[key]] BasquePigObject[[key]] <- self$additional_properties[[key]]
} }
BasquePigObject return(BasquePigObject)
}, },
#' @description #' @description
@ -95,34 +120,16 @@ BasquePig <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return BasquePig in JSON format #' @return BasquePig in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`color`)) {
sprintf(
'"color":
"%s"
',
self$`color`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -60,10 +60,35 @@ Cat <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Cat in JSON format
toJSON = function() { 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 Cat as a base R list.
#' @examples
#' # convert array of Cat (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 Cat to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
CatObject <- list() CatObject <- list()
if (!is.null(self$`className`)) { if (!is.null(self$`className`)) {
CatObject[["className"]] <- CatObject[["className"]] <-
@ -81,7 +106,7 @@ Cat <- R6::R6Class(
CatObject[[key]] <- self$additional_properties[[key]] CatObject[[key]] <- self$additional_properties[[key]]
} }
CatObject return(CatObject)
}, },
#' @description #' @description
@ -112,42 +137,16 @@ Cat <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Cat in JSON format #' @return Cat in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`color`)) {
sprintf(
'"color":
"%s"
',
self$`color`
)
},
if (!is.null(self$`declawed`)) {
sprintf(
'"declawed":
%s
',
tolower(self$`declawed`)
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -50,10 +50,35 @@ Category <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Category in JSON format
toJSON = function() { 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() CategoryObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
CategoryObject[["id"]] <- CategoryObject[["id"]] <-
@ -67,7 +92,7 @@ Category <- R6::R6Class(
CategoryObject[[key]] <- self$additional_properties[[key]] CategoryObject[[key]] <- self$additional_properties[[key]]
} }
CategoryObject return(CategoryObject)
}, },
#' @description #' @description
@ -95,34 +120,16 @@ Category <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Category in JSON format #' @return Category in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
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 = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -50,10 +50,35 @@ DanishPig <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return DanishPig in JSON format
toJSON = function() { 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 DanishPig as a base R list.
#' @examples
#' # convert array of DanishPig (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 DanishPig to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
DanishPigObject <- list() DanishPigObject <- list()
if (!is.null(self$`className`)) { if (!is.null(self$`className`)) {
DanishPigObject[["className"]] <- DanishPigObject[["className"]] <-
@ -67,7 +92,7 @@ DanishPig <- R6::R6Class(
DanishPigObject[[key]] <- self$additional_properties[[key]] DanishPigObject[[key]] <- self$additional_properties[[key]]
} }
DanishPigObject return(DanishPigObject)
}, },
#' @description #' @description
@ -95,34 +120,16 @@ DanishPig <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return DanishPig in JSON format #' @return DanishPig in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`size`)) {
sprintf(
'"size":
%d
',
self$`size`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -63,10 +63,35 @@ Date <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Date in JSON format
toJSON = function() { 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 Date as a base R list.
#' @examples
#' # convert array of Date (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 Date to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
DateObject <- list() DateObject <- list()
if (!is.null(self$`className`)) { if (!is.null(self$`className`)) {
DateObject[["className"]] <- DateObject[["className"]] <-
@ -84,7 +109,7 @@ Date <- R6::R6Class(
DateObject[[key]] <- self$additional_properties[[key]] DateObject[[key]] <- self$additional_properties[[key]]
} }
DateObject return(DateObject)
}, },
#' @description #' @description
@ -119,42 +144,16 @@ Date <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Date in JSON format #' @return Date in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`percent_description`)) {
sprintf(
'"percent_description":
"%s"
',
self$`percent_description`
)
},
if (!is.null(self$`url_property`)) {
sprintf(
'"url_property":
"%s"
',
self$`url_property`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -60,10 +60,35 @@ Dog <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Dog in JSON format
toJSON = function() { 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 Dog as a base R list.
#' @examples
#' # convert array of Dog (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 Dog to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
DogObject <- list() DogObject <- list()
if (!is.null(self$`className`)) { if (!is.null(self$`className`)) {
DogObject[["className"]] <- DogObject[["className"]] <-
@ -81,7 +106,7 @@ Dog <- R6::R6Class(
DogObject[[key]] <- self$additional_properties[[key]] DogObject[[key]] <- self$additional_properties[[key]]
} }
DogObject return(DogObject)
}, },
#' @description #' @description
@ -112,42 +137,16 @@ Dog <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Dog in JSON format #' @return Dog in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`color`)) {
sprintf(
'"color":
"%s"
',
self$`color`
)
},
if (!is.null(self$`breed`)) {
sprintf(
'"breed":
"%s"
',
self$`breed`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -41,10 +41,35 @@ DummyModel <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return DummyModel in JSON format
toJSON = function() { 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 DummyModel as a base R list.
#' @examples
#' # convert array of DummyModel (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 DummyModel to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
DummyModelObject <- list() DummyModelObject <- list()
if (!is.null(self$`property`)) { if (!is.null(self$`property`)) {
DummyModelObject[["property"]] <- DummyModelObject[["property"]] <-
@ -54,7 +79,7 @@ DummyModel <- R6::R6Class(
DummyModelObject[[key]] <- self$additional_properties[[key]] DummyModelObject[[key]] <- self$additional_properties[[key]]
} }
DummyModelObject return(DummyModelObject)
}, },
#' @description #' @description
@ -79,26 +104,16 @@ DummyModel <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return DummyModel in JSON format #' @return DummyModel in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`property`)) {
sprintf(
'"property":
"%s"
',
self$`property`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -225,7 +225,7 @@ FakeApi <- R6::R6Class(
if (!is.null(`pet`)) { if (!is.null(`pet`)) {
local_var_body <- `pet`$toJSONString() local_var_body <- `pet`$toJSONString()
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/fake/test_optional_body_parameter" local_var_url_path <- "/fake/test_optional_body_parameter"

View File

@ -158,10 +158,35 @@ FormatTest <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return FormatTest in JSON format
toJSON = function() { 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 FormatTest as a base R list.
#' @examples
#' # convert array of FormatTest (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 FormatTest to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
FormatTestObject <- list() FormatTestObject <- list()
if (!is.null(self$`integer`)) { if (!is.null(self$`integer`)) {
FormatTestObject[["integer"]] <- FormatTestObject[["integer"]] <-
@ -227,7 +252,7 @@ FormatTest <- R6::R6Class(
FormatTestObject[[key]] <- self$additional_properties[[key]] FormatTestObject[[key]] <- self$additional_properties[[key]]
} }
FormatTestObject return(FormatTestObject)
}, },
#' @description #' @description
@ -294,138 +319,16 @@ FormatTest <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return FormatTest in JSON format #' @return FormatTest in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`integer`)) {
sprintf(
'"integer":
%d
',
self$`integer`
)
},
if (!is.null(self$`int32`)) {
sprintf(
'"int32":
%d
',
self$`int32`
)
},
if (!is.null(self$`int64`)) {
sprintf(
'"int64":
%d
',
self$`int64`
)
},
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`
)
},
if (!is.null(self$`string`)) {
sprintf(
'"string":
"%s"
',
self$`string`
)
},
if (!is.null(self$`byte`)) {
sprintf(
'"byte":
"%s"
',
self$`byte`
)
},
if (!is.null(self$`binary`)) {
sprintf(
'"binary":
"%s"
',
self$`binary`
)
},
if (!is.null(self$`date`)) {
sprintf(
'"date":
"%s"
',
self$`date`
)
},
if (!is.null(self$`dateTime`)) {
sprintf(
'"dateTime":
"%s"
',
self$`dateTime`
)
},
if (!is.null(self$`uuid`)) {
sprintf(
'"uuid":
"%s"
',
self$`uuid`
)
},
if (!is.null(self$`password`)) {
sprintf(
'"password":
"%s"
',
self$`password`
)
},
if (!is.null(self$`pattern_with_digits`)) {
sprintf(
'"pattern_with_digits":
"%s"
',
self$`pattern_with_digits`
)
},
if (!is.null(self$`pattern_with_digits_and_delimiter`)) {
sprintf(
'"pattern_with_digits_and_delimiter":
"%s"
',
self$`pattern_with_digits_and_delimiter`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -135,25 +135,35 @@ Mammal <- R6::R6Class(
#' @description #' @description
#' Serialize Mammal to JSON string. #' Serialize Mammal to JSON string.
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return JSON string representation of the Mammal. #' @return JSON string representation of the Mammal.
toJSONString = function() { toJSONString = function(...) {
simple <- self$toSimpleType()
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
as.character(jsonlite::minify(self$actual_instance$toJSONString())) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, ...)
return(as.character(jsonlite::minify(json)))
} else { } else {
NULL return(NULL)
} }
}, },
#' @description #' @description
#' Serialize Mammal to JSON. #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return JSON representation of the Mammal.
toJSON = function() { 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 Mammal to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
self$actual_instance$toJSON() return(self$actual_instance$toSimpleType())
} else { } else {
NULL return(NULL)
} }
}, },

View File

@ -59,10 +59,35 @@ ModelApiResponse <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return ModelApiResponse in JSON format
toJSON = function() { 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 ModelApiResponse as a base R list.
#' @examples
#' # convert array of ModelApiResponse (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 ModelApiResponse to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
ModelApiResponseObject <- list() ModelApiResponseObject <- list()
if (!is.null(self$`code`)) { if (!is.null(self$`code`)) {
ModelApiResponseObject[["code"]] <- ModelApiResponseObject[["code"]] <-
@ -80,7 +105,7 @@ ModelApiResponse <- R6::R6Class(
ModelApiResponseObject[[key]] <- self$additional_properties[[key]] ModelApiResponseObject[[key]] <- self$additional_properties[[key]]
} }
ModelApiResponseObject return(ModelApiResponseObject)
}, },
#' @description #' @description
@ -111,42 +136,16 @@ ModelApiResponse <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return ModelApiResponse in JSON format #' @return ModelApiResponse in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`code`)) {
sprintf(
'"code":
%d
',
self$`code`
)
},
if (!is.null(self$`type`)) {
sprintf(
'"type":
"%s"
',
self$`type`
)
},
if (!is.null(self$`message`)) {
sprintf(
'"message":
"%s"
',
self$`message`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -48,10 +48,35 @@ NestedOneOf <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return NestedOneOf in JSON format
toJSON = function() { 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 NestedOneOf as a base R list.
#' @examples
#' # convert array of NestedOneOf (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 NestedOneOf to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
NestedOneOfObject <- list() NestedOneOfObject <- list()
if (!is.null(self$`size`)) { if (!is.null(self$`size`)) {
NestedOneOfObject[["size"]] <- NestedOneOfObject[["size"]] <-
@ -59,13 +84,13 @@ NestedOneOf <- R6::R6Class(
} }
if (!is.null(self$`nested_pig`)) { if (!is.null(self$`nested_pig`)) {
NestedOneOfObject[["nested_pig"]] <- NestedOneOfObject[["nested_pig"]] <-
self$`nested_pig`$toJSON() self$`nested_pig`$toSimpleType()
} }
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
NestedOneOfObject[[key]] <- self$additional_properties[[key]] NestedOneOfObject[[key]] <- self$additional_properties[[key]]
} }
NestedOneOfObject return(NestedOneOfObject)
}, },
#' @description #' @description
@ -95,34 +120,16 @@ NestedOneOf <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return NestedOneOf in JSON format #' @return NestedOneOf in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`size`)) {
sprintf(
'"size":
%d
',
self$`size`
)
},
if (!is.null(self$`nested_pig`)) {
sprintf(
'"nested_pig":
%s
',
jsonlite::toJSON(self$`nested_pig`$toJSON(), auto_unbox = TRUE, digits = NA)
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -111,25 +111,35 @@ OneOfPrimitiveTypeTest <- R6::R6Class(
#' @description #' @description
#' Serialize OneOfPrimitiveTypeTest to JSON string. #' Serialize OneOfPrimitiveTypeTest to JSON string.
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return JSON string representation of the OneOfPrimitiveTypeTest. #' @return JSON string representation of the OneOfPrimitiveTypeTest.
toJSONString = function() { toJSONString = function(...) {
simple <- self$toSimpleType()
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
as.character(jsonlite::minify(self$actual_instance$toJSONString())) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, ...)
return(as.character(jsonlite::minify(json)))
} else { } else {
NULL return(NULL)
} }
}, },
#' @description #' @description
#' Serialize OneOfPrimitiveTypeTest to JSON. #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return JSON representation of the OneOfPrimitiveTypeTest.
toJSON = function() { 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 OneOfPrimitiveTypeTest to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
self$actual_instance$toJSON() return(self$actual_instance$toSimpleType())
} else { } else {
NULL return(NULL)
} }
}, },

View File

@ -89,10 +89,35 @@ Order <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Order in JSON format
toJSON = function() { 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 Order as a base R list.
#' @examples
#' # convert array of Order (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 Order to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
OrderObject <- list() OrderObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
OrderObject[["id"]] <- OrderObject[["id"]] <-
@ -122,7 +147,7 @@ Order <- R6::R6Class(
OrderObject[[key]] <- self$additional_properties[[key]] OrderObject[[key]] <- self$additional_properties[[key]]
} }
OrderObject return(OrderObject)
}, },
#' @description #' @description
@ -165,66 +190,16 @@ Order <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Order in JSON format #' @return Order in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`petId`)) {
sprintf(
'"petId":
%d
',
self$`petId`
)
},
if (!is.null(self$`quantity`)) {
sprintf(
'"quantity":
%d
',
self$`quantity`
)
},
if (!is.null(self$`shipDate`)) {
sprintf(
'"shipDate":
"%s"
',
self$`shipDate`
)
},
if (!is.null(self$`status`)) {
sprintf(
'"status":
"%s"
',
self$`status`
)
},
if (!is.null(self$`complete`)) {
sprintf(
'"complete":
%s
',
tolower(self$`complete`)
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -85,10 +85,35 @@ Pet <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Pet in JSON format
toJSON = function() { 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() PetObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
PetObject[["id"]] <- PetObject[["id"]] <-
@ -96,7 +121,7 @@ Pet <- R6::R6Class(
} }
if (!is.null(self$`category`)) { if (!is.null(self$`category`)) {
PetObject[["category"]] <- PetObject[["category"]] <-
self$`category`$toJSON() self$`category`$toSimpleType()
} }
if (!is.null(self$`name`)) { if (!is.null(self$`name`)) {
PetObject[["name"]] <- PetObject[["name"]] <-
@ -108,7 +133,7 @@ Pet <- R6::R6Class(
} }
if (!is.null(self$`tags`)) { if (!is.null(self$`tags`)) {
PetObject[["tags"]] <- PetObject[["tags"]] <-
lapply(self$`tags`, function(x) x$toJSON()) lapply(self$`tags`, function(x) x$toSimpleType())
} }
if (!is.null(self$`status`)) { if (!is.null(self$`status`)) {
PetObject[["status"]] <- PetObject[["status"]] <-
@ -118,7 +143,7 @@ Pet <- R6::R6Class(
PetObject[[key]] <- self$additional_properties[[key]] PetObject[[key]] <- self$additional_properties[[key]]
} }
PetObject return(PetObject)
}, },
#' @description #' @description
@ -163,66 +188,16 @@ Pet <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Pet in JSON format #' @return Pet in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`category`)) {
sprintf(
'"category":
%s
',
jsonlite::toJSON(self$`category`$toJSON(), auto_unbox = TRUE, digits = NA)
)
},
if (!is.null(self$`name`)) {
sprintf(
'"name":
"%s"
',
self$`name`
)
},
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 = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -435,7 +435,7 @@ PetApi <- R6::R6Class(
if (!is.null(`pet`)) { if (!is.null(`pet`)) {
local_var_body <- `pet`$toJSONString() local_var_body <- `pet`$toJSONString()
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/pet" local_var_url_path <- "/pet"
@ -1288,7 +1288,7 @@ PetApi <- R6::R6Class(
if (!is.null(`pet`)) { if (!is.null(`pet`)) {
local_var_body <- `pet`$toJSONString() local_var_body <- `pet`$toJSONString()
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/pet" local_var_url_path <- "/pet"

View File

@ -40,10 +40,35 @@ PetMap <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return PetMap in JSON format
toJSON = function() { 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 PetMap as a base R list.
#' @examples
#' # convert array of PetMap (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 PetMap to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
PetMapObject <- list() PetMapObject <- list()
if (!is.null(self$`pet`)) { if (!is.null(self$`pet`)) {
PetMapObject[["pet"]] <- PetMapObject[["pet"]] <-
@ -53,7 +78,7 @@ PetMap <- R6::R6Class(
PetMapObject[[key]] <- self$additional_properties[[key]] PetMapObject[[key]] <- self$additional_properties[[key]]
} }
PetMapObject return(PetMapObject)
}, },
#' @description #' @description
@ -78,26 +103,16 @@ PetMap <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return PetMap in JSON format #' @return PetMap in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`pet`)) {
sprintf(
'"pet":
%s
',
jsonlite::toJSON(lapply(self$`pet`, function(x){ x }), auto_unbox = TRUE, digits = NA)
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -135,25 +135,35 @@ Pig <- R6::R6Class(
#' @description #' @description
#' Serialize Pig to JSON string. #' Serialize Pig to JSON string.
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return JSON string representation of the Pig. #' @return JSON string representation of the Pig.
toJSONString = function() { toJSONString = function(...) {
simple <- self$toSimpleType()
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
as.character(jsonlite::minify(self$actual_instance$toJSONString())) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, ...)
return(as.character(jsonlite::minify(json)))
} else { } else {
NULL return(NULL)
} }
}, },
#' @description #' @description
#' Serialize Pig to JSON. #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return JSON representation of the Pig.
toJSON = function() { 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 Pig to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
self$actual_instance$toJSON() return(self$actual_instance$toSimpleType())
} else { } else {
NULL return(NULL)
} }
}, },

View File

@ -97,10 +97,35 @@ Special <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Special in JSON format
toJSON = function() { 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 Special as a base R list.
#' @examples
#' # convert array of Special (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 Special to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
SpecialObject <- list() SpecialObject <- list()
if (!is.null(self$`set_test`)) { if (!is.null(self$`set_test`)) {
SpecialObject[["set_test"]] <- SpecialObject[["set_test"]] <-
@ -134,7 +159,7 @@ Special <- R6::R6Class(
SpecialObject[[key]] <- self$additional_properties[[key]] SpecialObject[[key]] <- self$additional_properties[[key]]
} }
SpecialObject return(SpecialObject)
}, },
#' @description #' @description
@ -180,74 +205,16 @@ Special <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Special in JSON format #' @return Special in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`set_test`)) {
sprintf(
'"set_test":
[%s]
',
paste(unlist(lapply(self$`set_test`, function(x) paste0('"', x, '"'))), collapse = ",")
)
},
if (!is.null(self$`item_self`)) {
sprintf(
'"self":
%d
',
self$`item_self`
)
},
if (!is.null(self$`item_private`)) {
sprintf(
'"private":
"%s"
',
self$`item_private`
)
},
if (!is.null(self$`item_super`)) {
sprintf(
'"super":
"%s"
',
self$`item_super`
)
},
if (!is.null(self$`123_number`)) {
sprintf(
'"123_number":
"%s"
',
self$`123_number`
)
},
if (!is.null(self$`array[test]`)) {
sprintf(
'"array[test]":
"%s"
',
self$`array[test]`
)
},
if (!is.null(self$`empty_string`)) {
sprintf(
'"empty_string":
"%s"
',
self$`empty_string`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -546,7 +546,7 @@ StoreApi <- R6::R6Class(
if (!is.null(`order`)) { if (!is.null(`order`)) {
local_var_body <- `order`$toJSONString() local_var_body <- `order`$toJSONString()
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/store/order" local_var_url_path <- "/store/order"

View File

@ -50,10 +50,35 @@ Tag <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Tag in JSON format
toJSON = function() { 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() TagObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
TagObject[["id"]] <- TagObject[["id"]] <-
@ -67,7 +92,7 @@ Tag <- R6::R6Class(
TagObject[[key]] <- self$additional_properties[[key]] TagObject[[key]] <- self$additional_properties[[key]]
} }
TagObject return(TagObject)
}, },
#' @description #' @description
@ -95,34 +120,16 @@ Tag <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Tag in JSON format #' @return Tag in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
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 = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -45,14 +45,39 @@ UpdatePetRequest <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return UpdatePetRequest in JSON format
toJSON = function() { 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 UpdatePetRequest as a base R list.
#' @examples
#' # convert array of UpdatePetRequest (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 UpdatePetRequest to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
UpdatePetRequestObject <- list() UpdatePetRequestObject <- list()
if (!is.null(self$`jsonData`)) { if (!is.null(self$`jsonData`)) {
UpdatePetRequestObject[["jsonData"]] <- UpdatePetRequestObject[["jsonData"]] <-
self$`jsonData`$toJSON() self$`jsonData`$toSimpleType()
} }
if (!is.null(self$`binaryDataN2Information`)) { if (!is.null(self$`binaryDataN2Information`)) {
UpdatePetRequestObject[["binaryDataN2Information"]] <- UpdatePetRequestObject[["binaryDataN2Information"]] <-
@ -62,7 +87,7 @@ UpdatePetRequest <- R6::R6Class(
UpdatePetRequestObject[[key]] <- self$additional_properties[[key]] UpdatePetRequestObject[[key]] <- self$additional_properties[[key]]
} }
UpdatePetRequestObject return(UpdatePetRequestObject)
}, },
#' @description #' @description
@ -92,34 +117,16 @@ UpdatePetRequest <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return UpdatePetRequest in JSON format #' @return UpdatePetRequest in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`jsonData`)) {
sprintf(
'"jsonData":
%s
',
jsonlite::toJSON(self$`jsonData`$toJSON(), auto_unbox = TRUE, digits = NA)
)
},
if (!is.null(self$`binaryDataN2Information`)) {
sprintf(
'"binaryDataN2Information":
"%s"
',
self$`binaryDataN2Information`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -104,10 +104,35 @@ User <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return User in JSON format
toJSON = function() { 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 User as a base R list.
#' @examples
#' # convert array of User (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 User to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
UserObject <- list() UserObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
UserObject[["id"]] <- UserObject[["id"]] <-
@ -145,7 +170,7 @@ User <- R6::R6Class(
UserObject[[key]] <- self$additional_properties[[key]] UserObject[[key]] <- self$additional_properties[[key]]
} }
UserObject return(UserObject)
}, },
#' @description #' @description
@ -191,82 +216,16 @@ User <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return User in JSON format #' @return User in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`username`)) {
sprintf(
'"username":
"%s"
',
self$`username`
)
},
if (!is.null(self$`firstName`)) {
sprintf(
'"firstName":
"%s"
',
self$`firstName`
)
},
if (!is.null(self$`lastName`)) {
sprintf(
'"lastName":
"%s"
',
self$`lastName`
)
},
if (!is.null(self$`email`)) {
sprintf(
'"email":
"%s"
',
self$`email`
)
},
if (!is.null(self$`password`)) {
sprintf(
'"password":
"%s"
',
self$`password`
)
},
if (!is.null(self$`phone`)) {
sprintf(
'"phone":
"%s"
',
self$`phone`
)
},
if (!is.null(self$`userStatus`)) {
sprintf(
'"userStatus":
%d
',
self$`userStatus`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -318,7 +318,7 @@ UserApi <- R6::R6Class(
if (!is.null(`user`)) { if (!is.null(`user`)) {
local_var_body <- `user`$toJSONString() local_var_body <- `user`$toJSONString()
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/user" local_var_url_path <- "/user"
@ -428,7 +428,7 @@ UserApi <- R6::R6Class(
})), collapse = ",") })), collapse = ",")
local_var_body <- paste0("[", body.items, "]") local_var_body <- paste0("[", body.items, "]")
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/user/createWithArray" local_var_url_path <- "/user/createWithArray"
@ -538,7 +538,7 @@ UserApi <- R6::R6Class(
})), collapse = ",") })), collapse = ",")
local_var_body <- paste0("[", body.items, "]") local_var_body <- paste0("[", body.items, "]")
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/user/createWithList" local_var_url_path <- "/user/createWithList"
@ -1099,7 +1099,7 @@ UserApi <- R6::R6Class(
if (!is.null(`user`)) { if (!is.null(`user`)) {
local_var_body <- `user`$toJSONString() local_var_body <- `user`$toJSONString()
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/user/{username}" local_var_url_path <- "/user/{username}"

View File

@ -59,10 +59,35 @@ Whale <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Whale in JSON format
toJSON = function() { 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 Whale as a base R list.
#' @examples
#' # convert array of Whale (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 Whale to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
WhaleObject <- list() WhaleObject <- list()
if (!is.null(self$`hasBaleen`)) { if (!is.null(self$`hasBaleen`)) {
WhaleObject[["hasBaleen"]] <- WhaleObject[["hasBaleen"]] <-
@ -80,7 +105,7 @@ Whale <- R6::R6Class(
WhaleObject[[key]] <- self$additional_properties[[key]] WhaleObject[[key]] <- self$additional_properties[[key]]
} }
WhaleObject return(WhaleObject)
}, },
#' @description #' @description
@ -111,42 +136,16 @@ Whale <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Whale in JSON format #' @return Whale in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`hasBaleen`)) {
sprintf(
'"hasBaleen":
%s
',
tolower(self$`hasBaleen`)
)
},
if (!is.null(self$`hasTeeth`)) {
sprintf(
'"hasTeeth":
%s
',
tolower(self$`hasTeeth`)
)
},
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -53,10 +53,35 @@ Zebra <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Zebra in JSON format
toJSON = function() { 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 Zebra as a base R list.
#' @examples
#' # convert array of Zebra (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 Zebra to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
ZebraObject <- list() ZebraObject <- list()
if (!is.null(self$`type`)) { if (!is.null(self$`type`)) {
ZebraObject[["type"]] <- ZebraObject[["type"]] <-
@ -70,7 +95,7 @@ Zebra <- R6::R6Class(
ZebraObject[[key]] <- self$additional_properties[[key]] ZebraObject[[key]] <- self$additional_properties[[key]]
} }
ZebraObject return(ZebraObject)
}, },
#' @description #' @description
@ -101,34 +126,16 @@ Zebra <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Zebra in JSON format #' @return Zebra in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`type`)) {
sprintf(
'"type":
"%s"
',
self$`type`
)
},
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -70,7 +70,7 @@ test_that("Test toJSON toJSONString fromJSON fromJSONString print", {
# tests for other pet objects # tests for other pet objects
pet0 <- Pet$new() pet0 <- Pet$new()
jsonpet <- pet0$toJSON() jsonpet <- pet0$toSimpleType()
pet2 <- pet0$fromJSON( pet2 <- pet0$fromJSON(
jsonlite::toJSON(jsonpet, auto_unbox = TRUE) jsonlite::toJSON(jsonpet, auto_unbox = TRUE)
) )
@ -96,7 +96,7 @@ test_that("Test toJSON toJSONString fromJSON fromJSONString print", {
), ),
status = "available" status = "available"
) )
jsonpet <- pet1$toJSON() jsonpet <- pet1$toSimpleType()
pet2 <- pet1$fromJSON( pet2 <- pet1$fromJSON(
jsonlite::toJSON(jsonpet, auto_unbox = TRUE) jsonlite::toJSON(jsonpet, auto_unbox = TRUE)
) )
@ -118,7 +118,7 @@ test_that("Test toJSON toJSONString fromJSON fromJSONString print", {
test_that("Test Category", { test_that("Test Category", {
c1 <- Category$new(id = 450, name = "test_cat") c1 <- Category$new(id = 450, name = "test_cat")
c2 <- Category$new() c2 <- Category$new()
c2$fromJSON(jsonlite::toJSON(c1$toJSON(), auto_unbox = TRUE)) c2$fromJSON(jsonlite::toJSON(c1$toSimpleType(), auto_unbox = TRUE))
expect_equal(c1, c2) expect_equal(c1, c2)
c2$fromJSONString(c1$toJSONString()) c2$fromJSONString(c1$toJSONString())
expect_equal(c1, c2) expect_equal(c1, c2)

View File

@ -67,10 +67,35 @@ AllofTagApiResponse <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return AllofTagApiResponse in JSON format
toJSON = function() { 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 AllofTagApiResponse as a base R list.
#' @examples
#' # convert array of AllofTagApiResponse (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 AllofTagApiResponse to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
AllofTagApiResponseObject <- list() AllofTagApiResponseObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
AllofTagApiResponseObject[["id"]] <- AllofTagApiResponseObject[["id"]] <-
@ -92,7 +117,7 @@ AllofTagApiResponse <- R6::R6Class(
AllofTagApiResponseObject[["message"]] <- AllofTagApiResponseObject[["message"]] <-
self$`message` self$`message`
} }
AllofTagApiResponseObject return(AllofTagApiResponseObject)
}, },
#' @description #' @description
@ -122,53 +147,13 @@ AllofTagApiResponse <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return AllofTagApiResponse in JSON format #' @return AllofTagApiResponse in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`id`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`name`)) {
sprintf(
'"name":
"%s"
',
self$`name`
)
},
if (!is.null(self$`code`)) {
sprintf(
'"code":
%d
',
self$`code`
)
},
if (!is.null(self$`type`)) {
sprintf(
'"type":
"%s"
',
self$`type`
)
},
if (!is.null(self$`message`)) {
sprintf(
'"message":
"%s"
',
self$`message`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -42,10 +42,35 @@ Animal <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Animal in JSON format
toJSON = function() { 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 Animal as a base R list.
#' @examples
#' # convert array of Animal (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 Animal to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
AnimalObject <- list() AnimalObject <- list()
if (!is.null(self$`className`)) { if (!is.null(self$`className`)) {
AnimalObject[["className"]] <- AnimalObject[["className"]] <-
@ -55,7 +80,7 @@ Animal <- R6::R6Class(
AnimalObject[["color"]] <- AnimalObject[["color"]] <-
self$`color` self$`color`
} }
AnimalObject return(AnimalObject)
}, },
#' @description #' @description
@ -76,29 +101,13 @@ Animal <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Animal in JSON format #' @return Animal in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`className`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`color`)) {
sprintf(
'"color":
"%s"
',
self$`color`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -91,27 +91,32 @@ AnyOfPig <- R6::R6Class(
}, },
#' @description #' @description
#' Serialize AnyOfPig to JSON string. #' 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 AnyOfPig to a base R type
#' #'
#' @return JSON string representation of the AnyOfPig. #' @return A base R type, e.g. a list or numeric/character array.
toJSONString = function() { toSimpleType = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
as.character(jsonlite::minify((self$actual_instance$toJSONString()))) return(self$actual_instance$toSimpleType())
} else { } else {
NULL NULL
} }
}, },
#' @description #' @description
#' Serialize AnyOfPig to JSON. #' Serialize AnyOfPig to JSON string.
#' #'
#' @return JSON representation of the AnyOfPig. #' @param ... Parameters passed to `jsonlite::toJSON`
toJSON = function() { #' @return JSON string representation of the AnyOfPig.
if (!is.null(self$actual_instance)) { toJSONString = function(...) {
self$actual_instance$toJSON() json <- jsonlite::toJSON(self$toSimpleType(), auto_unbox = TRUE, ...)
} else { return(as.character(jsonlite::minify(json)))
NULL
}
}, },
#' @description #' @description

View File

@ -111,25 +111,35 @@ AnyOfPrimitiveTypeTest <- R6::R6Class(
#' @description #' @description
#' Serialize AnyOfPrimitiveTypeTest to JSON string. #' Serialize AnyOfPrimitiveTypeTest to JSON string.
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return JSON string representation of the AnyOfPrimitiveTypeTest. #' @return JSON string representation of the AnyOfPrimitiveTypeTest.
toJSONString = function() { toJSONString = function(...) {
simple <- self$toSimpleType()
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
as.character(jsonlite::minify(self$actual_instance$toJSONString())) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, ...)
return(as.character(jsonlite::minify(json)))
} else { } else {
NULL return(NULL)
} }
}, },
#' @description #' @description
#' Serialize AnyOfPrimitiveTypeTest to JSON. #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return JSON representation of the AnyOfPrimitiveTypeTest.
toJSON = function() { 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 AnyOfPrimitiveTypeTest to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
self$actual_instance$toJSON() return(self$actual_instance$toSimpleType())
} else { } else {
NULL return(NULL)
} }
}, },

View File

@ -40,10 +40,35 @@ BasquePig <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return BasquePig in JSON format
toJSON = function() { 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 BasquePig as a base R list.
#' @examples
#' # convert array of BasquePig (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 BasquePig to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
BasquePigObject <- list() BasquePigObject <- list()
if (!is.null(self$`className`)) { if (!is.null(self$`className`)) {
BasquePigObject[["className"]] <- BasquePigObject[["className"]] <-
@ -53,7 +78,7 @@ BasquePig <- R6::R6Class(
BasquePigObject[["color"]] <- BasquePigObject[["color"]] <-
self$`color` self$`color`
} }
BasquePigObject return(BasquePigObject)
}, },
#' @description #' @description
@ -74,29 +99,13 @@ BasquePig <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return BasquePig in JSON format #' @return BasquePig in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`className`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`color`)) {
sprintf(
'"color":
"%s"
',
self$`color`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -50,10 +50,35 @@ Cat <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Cat in JSON format
toJSON = function() { 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 Cat as a base R list.
#' @examples
#' # convert array of Cat (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 Cat to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
CatObject <- list() CatObject <- list()
if (!is.null(self$`className`)) { if (!is.null(self$`className`)) {
CatObject[["className"]] <- CatObject[["className"]] <-
@ -67,7 +92,7 @@ Cat <- R6::R6Class(
CatObject[["declawed"]] <- CatObject[["declawed"]] <-
self$`declawed` self$`declawed`
} }
CatObject return(CatObject)
}, },
#' @description #' @description
@ -91,37 +116,13 @@ Cat <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Cat in JSON format #' @return Cat in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`className`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`color`)) {
sprintf(
'"color":
"%s"
',
self$`color`
)
},
if (!is.null(self$`declawed`)) {
sprintf(
'"declawed":
%s
',
tolower(self$`declawed`)
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -40,10 +40,35 @@ Category <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Category in JSON format
toJSON = function() { 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() CategoryObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
CategoryObject[["id"]] <- CategoryObject[["id"]] <-
@ -53,7 +78,7 @@ Category <- R6::R6Class(
CategoryObject[["name"]] <- CategoryObject[["name"]] <-
self$`name` self$`name`
} }
CategoryObject return(CategoryObject)
}, },
#' @description #' @description
@ -74,29 +99,13 @@ Category <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Category in JSON format #' @return Category in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`id`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"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 = "")))
}, },
#' @description #' @description

View File

@ -40,10 +40,35 @@ DanishPig <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return DanishPig in JSON format
toJSON = function() { 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 DanishPig as a base R list.
#' @examples
#' # convert array of DanishPig (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 DanishPig to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
DanishPigObject <- list() DanishPigObject <- list()
if (!is.null(self$`className`)) { if (!is.null(self$`className`)) {
DanishPigObject[["className"]] <- DanishPigObject[["className"]] <-
@ -53,7 +78,7 @@ DanishPig <- R6::R6Class(
DanishPigObject[["size"]] <- DanishPigObject[["size"]] <-
self$`size` self$`size`
} }
DanishPigObject return(DanishPigObject)
}, },
#' @description #' @description
@ -74,29 +99,13 @@ DanishPig <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return DanishPig in JSON format #' @return DanishPig in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`className`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`size`)) {
sprintf(
'"size":
%d
',
self$`size`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -53,10 +53,35 @@ Date <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Date in JSON format
toJSON = function() { 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 Date as a base R list.
#' @examples
#' # convert array of Date (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 Date to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
DateObject <- list() DateObject <- list()
if (!is.null(self$`className`)) { if (!is.null(self$`className`)) {
DateObject[["className"]] <- DateObject[["className"]] <-
@ -70,7 +95,7 @@ Date <- R6::R6Class(
DateObject[["url_property"]] <- DateObject[["url_property"]] <-
self$`url_property` self$`url_property`
} }
DateObject return(DateObject)
}, },
#' @description #' @description
@ -98,37 +123,13 @@ Date <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Date in JSON format #' @return Date in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`className`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`percent`)) {
sprintf(
'"percent_description":
"%s"
',
self$`percent`
)
},
if (!is.null(self$`url_property`)) {
sprintf(
'"url_property":
"%s"
',
self$`url_property`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -50,10 +50,35 @@ Dog <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Dog in JSON format
toJSON = function() { 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 Dog as a base R list.
#' @examples
#' # convert array of Dog (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 Dog to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
DogObject <- list() DogObject <- list()
if (!is.null(self$`className`)) { if (!is.null(self$`className`)) {
DogObject[["className"]] <- DogObject[["className"]] <-
@ -67,7 +92,7 @@ Dog <- R6::R6Class(
DogObject[["breed"]] <- DogObject[["breed"]] <-
self$`breed` self$`breed`
} }
DogObject return(DogObject)
}, },
#' @description #' @description
@ -91,37 +116,13 @@ Dog <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Dog in JSON format #' @return Dog in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`className`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`color`)) {
sprintf(
'"color":
"%s"
',
self$`color`
)
},
if (!is.null(self$`breed`)) {
sprintf(
'"breed":
"%s"
',
self$`breed`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -225,7 +225,7 @@ FakeApi <- R6::R6Class(
if (!is.null(`pet`)) { if (!is.null(`pet`)) {
local_var_body <- `pet`$toJSONString() local_var_body <- `pet`$toJSONString()
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/fake/test_optional_body_parameter" local_var_url_path <- "/fake/test_optional_body_parameter"

View File

@ -148,10 +148,35 @@ FormatTest <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return FormatTest in JSON format
toJSON = function() { 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 FormatTest as a base R list.
#' @examples
#' # convert array of FormatTest (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 FormatTest to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
FormatTestObject <- list() FormatTestObject <- list()
if (!is.null(self$`integer`)) { if (!is.null(self$`integer`)) {
FormatTestObject[["integer"]] <- FormatTestObject[["integer"]] <-
@ -213,7 +238,7 @@ FormatTest <- R6::R6Class(
FormatTestObject[["pattern_with_digits_and_delimiter"]] <- FormatTestObject[["pattern_with_digits_and_delimiter"]] <-
self$`pattern_with_digits_and_delimiter` self$`pattern_with_digits_and_delimiter`
} }
FormatTestObject return(FormatTestObject)
}, },
#' @description #' @description
@ -273,133 +298,13 @@ FormatTest <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return FormatTest in JSON format #' @return FormatTest in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`integer`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"integer":
%d
',
self$`integer`
)
},
if (!is.null(self$`int32`)) {
sprintf(
'"int32":
%d
',
self$`int32`
)
},
if (!is.null(self$`int64`)) {
sprintf(
'"int64":
%d
',
self$`int64`
)
},
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`
)
},
if (!is.null(self$`string`)) {
sprintf(
'"string":
"%s"
',
self$`string`
)
},
if (!is.null(self$`byte`)) {
sprintf(
'"byte":
"%s"
',
self$`byte`
)
},
if (!is.null(self$`binary`)) {
sprintf(
'"binary":
"%s"
',
self$`binary`
)
},
if (!is.null(self$`date`)) {
sprintf(
'"date":
"%s"
',
self$`date`
)
},
if (!is.null(self$`dateTime`)) {
sprintf(
'"dateTime":
"%s"
',
self$`dateTime`
)
},
if (!is.null(self$`uuid`)) {
sprintf(
'"uuid":
"%s"
',
self$`uuid`
)
},
if (!is.null(self$`password`)) {
sprintf(
'"password":
"%s"
',
self$`password`
)
},
if (!is.null(self$`pattern_with_digits`)) {
sprintf(
'"pattern_with_digits":
"%s"
',
self$`pattern_with_digits`
)
},
if (!is.null(self$`pattern_with_digits_and_delimiter`)) {
sprintf(
'"pattern_with_digits_and_delimiter":
"%s"
',
self$`pattern_with_digits_and_delimiter`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -31,16 +31,41 @@ JustModel <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return JustModel in JSON format
toJSON = function() { 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 JustModel as a base R list.
#' @examples
#' # convert array of JustModel (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 JustModel to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
JustModelObject <- list() JustModelObject <- list()
if (!is.null(self$`property`)) { if (!is.null(self$`property`)) {
JustModelObject[["property"]] <- JustModelObject[["property"]] <-
self$`property` self$`property`
} }
JustModelObject return(JustModelObject)
}, },
#' @description #' @description
@ -58,21 +83,13 @@ JustModel <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return JustModel in JSON format #' @return JustModel in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`property`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"property":
"%s"
',
self$`property`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -109,25 +109,35 @@ Mammal <- R6::R6Class(
#' @description #' @description
#' Serialize Mammal to JSON string. #' Serialize Mammal to JSON string.
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return JSON string representation of the Mammal. #' @return JSON string representation of the Mammal.
toJSONString = function() { toJSONString = function(...) {
simple <- self$toSimpleType()
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
as.character(jsonlite::minify(self$actual_instance$toJSONString())) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, ...)
return(as.character(jsonlite::minify(json)))
} else { } else {
NULL return(NULL)
} }
}, },
#' @description #' @description
#' Serialize Mammal to JSON. #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return JSON representation of the Mammal.
toJSON = function() { 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 Mammal to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
self$actual_instance$toJSON() return(self$actual_instance$toSimpleType())
} else { } else {
NULL return(NULL)
} }
}, },

View File

@ -49,10 +49,35 @@ ModelApiResponse <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return ModelApiResponse in JSON format
toJSON = function() { 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 ModelApiResponse as a base R list.
#' @examples
#' # convert array of ModelApiResponse (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 ModelApiResponse to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
ModelApiResponseObject <- list() ModelApiResponseObject <- list()
if (!is.null(self$`code`)) { if (!is.null(self$`code`)) {
ModelApiResponseObject[["code"]] <- ModelApiResponseObject[["code"]] <-
@ -66,7 +91,7 @@ ModelApiResponse <- R6::R6Class(
ModelApiResponseObject[["message"]] <- ModelApiResponseObject[["message"]] <-
self$`message` self$`message`
} }
ModelApiResponseObject return(ModelApiResponseObject)
}, },
#' @description #' @description
@ -90,37 +115,13 @@ ModelApiResponse <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return ModelApiResponse in JSON format #' @return ModelApiResponse in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`code`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"code":
%d
',
self$`code`
)
},
if (!is.null(self$`type`)) {
sprintf(
'"type":
"%s"
',
self$`type`
)
},
if (!is.null(self$`message`)) {
sprintf(
'"message":
"%s"
',
self$`message`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -38,10 +38,35 @@ NestedOneOf <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return NestedOneOf in JSON format
toJSON = function() { 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 NestedOneOf as a base R list.
#' @examples
#' # convert array of NestedOneOf (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 NestedOneOf to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
NestedOneOfObject <- list() NestedOneOfObject <- list()
if (!is.null(self$`size`)) { if (!is.null(self$`size`)) {
NestedOneOfObject[["size"]] <- NestedOneOfObject[["size"]] <-
@ -49,9 +74,9 @@ NestedOneOf <- R6::R6Class(
} }
if (!is.null(self$`nested_pig`)) { if (!is.null(self$`nested_pig`)) {
NestedOneOfObject[["nested_pig"]] <- NestedOneOfObject[["nested_pig"]] <-
self$`nested_pig`$toJSON() self$`nested_pig`$toSimpleType()
} }
NestedOneOfObject return(NestedOneOfObject)
}, },
#' @description #' @description
@ -74,29 +99,13 @@ NestedOneOf <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return NestedOneOf in JSON format #' @return NestedOneOf in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`size`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"size":
%d
',
self$`size`
)
},
if (!is.null(self$`nested_pig`)) {
sprintf(
'"nested_pig":
%s
',
jsonlite::toJSON(self$`nested_pig`$toJSON(), auto_unbox = TRUE, digits = NA)
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -111,25 +111,35 @@ OneOfPrimitiveTypeTest <- R6::R6Class(
#' @description #' @description
#' Serialize OneOfPrimitiveTypeTest to JSON string. #' Serialize OneOfPrimitiveTypeTest to JSON string.
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return JSON string representation of the OneOfPrimitiveTypeTest. #' @return JSON string representation of the OneOfPrimitiveTypeTest.
toJSONString = function() { toJSONString = function(...) {
simple <- self$toSimpleType()
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
as.character(jsonlite::minify(self$actual_instance$toJSONString())) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, ...)
return(as.character(jsonlite::minify(json)))
} else { } else {
NULL return(NULL)
} }
}, },
#' @description #' @description
#' Serialize OneOfPrimitiveTypeTest to JSON. #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return JSON representation of the OneOfPrimitiveTypeTest.
toJSON = function() { 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 OneOfPrimitiveTypeTest to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
self$actual_instance$toJSON() return(self$actual_instance$toSimpleType())
} else { } else {
NULL return(NULL)
} }
}, },

View File

@ -79,10 +79,35 @@ Order <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Order in JSON format
toJSON = function() { 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 Order as a base R list.
#' @examples
#' # convert array of Order (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 Order to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
OrderObject <- list() OrderObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
OrderObject[["id"]] <- OrderObject[["id"]] <-
@ -108,7 +133,7 @@ Order <- R6::R6Class(
OrderObject[["complete"]] <- OrderObject[["complete"]] <-
self$`complete` self$`complete`
} }
OrderObject return(OrderObject)
}, },
#' @description #' @description
@ -144,61 +169,13 @@ Order <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Order in JSON format #' @return Order in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`id`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`petId`)) {
sprintf(
'"petId":
%d
',
self$`petId`
)
},
if (!is.null(self$`quantity`)) {
sprintf(
'"quantity":
%d
',
self$`quantity`
)
},
if (!is.null(self$`shipDate`)) {
sprintf(
'"shipDate":
"%s"
',
self$`shipDate`
)
},
if (!is.null(self$`status`)) {
sprintf(
'"status":
"%s"
',
self$`status`
)
},
if (!is.null(self$`complete`)) {
sprintf(
'"complete":
%s
',
tolower(self$`complete`)
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -75,10 +75,35 @@ Pet <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Pet in JSON format
toJSON = function() { 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() PetObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
PetObject[["id"]] <- PetObject[["id"]] <-
@ -86,7 +111,7 @@ Pet <- R6::R6Class(
} }
if (!is.null(self$`category`)) { if (!is.null(self$`category`)) {
PetObject[["category"]] <- PetObject[["category"]] <-
self$`category`$toJSON() self$`category`$toSimpleType()
} }
if (!is.null(self$`name`)) { if (!is.null(self$`name`)) {
PetObject[["name"]] <- PetObject[["name"]] <-
@ -98,13 +123,13 @@ Pet <- R6::R6Class(
} }
if (!is.null(self$`tags`)) { if (!is.null(self$`tags`)) {
PetObject[["tags"]] <- PetObject[["tags"]] <-
lapply(self$`tags`, function(x) x$toJSON()) lapply(self$`tags`, function(x) x$toSimpleType())
} }
if (!is.null(self$`status`)) { if (!is.null(self$`status`)) {
PetObject[["status"]] <- PetObject[["status"]] <-
self$`status` self$`status`
} }
PetObject return(PetObject)
}, },
#' @description #' @description
@ -142,61 +167,13 @@ Pet <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Pet in JSON format #' @return Pet in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`id`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`category`)) {
sprintf(
'"category":
%s
',
jsonlite::toJSON(self$`category`$toJSON(), auto_unbox = TRUE, digits = NA)
)
},
if (!is.null(self$`name`)) {
sprintf(
'"name":
"%s"
',
self$`name`
)
},
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 = "")))
}, },
#' @description #' @description

View File

@ -435,7 +435,7 @@ PetApi <- R6::R6Class(
if (!is.null(`pet`)) { if (!is.null(`pet`)) {
local_var_body <- `pet`$toJSONString() local_var_body <- `pet`$toJSONString()
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/pet" local_var_url_path <- "/pet"
@ -1288,7 +1288,7 @@ PetApi <- R6::R6Class(
if (!is.null(`pet`)) { if (!is.null(`pet`)) {
local_var_body <- `pet`$toJSONString() local_var_body <- `pet`$toJSONString()
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/pet" local_var_url_path <- "/pet"

View File

@ -30,16 +30,41 @@ PetMap <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return PetMap in JSON format
toJSON = function() { 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 PetMap as a base R list.
#' @examples
#' # convert array of PetMap (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 PetMap to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
PetMapObject <- list() PetMapObject <- list()
if (!is.null(self$`pet`)) { if (!is.null(self$`pet`)) {
PetMapObject[["pet"]] <- PetMapObject[["pet"]] <-
self$`pet` self$`pet`
} }
PetMapObject return(PetMapObject)
}, },
#' @description #' @description
@ -57,21 +82,13 @@ PetMap <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return PetMap in JSON format #' @return PetMap in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`pet`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"pet":
%s
',
jsonlite::toJSON(lapply(self$`pet`, function(x){ x }), auto_unbox = TRUE, digits = NA)
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -109,25 +109,35 @@ Pig <- R6::R6Class(
#' @description #' @description
#' Serialize Pig to JSON string. #' Serialize Pig to JSON string.
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return JSON string representation of the Pig. #' @return JSON string representation of the Pig.
toJSONString = function() { toJSONString = function(...) {
simple <- self$toSimpleType()
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
as.character(jsonlite::minify(self$actual_instance$toJSONString())) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, ...)
return(as.character(jsonlite::minify(json)))
} else { } else {
NULL return(NULL)
} }
}, },
#' @description #' @description
#' Serialize Pig to JSON. #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return JSON representation of the Pig.
toJSON = function() { 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 Pig to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
self$actual_instance$toJSON() return(self$actual_instance$toSimpleType())
} else { } else {
NULL return(NULL)
} }
}, },

View File

@ -87,10 +87,35 @@ Special <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Special in JSON format
toJSON = function() { 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 Special as a base R list.
#' @examples
#' # convert array of Special (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 Special to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
SpecialObject <- list() SpecialObject <- list()
if (!is.null(self$`set_test`)) { if (!is.null(self$`set_test`)) {
SpecialObject[["set_test"]] <- SpecialObject[["set_test"]] <-
@ -120,7 +145,7 @@ Special <- R6::R6Class(
SpecialObject[["empty_string"]] <- SpecialObject[["empty_string"]] <-
self$`empty_string` self$`empty_string`
} }
SpecialObject return(SpecialObject)
}, },
#' @description #' @description
@ -159,69 +184,13 @@ Special <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Special in JSON format #' @return Special in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`set_test`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"set_test":
[%s]
',
paste(unlist(lapply(self$`set_test`, function(x) paste0('"', x, '"'))), collapse = ",")
)
},
if (!is.null(self$`item_self`)) {
sprintf(
'"self":
%d
',
self$`item_self`
)
},
if (!is.null(self$`item_private`)) {
sprintf(
'"private":
"%s"
',
self$`item_private`
)
},
if (!is.null(self$`item_super`)) {
sprintf(
'"super":
"%s"
',
self$`item_super`
)
},
if (!is.null(self$`123_number`)) {
sprintf(
'"123_number":
"%s"
',
self$`123_number`
)
},
if (!is.null(self$`array[test]`)) {
sprintf(
'"array[test]":
"%s"
',
self$`array[test]`
)
},
if (!is.null(self$`empty_string`)) {
sprintf(
'"empty_string":
"%s"
',
self$`empty_string`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -546,7 +546,7 @@ StoreApi <- R6::R6Class(
if (!is.null(`order`)) { if (!is.null(`order`)) {
local_var_body <- `order`$toJSONString() local_var_body <- `order`$toJSONString()
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/store/order" local_var_url_path <- "/store/order"

View File

@ -40,10 +40,35 @@ Tag <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Tag in JSON format
toJSON = function() { 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() TagObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
TagObject[["id"]] <- TagObject[["id"]] <-
@ -53,7 +78,7 @@ Tag <- R6::R6Class(
TagObject[["name"]] <- TagObject[["name"]] <-
self$`name` self$`name`
} }
TagObject return(TagObject)
}, },
#' @description #' @description
@ -74,29 +99,13 @@ Tag <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Tag in JSON format #' @return Tag in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`id`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"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 = "")))
}, },
#' @description #' @description

View File

@ -35,20 +35,45 @@ UpdatePetRequest <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return UpdatePetRequest in JSON format
toJSON = function() { 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 UpdatePetRequest as a base R list.
#' @examples
#' # convert array of UpdatePetRequest (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 UpdatePetRequest to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
UpdatePetRequestObject <- list() UpdatePetRequestObject <- list()
if (!is.null(self$`jsonData`)) { if (!is.null(self$`jsonData`)) {
UpdatePetRequestObject[["jsonData"]] <- UpdatePetRequestObject[["jsonData"]] <-
self$`jsonData`$toJSON() self$`jsonData`$toSimpleType()
} }
if (!is.null(self$`binaryDataN2Information`)) { if (!is.null(self$`binaryDataN2Information`)) {
UpdatePetRequestObject[["binaryDataN2Information"]] <- UpdatePetRequestObject[["binaryDataN2Information"]] <-
self$`binaryDataN2Information` self$`binaryDataN2Information`
} }
UpdatePetRequestObject return(UpdatePetRequestObject)
}, },
#' @description #' @description
@ -71,29 +96,13 @@ UpdatePetRequest <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return UpdatePetRequest in JSON format #' @return UpdatePetRequest in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`jsonData`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"jsonData":
%s
',
jsonlite::toJSON(self$`jsonData`$toJSON(), auto_unbox = TRUE, digits = NA)
)
},
if (!is.null(self$`binaryDataN2Information`)) {
sprintf(
'"binaryDataN2Information":
"%s"
',
self$`binaryDataN2Information`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -94,10 +94,35 @@ User <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return User in JSON format
toJSON = function() { 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 User as a base R list.
#' @examples
#' # convert array of User (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 User to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
UserObject <- list() UserObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
UserObject[["id"]] <- UserObject[["id"]] <-
@ -131,7 +156,7 @@ User <- R6::R6Class(
UserObject[["userStatus"]] <- UserObject[["userStatus"]] <-
self$`userStatus` self$`userStatus`
} }
UserObject return(UserObject)
}, },
#' @description #' @description
@ -170,77 +195,13 @@ User <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return User in JSON format #' @return User in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`id`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`username`)) {
sprintf(
'"username":
"%s"
',
self$`username`
)
},
if (!is.null(self$`firstName`)) {
sprintf(
'"firstName":
"%s"
',
self$`firstName`
)
},
if (!is.null(self$`lastName`)) {
sprintf(
'"lastName":
"%s"
',
self$`lastName`
)
},
if (!is.null(self$`email`)) {
sprintf(
'"email":
"%s"
',
self$`email`
)
},
if (!is.null(self$`password`)) {
sprintf(
'"password":
"%s"
',
self$`password`
)
},
if (!is.null(self$`phone`)) {
sprintf(
'"phone":
"%s"
',
self$`phone`
)
},
if (!is.null(self$`userStatus`)) {
sprintf(
'"userStatus":
%d
',
self$`userStatus`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -318,7 +318,7 @@ UserApi <- R6::R6Class(
if (!is.null(`user`)) { if (!is.null(`user`)) {
local_var_body <- `user`$toJSONString() local_var_body <- `user`$toJSONString()
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/user" local_var_url_path <- "/user"
@ -428,7 +428,7 @@ UserApi <- R6::R6Class(
})), collapse = ",") })), collapse = ",")
local_var_body <- paste0("[", body.items, "]") local_var_body <- paste0("[", body.items, "]")
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/user/createWithArray" local_var_url_path <- "/user/createWithArray"
@ -538,7 +538,7 @@ UserApi <- R6::R6Class(
})), collapse = ",") })), collapse = ",")
local_var_body <- paste0("[", body.items, "]") local_var_body <- paste0("[", body.items, "]")
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/user/createWithList" local_var_url_path <- "/user/createWithList"
@ -1099,7 +1099,7 @@ UserApi <- R6::R6Class(
if (!is.null(`user`)) { if (!is.null(`user`)) {
local_var_body <- `user`$toJSONString() local_var_body <- `user`$toJSONString()
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/user/{username}" local_var_url_path <- "/user/{username}"

View File

@ -49,10 +49,35 @@ Whale <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Whale in JSON format
toJSON = function() { 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 Whale as a base R list.
#' @examples
#' # convert array of Whale (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 Whale to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
WhaleObject <- list() WhaleObject <- list()
if (!is.null(self$`hasBaleen`)) { if (!is.null(self$`hasBaleen`)) {
WhaleObject[["hasBaleen"]] <- WhaleObject[["hasBaleen"]] <-
@ -66,7 +91,7 @@ Whale <- R6::R6Class(
WhaleObject[["className"]] <- WhaleObject[["className"]] <-
self$`className` self$`className`
} }
WhaleObject return(WhaleObject)
}, },
#' @description #' @description
@ -90,37 +115,13 @@ Whale <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Whale in JSON format #' @return Whale in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`hasBaleen`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"hasBaleen":
%s
',
tolower(self$`hasBaleen`)
)
},
if (!is.null(self$`hasTeeth`)) {
sprintf(
'"hasTeeth":
%s
',
tolower(self$`hasTeeth`)
)
},
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -43,10 +43,35 @@ Zebra <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Zebra in JSON format
toJSON = function() { 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 Zebra as a base R list.
#' @examples
#' # convert array of Zebra (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 Zebra to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
ZebraObject <- list() ZebraObject <- list()
if (!is.null(self$`type`)) { if (!is.null(self$`type`)) {
ZebraObject[["type"]] <- ZebraObject[["type"]] <-
@ -56,7 +81,7 @@ Zebra <- R6::R6Class(
ZebraObject[["className"]] <- ZebraObject[["className"]] <-
self$`className` self$`className`
} }
ZebraObject return(ZebraObject)
}, },
#' @description #' @description
@ -80,29 +105,13 @@ Zebra <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Zebra in JSON format #' @return Zebra in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`type`)) { json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
sprintf( return(as.character(jsonlite::minify(json)))
'"type":
"%s"
',
self$`type`
)
},
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
}, },
#' @description #' @description

View File

@ -23,7 +23,7 @@ test_that("Test toJSON toJSONString fromJSON fromJSONString", {
# tests for other pet objects # tests for other pet objects
pet0 <- Pet$new() pet0 <- Pet$new()
jsonpet <- pet0$toJSON() jsonpet <- pet0$toSimpleType()
pet2 <- pet0$fromJSON( pet2 <- pet0$fromJSON(
jsonlite::toJSON(jsonpet, auto_unbox = TRUE) jsonlite::toJSON(jsonpet, auto_unbox = TRUE)
) )
@ -49,7 +49,7 @@ test_that("Test toJSON toJSONString fromJSON fromJSONString", {
), ),
status = "available" status = "available"
) )
jsonpet <- pet1$toJSON() jsonpet <- pet1$toSimpleType()
pet2 <- pet1$fromJSON( pet2 <- pet1$fromJSON(
jsonlite::toJSON(jsonpet, auto_unbox = TRUE) jsonlite::toJSON(jsonpet, auto_unbox = TRUE)
) )
@ -71,7 +71,7 @@ test_that("Test toJSON toJSONString fromJSON fromJSONString", {
test_that("Test Category", { test_that("Test Category", {
c1 <- Category$new(id = 450, name = "test_cat") c1 <- Category$new(id = 450, name = "test_cat")
c2 <- Category$new() c2 <- Category$new()
c2$fromJSON(jsonlite::toJSON(c1$toJSON(), auto_unbox = TRUE)) c2$fromJSON(jsonlite::toJSON(c1$toSimpleType(), auto_unbox = TRUE))
expect_equal(c1, c2) expect_equal(c1, c2)
c2$fromJSONString(c1$toJSONString()) c2$fromJSONString(c1$toJSONString())
expect_equal(c1, c2) expect_equal(c1, c2)

View File

@ -77,10 +77,35 @@ AllofTagApiResponse <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return AllofTagApiResponse in JSON format
toJSON = function() { 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 AllofTagApiResponse as a base R list.
#' @examples
#' # convert array of AllofTagApiResponse (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 AllofTagApiResponse to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
AllofTagApiResponseObject <- list() AllofTagApiResponseObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
AllofTagApiResponseObject[["id"]] <- AllofTagApiResponseObject[["id"]] <-
@ -106,7 +131,7 @@ AllofTagApiResponse <- R6::R6Class(
AllofTagApiResponseObject[[key]] <- self$additional_properties[[key]] AllofTagApiResponseObject[[key]] <- self$additional_properties[[key]]
} }
AllofTagApiResponseObject return(AllofTagApiResponseObject)
}, },
#' @description #' @description
@ -143,58 +168,16 @@ AllofTagApiResponse <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return AllofTagApiResponse in JSON format #' @return AllofTagApiResponse in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`name`)) {
sprintf(
'"name":
"%s"
',
self$`name`
)
},
if (!is.null(self$`code`)) {
sprintf(
'"code":
%d
',
self$`code`
)
},
if (!is.null(self$`type`)) {
sprintf(
'"type":
"%s"
',
self$`type`
)
},
if (!is.null(self$`message`)) {
sprintf(
'"message":
"%s"
',
self$`message`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -52,10 +52,35 @@ Animal <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Animal in JSON format
toJSON = function() { 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 Animal as a base R list.
#' @examples
#' # convert array of Animal (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 Animal to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
AnimalObject <- list() AnimalObject <- list()
if (!is.null(self$`className`)) { if (!is.null(self$`className`)) {
AnimalObject[["className"]] <- AnimalObject[["className"]] <-
@ -69,7 +94,7 @@ Animal <- R6::R6Class(
AnimalObject[[key]] <- self$additional_properties[[key]] AnimalObject[[key]] <- self$additional_properties[[key]]
} }
AnimalObject return(AnimalObject)
}, },
#' @description #' @description
@ -97,34 +122,16 @@ Animal <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Animal in JSON format #' @return Animal in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`color`)) {
sprintf(
'"color":
"%s"
',
self$`color`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -91,27 +91,32 @@ AnyOfPig <- R6::R6Class(
}, },
#' @description #' @description
#' Serialize AnyOfPig to JSON string. #' 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 AnyOfPig to a base R type
#' #'
#' @return JSON string representation of the AnyOfPig. #' @return A base R type, e.g. a list or numeric/character array.
toJSONString = function() { toSimpleType = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
as.character(jsonlite::minify((self$actual_instance$toJSONString()))) return(self$actual_instance$toSimpleType())
} else { } else {
NULL NULL
} }
}, },
#' @description #' @description
#' Serialize AnyOfPig to JSON. #' Serialize AnyOfPig to JSON string.
#' #'
#' @return JSON representation of the AnyOfPig. #' @param ... Parameters passed to `jsonlite::toJSON`
toJSON = function() { #' @return JSON string representation of the AnyOfPig.
if (!is.null(self$actual_instance)) { toJSONString = function(...) {
self$actual_instance$toJSON() json <- jsonlite::toJSON(self$toSimpleType(), auto_unbox = TRUE, ...)
} else { return(as.character(jsonlite::minify(json)))
NULL
}
}, },
#' @description #' @description

View File

@ -111,25 +111,35 @@ AnyOfPrimitiveTypeTest <- R6::R6Class(
#' @description #' @description
#' Serialize AnyOfPrimitiveTypeTest to JSON string. #' Serialize AnyOfPrimitiveTypeTest to JSON string.
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return JSON string representation of the AnyOfPrimitiveTypeTest. #' @return JSON string representation of the AnyOfPrimitiveTypeTest.
toJSONString = function() { toJSONString = function(...) {
simple <- self$toSimpleType()
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
as.character(jsonlite::minify(self$actual_instance$toJSONString())) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, ...)
return(as.character(jsonlite::minify(json)))
} else { } else {
NULL return(NULL)
} }
}, },
#' @description #' @description
#' Serialize AnyOfPrimitiveTypeTest to JSON. #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return JSON representation of the AnyOfPrimitiveTypeTest.
toJSON = function() { 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 AnyOfPrimitiveTypeTest to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
self$actual_instance$toJSON() return(self$actual_instance$toSimpleType())
} else { } else {
NULL return(NULL)
} }
}, },

View File

@ -50,10 +50,35 @@ BasquePig <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return BasquePig in JSON format
toJSON = function() { 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 BasquePig as a base R list.
#' @examples
#' # convert array of BasquePig (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 BasquePig to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
BasquePigObject <- list() BasquePigObject <- list()
if (!is.null(self$`className`)) { if (!is.null(self$`className`)) {
BasquePigObject[["className"]] <- BasquePigObject[["className"]] <-
@ -67,7 +92,7 @@ BasquePig <- R6::R6Class(
BasquePigObject[[key]] <- self$additional_properties[[key]] BasquePigObject[[key]] <- self$additional_properties[[key]]
} }
BasquePigObject return(BasquePigObject)
}, },
#' @description #' @description
@ -95,34 +120,16 @@ BasquePig <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return BasquePig in JSON format #' @return BasquePig in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`color`)) {
sprintf(
'"color":
"%s"
',
self$`color`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -60,10 +60,35 @@ Cat <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Cat in JSON format
toJSON = function() { 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 Cat as a base R list.
#' @examples
#' # convert array of Cat (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 Cat to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
CatObject <- list() CatObject <- list()
if (!is.null(self$`className`)) { if (!is.null(self$`className`)) {
CatObject[["className"]] <- CatObject[["className"]] <-
@ -81,7 +106,7 @@ Cat <- R6::R6Class(
CatObject[[key]] <- self$additional_properties[[key]] CatObject[[key]] <- self$additional_properties[[key]]
} }
CatObject return(CatObject)
}, },
#' @description #' @description
@ -112,42 +137,16 @@ Cat <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Cat in JSON format #' @return Cat in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`color`)) {
sprintf(
'"color":
"%s"
',
self$`color`
)
},
if (!is.null(self$`declawed`)) {
sprintf(
'"declawed":
%s
',
tolower(self$`declawed`)
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -50,10 +50,35 @@ Category <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Category in JSON format
toJSON = function() { 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() CategoryObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
CategoryObject[["id"]] <- CategoryObject[["id"]] <-
@ -67,7 +92,7 @@ Category <- R6::R6Class(
CategoryObject[[key]] <- self$additional_properties[[key]] CategoryObject[[key]] <- self$additional_properties[[key]]
} }
CategoryObject return(CategoryObject)
}, },
#' @description #' @description
@ -95,34 +120,16 @@ Category <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Category in JSON format #' @return Category in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
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 = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -50,10 +50,35 @@ DanishPig <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return DanishPig in JSON format
toJSON = function() { 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 DanishPig as a base R list.
#' @examples
#' # convert array of DanishPig (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 DanishPig to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
DanishPigObject <- list() DanishPigObject <- list()
if (!is.null(self$`className`)) { if (!is.null(self$`className`)) {
DanishPigObject[["className"]] <- DanishPigObject[["className"]] <-
@ -67,7 +92,7 @@ DanishPig <- R6::R6Class(
DanishPigObject[[key]] <- self$additional_properties[[key]] DanishPigObject[[key]] <- self$additional_properties[[key]]
} }
DanishPigObject return(DanishPigObject)
}, },
#' @description #' @description
@ -95,34 +120,16 @@ DanishPig <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return DanishPig in JSON format #' @return DanishPig in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`size`)) {
sprintf(
'"size":
%d
',
self$`size`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -63,10 +63,35 @@ Date <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Date in JSON format
toJSON = function() { 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 Date as a base R list.
#' @examples
#' # convert array of Date (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 Date to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
DateObject <- list() DateObject <- list()
if (!is.null(self$`className`)) { if (!is.null(self$`className`)) {
DateObject[["className"]] <- DateObject[["className"]] <-
@ -84,7 +109,7 @@ Date <- R6::R6Class(
DateObject[[key]] <- self$additional_properties[[key]] DateObject[[key]] <- self$additional_properties[[key]]
} }
DateObject return(DateObject)
}, },
#' @description #' @description
@ -119,42 +144,16 @@ Date <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Date in JSON format #' @return Date in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`percent_description`)) {
sprintf(
'"percent_description":
"%s"
',
self$`percent_description`
)
},
if (!is.null(self$`url_property`)) {
sprintf(
'"url_property":
"%s"
',
self$`url_property`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -60,10 +60,35 @@ Dog <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Dog in JSON format
toJSON = function() { 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 Dog as a base R list.
#' @examples
#' # convert array of Dog (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 Dog to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
DogObject <- list() DogObject <- list()
if (!is.null(self$`className`)) { if (!is.null(self$`className`)) {
DogObject[["className"]] <- DogObject[["className"]] <-
@ -81,7 +106,7 @@ Dog <- R6::R6Class(
DogObject[[key]] <- self$additional_properties[[key]] DogObject[[key]] <- self$additional_properties[[key]]
} }
DogObject return(DogObject)
}, },
#' @description #' @description
@ -112,42 +137,16 @@ Dog <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Dog in JSON format #' @return Dog in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`color`)) {
sprintf(
'"color":
"%s"
',
self$`color`
)
},
if (!is.null(self$`breed`)) {
sprintf(
'"breed":
"%s"
',
self$`breed`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -41,10 +41,35 @@ DummyModel <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return DummyModel in JSON format
toJSON = function() { 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 DummyModel as a base R list.
#' @examples
#' # convert array of DummyModel (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 DummyModel to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
DummyModelObject <- list() DummyModelObject <- list()
if (!is.null(self$`property`)) { if (!is.null(self$`property`)) {
DummyModelObject[["property"]] <- DummyModelObject[["property"]] <-
@ -54,7 +79,7 @@ DummyModel <- R6::R6Class(
DummyModelObject[[key]] <- self$additional_properties[[key]] DummyModelObject[[key]] <- self$additional_properties[[key]]
} }
DummyModelObject return(DummyModelObject)
}, },
#' @description #' @description
@ -79,26 +104,16 @@ DummyModel <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return DummyModel in JSON format #' @return DummyModel in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`property`)) {
sprintf(
'"property":
"%s"
',
self$`property`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -225,7 +225,7 @@ FakeApi <- R6::R6Class(
if (!is.null(`pet`)) { if (!is.null(`pet`)) {
local_var_body <- `pet`$toJSONString() local_var_body <- `pet`$toJSONString()
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/fake/test_optional_body_parameter" local_var_url_path <- "/fake/test_optional_body_parameter"

View File

@ -158,10 +158,35 @@ FormatTest <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return FormatTest in JSON format
toJSON = function() { 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 FormatTest as a base R list.
#' @examples
#' # convert array of FormatTest (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 FormatTest to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
FormatTestObject <- list() FormatTestObject <- list()
if (!is.null(self$`integer`)) { if (!is.null(self$`integer`)) {
FormatTestObject[["integer"]] <- FormatTestObject[["integer"]] <-
@ -227,7 +252,7 @@ FormatTest <- R6::R6Class(
FormatTestObject[[key]] <- self$additional_properties[[key]] FormatTestObject[[key]] <- self$additional_properties[[key]]
} }
FormatTestObject return(FormatTestObject)
}, },
#' @description #' @description
@ -294,138 +319,16 @@ FormatTest <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return FormatTest in JSON format #' @return FormatTest in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`integer`)) {
sprintf(
'"integer":
%d
',
self$`integer`
)
},
if (!is.null(self$`int32`)) {
sprintf(
'"int32":
%d
',
self$`int32`
)
},
if (!is.null(self$`int64`)) {
sprintf(
'"int64":
%d
',
self$`int64`
)
},
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`
)
},
if (!is.null(self$`string`)) {
sprintf(
'"string":
"%s"
',
self$`string`
)
},
if (!is.null(self$`byte`)) {
sprintf(
'"byte":
"%s"
',
self$`byte`
)
},
if (!is.null(self$`binary`)) {
sprintf(
'"binary":
"%s"
',
self$`binary`
)
},
if (!is.null(self$`date`)) {
sprintf(
'"date":
"%s"
',
self$`date`
)
},
if (!is.null(self$`dateTime`)) {
sprintf(
'"dateTime":
"%s"
',
self$`dateTime`
)
},
if (!is.null(self$`uuid`)) {
sprintf(
'"uuid":
"%s"
',
self$`uuid`
)
},
if (!is.null(self$`password`)) {
sprintf(
'"password":
"%s"
',
self$`password`
)
},
if (!is.null(self$`pattern_with_digits`)) {
sprintf(
'"pattern_with_digits":
"%s"
',
self$`pattern_with_digits`
)
},
if (!is.null(self$`pattern_with_digits_and_delimiter`)) {
sprintf(
'"pattern_with_digits_and_delimiter":
"%s"
',
self$`pattern_with_digits_and_delimiter`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -109,25 +109,35 @@ Mammal <- R6::R6Class(
#' @description #' @description
#' Serialize Mammal to JSON string. #' Serialize Mammal to JSON string.
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return JSON string representation of the Mammal. #' @return JSON string representation of the Mammal.
toJSONString = function() { toJSONString = function(...) {
simple <- self$toSimpleType()
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
as.character(jsonlite::minify(self$actual_instance$toJSONString())) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, ...)
return(as.character(jsonlite::minify(json)))
} else { } else {
NULL return(NULL)
} }
}, },
#' @description #' @description
#' Serialize Mammal to JSON. #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return JSON representation of the Mammal.
toJSON = function() { 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 Mammal to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
self$actual_instance$toJSON() return(self$actual_instance$toSimpleType())
} else { } else {
NULL return(NULL)
} }
}, },

View File

@ -59,10 +59,35 @@ ModelApiResponse <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return ModelApiResponse in JSON format
toJSON = function() { 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 ModelApiResponse as a base R list.
#' @examples
#' # convert array of ModelApiResponse (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 ModelApiResponse to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
ModelApiResponseObject <- list() ModelApiResponseObject <- list()
if (!is.null(self$`code`)) { if (!is.null(self$`code`)) {
ModelApiResponseObject[["code"]] <- ModelApiResponseObject[["code"]] <-
@ -80,7 +105,7 @@ ModelApiResponse <- R6::R6Class(
ModelApiResponseObject[[key]] <- self$additional_properties[[key]] ModelApiResponseObject[[key]] <- self$additional_properties[[key]]
} }
ModelApiResponseObject return(ModelApiResponseObject)
}, },
#' @description #' @description
@ -111,42 +136,16 @@ ModelApiResponse <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return ModelApiResponse in JSON format #' @return ModelApiResponse in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`code`)) {
sprintf(
'"code":
%d
',
self$`code`
)
},
if (!is.null(self$`type`)) {
sprintf(
'"type":
"%s"
',
self$`type`
)
},
if (!is.null(self$`message`)) {
sprintf(
'"message":
"%s"
',
self$`message`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -48,10 +48,35 @@ NestedOneOf <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return NestedOneOf in JSON format
toJSON = function() { 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 NestedOneOf as a base R list.
#' @examples
#' # convert array of NestedOneOf (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 NestedOneOf to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
NestedOneOfObject <- list() NestedOneOfObject <- list()
if (!is.null(self$`size`)) { if (!is.null(self$`size`)) {
NestedOneOfObject[["size"]] <- NestedOneOfObject[["size"]] <-
@ -59,13 +84,13 @@ NestedOneOf <- R6::R6Class(
} }
if (!is.null(self$`nested_pig`)) { if (!is.null(self$`nested_pig`)) {
NestedOneOfObject[["nested_pig"]] <- NestedOneOfObject[["nested_pig"]] <-
self$`nested_pig`$toJSON() self$`nested_pig`$toSimpleType()
} }
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
NestedOneOfObject[[key]] <- self$additional_properties[[key]] NestedOneOfObject[[key]] <- self$additional_properties[[key]]
} }
NestedOneOfObject return(NestedOneOfObject)
}, },
#' @description #' @description
@ -95,34 +120,16 @@ NestedOneOf <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return NestedOneOf in JSON format #' @return NestedOneOf in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`size`)) {
sprintf(
'"size":
%d
',
self$`size`
)
},
if (!is.null(self$`nested_pig`)) {
sprintf(
'"nested_pig":
%s
',
jsonlite::toJSON(self$`nested_pig`$toJSON(), auto_unbox = TRUE, digits = NA)
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -111,25 +111,35 @@ OneOfPrimitiveTypeTest <- R6::R6Class(
#' @description #' @description
#' Serialize OneOfPrimitiveTypeTest to JSON string. #' Serialize OneOfPrimitiveTypeTest to JSON string.
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return JSON string representation of the OneOfPrimitiveTypeTest. #' @return JSON string representation of the OneOfPrimitiveTypeTest.
toJSONString = function() { toJSONString = function(...) {
simple <- self$toSimpleType()
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
as.character(jsonlite::minify(self$actual_instance$toJSONString())) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, ...)
return(as.character(jsonlite::minify(json)))
} else { } else {
NULL return(NULL)
} }
}, },
#' @description #' @description
#' Serialize OneOfPrimitiveTypeTest to JSON. #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return JSON representation of the OneOfPrimitiveTypeTest.
toJSON = function() { 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 OneOfPrimitiveTypeTest to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
self$actual_instance$toJSON() return(self$actual_instance$toSimpleType())
} else { } else {
NULL return(NULL)
} }
}, },

View File

@ -89,10 +89,35 @@ Order <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Order in JSON format
toJSON = function() { 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 Order as a base R list.
#' @examples
#' # convert array of Order (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 Order to a base R type
#'
#' @return A base R type, e.g. a list or numeric/character array.
toSimpleType = function() {
OrderObject <- list() OrderObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
OrderObject[["id"]] <- OrderObject[["id"]] <-
@ -122,7 +147,7 @@ Order <- R6::R6Class(
OrderObject[[key]] <- self$additional_properties[[key]] OrderObject[[key]] <- self$additional_properties[[key]]
} }
OrderObject return(OrderObject)
}, },
#' @description #' @description
@ -165,66 +190,16 @@ Order <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Order in JSON format #' @return Order in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`petId`)) {
sprintf(
'"petId":
%d
',
self$`petId`
)
},
if (!is.null(self$`quantity`)) {
sprintf(
'"quantity":
%d
',
self$`quantity`
)
},
if (!is.null(self$`shipDate`)) {
sprintf(
'"shipDate":
"%s"
',
self$`shipDate`
)
},
if (!is.null(self$`status`)) {
sprintf(
'"status":
"%s"
',
self$`status`
)
},
if (!is.null(self$`complete`)) {
sprintf(
'"complete":
%s
',
tolower(self$`complete`)
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -85,10 +85,35 @@ Pet <- R6::R6Class(
}, },
#' @description #' @description
#' To JSON String #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead.
#'
#' @return Pet in JSON format
toJSON = function() { 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() PetObject <- list()
if (!is.null(self$`id`)) { if (!is.null(self$`id`)) {
PetObject[["id"]] <- PetObject[["id"]] <-
@ -96,7 +121,7 @@ Pet <- R6::R6Class(
} }
if (!is.null(self$`category`)) { if (!is.null(self$`category`)) {
PetObject[["category"]] <- PetObject[["category"]] <-
self$`category`$toJSON() self$`category`$toSimpleType()
} }
if (!is.null(self$`name`)) { if (!is.null(self$`name`)) {
PetObject[["name"]] <- PetObject[["name"]] <-
@ -108,7 +133,7 @@ Pet <- R6::R6Class(
} }
if (!is.null(self$`tags`)) { if (!is.null(self$`tags`)) {
PetObject[["tags"]] <- PetObject[["tags"]] <-
lapply(self$`tags`, function(x) x$toJSON()) lapply(self$`tags`, function(x) x$toSimpleType())
} }
if (!is.null(self$`status`)) { if (!is.null(self$`status`)) {
PetObject[["status"]] <- PetObject[["status"]] <-
@ -118,7 +143,7 @@ Pet <- R6::R6Class(
PetObject[[key]] <- self$additional_properties[[key]] PetObject[[key]] <- self$additional_properties[[key]]
} }
PetObject return(PetObject)
}, },
#' @description #' @description
@ -163,66 +188,16 @@ Pet <- R6::R6Class(
#' @description #' @description
#' To JSON String #' To JSON String
#' #'
#' @param ... Parameters passed to `jsonlite::toJSON`
#' @return Pet in JSON format #' @return Pet in JSON format
toJSONString = function() { toJSONString = function(...) {
jsoncontent <- c( simple <- self$toSimpleType()
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`category`)) {
sprintf(
'"category":
%s
',
jsonlite::toJSON(self$`category`$toJSON(), auto_unbox = TRUE, digits = NA)
)
},
if (!is.null(self$`name`)) {
sprintf(
'"name":
"%s"
',
self$`name`
)
},
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 = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] simple[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, ...)
return(as.character(jsonlite::minify(json)))
}, },
#' @description #' @description

View File

@ -435,7 +435,7 @@ PetApi <- R6::R6Class(
if (!is.null(`pet`)) { if (!is.null(`pet`)) {
local_var_body <- `pet`$toJSONString() local_var_body <- `pet`$toJSONString()
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/pet" local_var_url_path <- "/pet"
@ -1288,7 +1288,7 @@ PetApi <- R6::R6Class(
if (!is.null(`pet`)) { if (!is.null(`pet`)) {
local_var_body <- `pet`$toJSONString() local_var_body <- `pet`$toJSONString()
} else { } else {
body <- NULL local_var_body <- NULL
} }
local_var_url_path <- "/pet" local_var_url_path <- "/pet"

Some files were not shown because too many files have changed in this diff Show More