From b6576d11733ecad6fa4a0a616e1a06d502a771b7 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Fri, 2 Sep 2022 09:46:56 +0800 Subject: [PATCH] [R] Update fromJSON to handle additional properties (#13331) * update fromJSON to handle additional properties * update RoxygenNote to newer version --- .../src/main/resources/r/description.mustache | 2 +- .../main/resources/r/modelGeneric.mustache | 26 ++++++++++++++++--- .../petstore/R-httr2-wrapper/DESCRIPTION | 2 +- .../R/allof_tag_api_response.R | 20 ++++++++++++-- .../petstore/R-httr2-wrapper/R/animal.R | 20 ++++++++++++-- .../petstore/R-httr2-wrapper/R/basque_pig.R | 20 ++++++++++++-- .../client/petstore/R-httr2-wrapper/R/cat.R | 20 ++++++++++++-- .../petstore/R-httr2-wrapper/R/cat_all_of.R | 20 ++++++++++++-- .../petstore/R-httr2-wrapper/R/category.R | 20 ++++++++++++-- .../petstore/R-httr2-wrapper/R/danish_pig.R | 20 ++++++++++++-- .../client/petstore/R-httr2-wrapper/R/dog.R | 20 ++++++++++++-- .../petstore/R-httr2-wrapper/R/dog_all_of.R | 20 ++++++++++++-- .../R-httr2-wrapper/R/model_api_response.R | 20 ++++++++++++-- .../R-httr2-wrapper/R/nested_one_of.R | 20 ++++++++++++-- .../client/petstore/R-httr2-wrapper/R/order.R | 22 +++++++++++++--- .../client/petstore/R-httr2-wrapper/R/pet.R | 22 +++++++++++++--- .../petstore/R-httr2-wrapper/R/special.R | 20 ++++++++++++-- .../client/petstore/R-httr2-wrapper/R/tag.R | 20 ++++++++++++-- .../R-httr2-wrapper/R/update_pet_request.R | 20 ++++++++++++-- .../client/petstore/R-httr2-wrapper/R/user.R | 22 +++++++++++++--- .../client/petstore/R-httr2-wrapper/R/whale.R | 20 ++++++++++++-- .../client/petstore/R-httr2-wrapper/R/zebra.R | 20 ++++++++++++-- .../tests/testthat/test_petstore.R | 9 +++++++ samples/client/petstore/R-httr2/DESCRIPTION | 2 +- samples/client/petstore/R-httr2/R/order.R | 2 +- samples/client/petstore/R-httr2/R/pet.R | 2 +- samples/client/petstore/R-httr2/R/user.R | 2 +- samples/client/petstore/R/DESCRIPTION | 2 +- .../petstore/R/R/allof_tag_api_response.R | 20 ++++++++++++-- samples/client/petstore/R/R/animal.R | 20 ++++++++++++-- samples/client/petstore/R/R/basque_pig.R | 20 ++++++++++++-- samples/client/petstore/R/R/cat.R | 20 ++++++++++++-- samples/client/petstore/R/R/cat_all_of.R | 20 ++++++++++++-- samples/client/petstore/R/R/category.R | 20 ++++++++++++-- samples/client/petstore/R/R/danish_pig.R | 20 ++++++++++++-- samples/client/petstore/R/R/dog.R | 20 ++++++++++++-- samples/client/petstore/R/R/dog_all_of.R | 20 ++++++++++++-- .../client/petstore/R/R/model_api_response.R | 20 ++++++++++++-- samples/client/petstore/R/R/nested_one_of.R | 20 ++++++++++++-- samples/client/petstore/R/R/order.R | 22 +++++++++++++--- samples/client/petstore/R/R/pet.R | 22 +++++++++++++--- samples/client/petstore/R/R/special.R | 20 ++++++++++++-- samples/client/petstore/R/R/tag.R | 20 ++++++++++++-- .../client/petstore/R/R/update_pet_request.R | 20 ++++++++++++-- samples/client/petstore/R/R/user.R | 22 +++++++++++++--- samples/client/petstore/R/R/whale.R | 20 ++++++++++++-- samples/client/petstore/R/R/zebra.R | 20 ++++++++++++-- 47 files changed, 729 insertions(+), 92 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/r/description.mustache b/modules/openapi-generator/src/main/resources/r/description.mustache index 2c4dd3bd68c..01721a459a6 100644 --- a/modules/openapi-generator/src/main/resources/r/description.mustache +++ b/modules/openapi-generator/src/main/resources/r/description.mustache @@ -12,4 +12,4 @@ License: {{#lambdaLicense}}{{licenseInfo}}{{/lambdaLicense}}{{^licenseInfo}}Unli LazyData: true Suggests: testthat Imports: jsonlite, httr{{#isHttr2}}2{{/isHttr2}}, R6, base64enc, stringr -RoxygenNote: 7.2.0 +RoxygenNote: 7.2.1 diff --git a/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache index 633578d049a..09561fb0503 100644 --- a/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache @@ -8,10 +8,11 @@ #' @description {{classname}} Class #' @format An \code{R6Class} generator object {{#vars}} -#' @field {{name}} {{title}} {{{vendorExtensions.x-r-doc-type}}}{{^required}} [optional]{{/required}} +#' @field {{name}} {{{description}}} {{{vendorExtensions.x-r-doc-type}}}{{^required}} [optional]{{/required}} {{/vars}} {{#isAdditionalPropertiesTrue}} -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] {{/isAdditionalPropertiesTrue}} #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON @@ -26,7 +27,8 @@ `{{{name}}}` = NULL, {{/vars}} {{#isAdditionalPropertiesTrue}} - `additional_properties` = NULL, + `_field_list` = c({{#vars}}"{{{name}}}"{{^-last}}, {{/-last}}{{/vars}}), + `additional_properties` = list(), {{/isAdditionalPropertiesTrue}} #' Initialize a new {{{classname}}} class. #' @@ -218,6 +220,15 @@ {{/isContainer}} } {{/vars}} + {{#isAdditionalPropertiesTrue}} + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + + {{/isAdditionalPropertiesTrue}} self }, #' To JSON string @@ -320,6 +331,15 @@ {{/isPrimitiveType}} {{/isContainer}} {{/vars}} + {{#isAdditionalPropertiesTrue}} + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + + {{/isAdditionalPropertiesTrue}} self }, #' Validate JSON input with respect to {{classname}} diff --git a/samples/client/petstore/R-httr2-wrapper/DESCRIPTION b/samples/client/petstore/R-httr2-wrapper/DESCRIPTION index f68d08ab84c..1cb6b5af889 100644 --- a/samples/client/petstore/R-httr2-wrapper/DESCRIPTION +++ b/samples/client/petstore/R-httr2-wrapper/DESCRIPTION @@ -12,4 +12,4 @@ License: Apache License 2.0 LazyData: true Suggests: testthat Imports: jsonlite, httr2, R6, base64enc, stringr -RoxygenNote: 7.2.0 +RoxygenNote: 7.2.1 diff --git a/samples/client/petstore/R-httr2-wrapper/R/allof_tag_api_response.R b/samples/client/petstore/R-httr2-wrapper/R/allof_tag_api_response.R index ee7d3df437d..6722a2f30d2 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/allof_tag_api_response.R +++ b/samples/client/petstore/R-httr2-wrapper/R/allof_tag_api_response.R @@ -12,7 +12,8 @@ #' @field code integer [optional] #' @field type character [optional] #' @field message character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -24,7 +25,8 @@ AllofTagApiResponse <- R6::R6Class( `code` = NULL, `type` = NULL, `message` = NULL, - `additional_properties` = NULL, + `_field_list` = c("id", "name", "code", "type", "message"), + `additional_properties` = list(), #' Initialize a new AllofTagApiResponse class. #' #' @description @@ -127,6 +129,13 @@ AllofTagApiResponse <- R6::R6Class( if (!is.null(this_object$`message`)) { self$`message` <- this_object$`message` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -202,6 +211,13 @@ AllofTagApiResponse <- R6::R6Class( self$`code` <- this_object$`code` self$`type` <- this_object$`type` self$`message` <- this_object$`message` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to AllofTagApiResponse diff --git a/samples/client/petstore/R-httr2-wrapper/R/animal.R b/samples/client/petstore/R-httr2-wrapper/R/animal.R index af3277925dc..17c49a82569 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/animal.R +++ b/samples/client/petstore/R-httr2-wrapper/R/animal.R @@ -9,7 +9,8 @@ #' @format An \code{R6Class} generator object #' @field className character #' @field color character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -18,7 +19,8 @@ Animal <- R6::R6Class( public = list( `className` = NULL, `color` = NULL, - `additional_properties` = NULL, + `_field_list` = c("className", "color"), + `additional_properties` = list(), #' Initialize a new Animal class. #' #' @description @@ -85,6 +87,13 @@ Animal <- R6::R6Class( if (!is.null(this_object$`color`)) { self$`color` <- this_object$`color` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -133,6 +142,13 @@ Animal <- R6::R6Class( this_object <- jsonlite::fromJSON(input_json) self$`className` <- this_object$`className` self$`color` <- this_object$`color` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Animal diff --git a/samples/client/petstore/R-httr2-wrapper/R/basque_pig.R b/samples/client/petstore/R-httr2-wrapper/R/basque_pig.R index 5533893c45e..a15bd94c659 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/basque_pig.R +++ b/samples/client/petstore/R-httr2-wrapper/R/basque_pig.R @@ -9,7 +9,8 @@ #' @format An \code{R6Class} generator object #' @field className character #' @field color character -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -18,7 +19,8 @@ BasquePig <- R6::R6Class( public = list( `className` = NULL, `color` = NULL, - `additional_properties` = NULL, + `_field_list` = c("className", "color"), + `additional_properties` = list(), #' Initialize a new BasquePig class. #' #' @description @@ -85,6 +87,13 @@ BasquePig <- R6::R6Class( if (!is.null(this_object$`color`)) { self$`color` <- this_object$`color` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -133,6 +142,13 @@ BasquePig <- R6::R6Class( this_object <- jsonlite::fromJSON(input_json) self$`className` <- this_object$`className` self$`color` <- this_object$`color` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to BasquePig diff --git a/samples/client/petstore/R-httr2-wrapper/R/cat.R b/samples/client/petstore/R-httr2-wrapper/R/cat.R index b029e1064fd..882eed5a9b7 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/cat.R +++ b/samples/client/petstore/R-httr2-wrapper/R/cat.R @@ -10,7 +10,8 @@ #' @field className character #' @field color character [optional] #' @field declawed character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -21,7 +22,8 @@ Cat <- R6::R6Class( `className` = NULL, `color` = NULL, `declawed` = NULL, - `additional_properties` = NULL, + `_field_list` = c("className", "color", "declawed"), + `additional_properties` = list(), #' Initialize a new Cat class. #' #' @description @@ -100,6 +102,13 @@ Cat <- R6::R6Class( if (!is.null(this_object$`declawed`)) { self$`declawed` <- this_object$`declawed` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -157,6 +166,13 @@ Cat <- R6::R6Class( self$`className` <- this_object$`className` self$`color` <- this_object$`color` self$`declawed` <- this_object$`declawed` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Cat diff --git a/samples/client/petstore/R-httr2-wrapper/R/cat_all_of.R b/samples/client/petstore/R-httr2-wrapper/R/cat_all_of.R index 24d913f89e0..2d77430810f 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/cat_all_of.R +++ b/samples/client/petstore/R-httr2-wrapper/R/cat_all_of.R @@ -8,7 +8,8 @@ #' @description CatAllOf Class #' @format An \code{R6Class} generator object #' @field declawed character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -16,7 +17,8 @@ CatAllOf <- R6::R6Class( "CatAllOf", public = list( `declawed` = NULL, - `additional_properties` = NULL, + `_field_list` = c("declawed"), + `additional_properties` = list(), #' Initialize a new CatAllOf class. #' #' @description @@ -71,6 +73,13 @@ CatAllOf <- R6::R6Class( if (!is.null(this_object$`declawed`)) { self$`declawed` <- this_object$`declawed` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -110,6 +119,13 @@ CatAllOf <- R6::R6Class( fromJSONString = function(input_json) { this_object <- jsonlite::fromJSON(input_json) self$`declawed` <- this_object$`declawed` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to CatAllOf diff --git a/samples/client/petstore/R-httr2-wrapper/R/category.R b/samples/client/petstore/R-httr2-wrapper/R/category.R index 95593d0cd7c..1e50799abeb 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/category.R +++ b/samples/client/petstore/R-httr2-wrapper/R/category.R @@ -9,7 +9,8 @@ #' @format An \code{R6Class} generator object #' @field id integer [optional] #' @field name character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -18,7 +19,8 @@ Category <- R6::R6Class( public = list( `id` = NULL, `name` = NULL, - `additional_properties` = NULL, + `_field_list` = c("id", "name"), + `additional_properties` = list(), #' Initialize a new Category class. #' #' @description @@ -85,6 +87,13 @@ Category <- R6::R6Class( if (!is.null(this_object$`name`)) { self$`name` <- this_object$`name` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -133,6 +142,13 @@ Category <- R6::R6Class( this_object <- jsonlite::fromJSON(input_json) self$`id` <- this_object$`id` self$`name` <- this_object$`name` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Category diff --git a/samples/client/petstore/R-httr2-wrapper/R/danish_pig.R b/samples/client/petstore/R-httr2-wrapper/R/danish_pig.R index 82407e0f46f..ae926fb8021 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/danish_pig.R +++ b/samples/client/petstore/R-httr2-wrapper/R/danish_pig.R @@ -9,7 +9,8 @@ #' @format An \code{R6Class} generator object #' @field className character #' @field size integer -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -18,7 +19,8 @@ DanishPig <- R6::R6Class( public = list( `className` = NULL, `size` = NULL, - `additional_properties` = NULL, + `_field_list` = c("className", "size"), + `additional_properties` = list(), #' Initialize a new DanishPig class. #' #' @description @@ -85,6 +87,13 @@ DanishPig <- R6::R6Class( if (!is.null(this_object$`size`)) { self$`size` <- this_object$`size` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -133,6 +142,13 @@ DanishPig <- R6::R6Class( this_object <- jsonlite::fromJSON(input_json) self$`className` <- this_object$`className` self$`size` <- this_object$`size` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to DanishPig diff --git a/samples/client/petstore/R-httr2-wrapper/R/dog.R b/samples/client/petstore/R-httr2-wrapper/R/dog.R index 6c651ed4ca4..25a7d14396a 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/dog.R +++ b/samples/client/petstore/R-httr2-wrapper/R/dog.R @@ -10,7 +10,8 @@ #' @field className character #' @field color character [optional] #' @field breed character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -21,7 +22,8 @@ Dog <- R6::R6Class( `className` = NULL, `color` = NULL, `breed` = NULL, - `additional_properties` = NULL, + `_field_list` = c("className", "color", "breed"), + `additional_properties` = list(), #' Initialize a new Dog class. #' #' @description @@ -100,6 +102,13 @@ Dog <- R6::R6Class( if (!is.null(this_object$`breed`)) { self$`breed` <- this_object$`breed` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -157,6 +166,13 @@ Dog <- R6::R6Class( self$`className` <- this_object$`className` self$`color` <- this_object$`color` self$`breed` <- this_object$`breed` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Dog diff --git a/samples/client/petstore/R-httr2-wrapper/R/dog_all_of.R b/samples/client/petstore/R-httr2-wrapper/R/dog_all_of.R index f566a558dde..8eb7912a406 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/dog_all_of.R +++ b/samples/client/petstore/R-httr2-wrapper/R/dog_all_of.R @@ -8,7 +8,8 @@ #' @description DogAllOf Class #' @format An \code{R6Class} generator object #' @field breed character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -16,7 +17,8 @@ DogAllOf <- R6::R6Class( "DogAllOf", public = list( `breed` = NULL, - `additional_properties` = NULL, + `_field_list` = c("breed"), + `additional_properties` = list(), #' Initialize a new DogAllOf class. #' #' @description @@ -71,6 +73,13 @@ DogAllOf <- R6::R6Class( if (!is.null(this_object$`breed`)) { self$`breed` <- this_object$`breed` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -110,6 +119,13 @@ DogAllOf <- R6::R6Class( fromJSONString = function(input_json) { this_object <- jsonlite::fromJSON(input_json) self$`breed` <- this_object$`breed` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to DogAllOf diff --git a/samples/client/petstore/R-httr2-wrapper/R/model_api_response.R b/samples/client/petstore/R-httr2-wrapper/R/model_api_response.R index a12add88cba..ed0f63e51b8 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/model_api_response.R +++ b/samples/client/petstore/R-httr2-wrapper/R/model_api_response.R @@ -10,7 +10,8 @@ #' @field code integer [optional] #' @field type character [optional] #' @field message character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -20,7 +21,8 @@ ModelApiResponse <- R6::R6Class( `code` = NULL, `type` = NULL, `message` = NULL, - `additional_properties` = NULL, + `_field_list` = c("code", "type", "message"), + `additional_properties` = list(), #' Initialize a new ModelApiResponse class. #' #' @description @@ -99,6 +101,13 @@ ModelApiResponse <- R6::R6Class( if (!is.null(this_object$`message`)) { self$`message` <- this_object$`message` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -156,6 +165,13 @@ ModelApiResponse <- R6::R6Class( self$`code` <- this_object$`code` self$`type` <- this_object$`type` self$`message` <- this_object$`message` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to ModelApiResponse diff --git a/samples/client/petstore/R-httr2-wrapper/R/nested_one_of.R b/samples/client/petstore/R-httr2-wrapper/R/nested_one_of.R index 01143c027a1..4aa8162d7eb 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/nested_one_of.R +++ b/samples/client/petstore/R-httr2-wrapper/R/nested_one_of.R @@ -9,7 +9,8 @@ #' @format An \code{R6Class} generator object #' @field size integer [optional] #' @field nested_pig \link{Pig} [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -18,7 +19,8 @@ NestedOneOf <- R6::R6Class( public = list( `size` = NULL, `nested_pig` = NULL, - `additional_properties` = NULL, + `_field_list` = c("size", "nested_pig"), + `additional_properties` = list(), #' Initialize a new NestedOneOf class. #' #' @description @@ -87,6 +89,13 @@ NestedOneOf <- R6::R6Class( nested_pig_object$fromJSON(jsonlite::toJSON(this_object$nested_pig, auto_unbox = TRUE, digits = NA)) self$`nested_pig` <- nested_pig_object } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -135,6 +144,13 @@ NestedOneOf <- R6::R6Class( this_object <- jsonlite::fromJSON(input_json) self$`size` <- this_object$`size` self$`nested_pig` <- Pig$new()$fromJSON(jsonlite::toJSON(this_object$nested_pig, auto_unbox = TRUE, digits = NA)) + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to NestedOneOf diff --git a/samples/client/petstore/R-httr2-wrapper/R/order.R b/samples/client/petstore/R-httr2-wrapper/R/order.R index b37f0763b07..706f12c60e5 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/order.R +++ b/samples/client/petstore/R-httr2-wrapper/R/order.R @@ -11,9 +11,10 @@ #' @field petId integer [optional] #' @field quantity integer [optional] #' @field shipDate character [optional] -#' @field status character [optional] +#' @field status Order Status character [optional] #' @field complete character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -26,7 +27,8 @@ Order <- R6::R6Class( `shipDate` = NULL, `status` = NULL, `complete` = NULL, - `additional_properties` = NULL, + `_field_list` = c("id", "petId", "quantity", "shipDate", "status", "complete"), + `additional_properties` = list(), #' Initialize a new Order class. #' #' @description @@ -141,6 +143,13 @@ Order <- R6::R6Class( if (!is.null(this_object$`complete`)) { self$`complete` <- this_object$`complete` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -225,6 +234,13 @@ Order <- R6::R6Class( self$`shipDate` <- this_object$`shipDate` self$`status` <- this_object$`status` self$`complete` <- this_object$`complete` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Order diff --git a/samples/client/petstore/R-httr2-wrapper/R/pet.R b/samples/client/petstore/R-httr2-wrapper/R/pet.R index 9dd8e7390d7..f6cb7a3d669 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/pet.R +++ b/samples/client/petstore/R-httr2-wrapper/R/pet.R @@ -12,8 +12,9 @@ #' @field name character #' @field photoUrls list(character) #' @field tags list(\link{Tag}) [optional] -#' @field status character [optional] -#' @field additional_properties named list(character) [optional] +#' @field status pet status in the store character [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -26,7 +27,8 @@ Pet <- R6::R6Class( `photoUrls` = NULL, `tags` = NULL, `status` = NULL, - `additional_properties` = NULL, + `_field_list` = c("id", "category", "name", "photoUrls", "tags", "status"), + `additional_properties` = list(), #' Initialize a new Pet class. #' #' @description @@ -145,6 +147,13 @@ Pet <- R6::R6Class( if (!is.null(this_object$`status`)) { self$`status` <- this_object$`status` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -229,6 +238,13 @@ Pet <- R6::R6Class( self$`photoUrls` <- ApiClient$new()$deserializeObj(this_object$`photoUrls`, "array[character]", loadNamespace("petstore")) self$`tags` <- ApiClient$new()$deserializeObj(this_object$`tags`, "array[Tag]", loadNamespace("petstore")) self$`status` <- this_object$`status` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Pet diff --git a/samples/client/petstore/R-httr2-wrapper/R/special.R b/samples/client/petstore/R-httr2-wrapper/R/special.R index 388300f0b47..6f6a2bee918 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/special.R +++ b/samples/client/petstore/R-httr2-wrapper/R/special.R @@ -13,7 +13,8 @@ #' @field 123_number character [optional] #' @field array[test] character [optional] #' @field empty_string character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -26,7 +27,8 @@ Special <- R6::R6Class( `123_number` = NULL, `array[test]` = NULL, `empty_string` = NULL, - `additional_properties` = NULL, + `_field_list` = c("item_self", "item_private", "item_super", "123_number", "array[test]", "empty_string"), + `additional_properties` = list(), #' Initialize a new Special class. #' #' @description @@ -141,6 +143,13 @@ Special <- R6::R6Class( if (!is.null(this_object$`empty_string`)) { self$`empty_string` <- this_object$`empty_string` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -225,6 +234,13 @@ Special <- R6::R6Class( self$`123_number` <- this_object$`123_number` self$`array[test]` <- this_object$`array[test]` self$`empty_string` <- this_object$`empty_string` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Special diff --git a/samples/client/petstore/R-httr2-wrapper/R/tag.R b/samples/client/petstore/R-httr2-wrapper/R/tag.R index 2475ccbdd88..639c14c4dd5 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/tag.R +++ b/samples/client/petstore/R-httr2-wrapper/R/tag.R @@ -9,7 +9,8 @@ #' @format An \code{R6Class} generator object #' @field id integer [optional] #' @field name character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -18,7 +19,8 @@ Tag <- R6::R6Class( public = list( `id` = NULL, `name` = NULL, - `additional_properties` = NULL, + `_field_list` = c("id", "name"), + `additional_properties` = list(), #' Initialize a new Tag class. #' #' @description @@ -85,6 +87,13 @@ Tag <- R6::R6Class( if (!is.null(this_object$`name`)) { self$`name` <- this_object$`name` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -133,6 +142,13 @@ Tag <- R6::R6Class( this_object <- jsonlite::fromJSON(input_json) self$`id` <- this_object$`id` self$`name` <- this_object$`name` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Tag diff --git a/samples/client/petstore/R-httr2-wrapper/R/update_pet_request.R b/samples/client/petstore/R-httr2-wrapper/R/update_pet_request.R index 6f0b39689fa..8e5d1689a4c 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/update_pet_request.R +++ b/samples/client/petstore/R-httr2-wrapper/R/update_pet_request.R @@ -9,7 +9,8 @@ #' @format An \code{R6Class} generator object #' @field jsonData \link{Pet} [optional] #' @field binaryDataN2Information data.frame [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -18,7 +19,8 @@ UpdatePetRequest <- R6::R6Class( public = list( `jsonData` = NULL, `binaryDataN2Information` = NULL, - `additional_properties` = NULL, + `_field_list` = c("jsonData", "binaryDataN2Information"), + `additional_properties` = list(), #' Initialize a new UpdatePetRequest class. #' #' @description @@ -86,6 +88,13 @@ UpdatePetRequest <- R6::R6Class( if (!is.null(this_object$`binaryDataN2Information`)) { self$`binaryDataN2Information` <- this_object$`binaryDataN2Information` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -134,6 +143,13 @@ UpdatePetRequest <- R6::R6Class( this_object <- jsonlite::fromJSON(input_json) self$`jsonData` <- Pet$new()$fromJSON(jsonlite::toJSON(this_object$jsonData, auto_unbox = TRUE, digits = NA)) self$`binaryDataN2Information` <- this_object$`binaryDataN2Information` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to UpdatePetRequest diff --git a/samples/client/petstore/R-httr2-wrapper/R/user.R b/samples/client/petstore/R-httr2-wrapper/R/user.R index bf4c323d5ce..1be67705420 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/user.R +++ b/samples/client/petstore/R-httr2-wrapper/R/user.R @@ -14,8 +14,9 @@ #' @field email character [optional] #' @field password character [optional] #' @field phone character [optional] -#' @field userStatus integer [optional] -#' @field additional_properties named list(character) [optional] +#' @field userStatus User Status integer [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -30,7 +31,8 @@ User <- R6::R6Class( `password` = NULL, `phone` = NULL, `userStatus` = NULL, - `additional_properties` = NULL, + `_field_list` = c("id", "username", "firstName", "lastName", "email", "password", "phone", "userStatus"), + `additional_properties` = list(), #' Initialize a new User class. #' #' @description @@ -169,6 +171,13 @@ User <- R6::R6Class( if (!is.null(this_object$`userStatus`)) { self$`userStatus` <- this_object$`userStatus` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -271,6 +280,13 @@ User <- R6::R6Class( self$`password` <- this_object$`password` self$`phone` <- this_object$`phone` self$`userStatus` <- this_object$`userStatus` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to User diff --git a/samples/client/petstore/R-httr2-wrapper/R/whale.R b/samples/client/petstore/R-httr2-wrapper/R/whale.R index 0e9b7f2dc8f..458f5d6f86c 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/whale.R +++ b/samples/client/petstore/R-httr2-wrapper/R/whale.R @@ -10,7 +10,8 @@ #' @field hasBaleen character [optional] #' @field hasTeeth character [optional] #' @field className character -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -20,7 +21,8 @@ Whale <- R6::R6Class( `hasBaleen` = NULL, `hasTeeth` = NULL, `className` = NULL, - `additional_properties` = NULL, + `_field_list` = c("hasBaleen", "hasTeeth", "className"), + `additional_properties` = list(), #' Initialize a new Whale class. #' #' @description @@ -99,6 +101,13 @@ Whale <- R6::R6Class( if (!is.null(this_object$`className`)) { self$`className` <- this_object$`className` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -156,6 +165,13 @@ Whale <- R6::R6Class( self$`hasBaleen` <- this_object$`hasBaleen` self$`hasTeeth` <- this_object$`hasTeeth` self$`className` <- this_object$`className` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Whale diff --git a/samples/client/petstore/R-httr2-wrapper/R/zebra.R b/samples/client/petstore/R-httr2-wrapper/R/zebra.R index aff7c8ddedc..4250d51d39c 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/zebra.R +++ b/samples/client/petstore/R-httr2-wrapper/R/zebra.R @@ -9,7 +9,8 @@ #' @format An \code{R6Class} generator object #' @field type character [optional] #' @field className character -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -18,7 +19,8 @@ Zebra <- R6::R6Class( public = list( `type` = NULL, `className` = NULL, - `additional_properties` = NULL, + `_field_list` = c("type", "className"), + `additional_properties` = list(), #' Initialize a new Zebra class. #' #' @description @@ -85,6 +87,13 @@ Zebra <- R6::R6Class( if (!is.null(this_object$`className`)) { self$`className` <- this_object$`className` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -133,6 +142,13 @@ Zebra <- R6::R6Class( this_object <- jsonlite::fromJSON(input_json) self$`type` <- this_object$`type` self$`className` <- this_object$`className` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Zebra diff --git a/samples/client/petstore/R-httr2-wrapper/tests/testthat/test_petstore.R b/samples/client/petstore/R-httr2-wrapper/tests/testthat/test_petstore.R index 92aecbfc262..6c052310d63 100644 --- a/samples/client/petstore/R-httr2-wrapper/tests/testthat/test_petstore.R +++ b/samples/client/petstore/R-httr2-wrapper/tests/testthat/test_petstore.R @@ -30,6 +30,15 @@ test_that("Additional Properties test", { # test tag with additional_properties in `new` t <- Tag$new(id = 393, name = "something", additional_properties = list("nested_object" = list("inside_item" = 8989))) expect_equal(t$toJSONString(), "{\"id\":393,\"name\":\"something\",\"nested_object\":{\"inside_item\":8989}}") + + # test fromJSONString + json <- "{\"id\":393,\"name\":\"something\",\"a1\":\"998\",\"b2\":\"bbccdd\"}" + t2 <- Tag$new() + t2$fromJSONString(json) + expect_equal(t2$id, 393) + expect_equal(t2$name, "something") + expect_equal(t2$additional_properties[["a1"]], "998") + expect_equal(t2$additional_properties[["b2"]], "bbccdd") }) test_that("Test toJSON toJSONString fromJSON fromJSONString print", { diff --git a/samples/client/petstore/R-httr2/DESCRIPTION b/samples/client/petstore/R-httr2/DESCRIPTION index f68d08ab84c..1cb6b5af889 100644 --- a/samples/client/petstore/R-httr2/DESCRIPTION +++ b/samples/client/petstore/R-httr2/DESCRIPTION @@ -12,4 +12,4 @@ License: Apache License 2.0 LazyData: true Suggests: testthat Imports: jsonlite, httr2, R6, base64enc, stringr -RoxygenNote: 7.2.0 +RoxygenNote: 7.2.1 diff --git a/samples/client/petstore/R-httr2/R/order.R b/samples/client/petstore/R-httr2/R/order.R index f4cfcae6ec2..0e12a88a70b 100644 --- a/samples/client/petstore/R-httr2/R/order.R +++ b/samples/client/petstore/R-httr2/R/order.R @@ -11,7 +11,7 @@ #' @field petId integer [optional] #' @field quantity integer [optional] #' @field shipDate character [optional] -#' @field status character [optional] +#' @field status Order Status character [optional] #' @field complete character [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON diff --git a/samples/client/petstore/R-httr2/R/pet.R b/samples/client/petstore/R-httr2/R/pet.R index e25c0052f55..1d16fed56f3 100644 --- a/samples/client/petstore/R-httr2/R/pet.R +++ b/samples/client/petstore/R-httr2/R/pet.R @@ -12,7 +12,7 @@ #' @field name character #' @field photoUrls list(character) #' @field tags list(\link{Tag}) [optional] -#' @field status character [optional] +#' @field status pet status in the store character [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export diff --git a/samples/client/petstore/R-httr2/R/user.R b/samples/client/petstore/R-httr2/R/user.R index 6a1eaf3d76d..96ac826498e 100644 --- a/samples/client/petstore/R-httr2/R/user.R +++ b/samples/client/petstore/R-httr2/R/user.R @@ -14,7 +14,7 @@ #' @field email character [optional] #' @field password character [optional] #' @field phone character [optional] -#' @field userStatus integer [optional] +#' @field userStatus User Status integer [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export diff --git a/samples/client/petstore/R/DESCRIPTION b/samples/client/petstore/R/DESCRIPTION index d8e1a4dfcde..ee2ebde9124 100644 --- a/samples/client/petstore/R/DESCRIPTION +++ b/samples/client/petstore/R/DESCRIPTION @@ -12,4 +12,4 @@ License: Apache License 2.0 LazyData: true Suggests: testthat Imports: jsonlite, httr, R6, base64enc, stringr -RoxygenNote: 7.2.0 +RoxygenNote: 7.2.1 diff --git a/samples/client/petstore/R/R/allof_tag_api_response.R b/samples/client/petstore/R/R/allof_tag_api_response.R index ee7d3df437d..6722a2f30d2 100644 --- a/samples/client/petstore/R/R/allof_tag_api_response.R +++ b/samples/client/petstore/R/R/allof_tag_api_response.R @@ -12,7 +12,8 @@ #' @field code integer [optional] #' @field type character [optional] #' @field message character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -24,7 +25,8 @@ AllofTagApiResponse <- R6::R6Class( `code` = NULL, `type` = NULL, `message` = NULL, - `additional_properties` = NULL, + `_field_list` = c("id", "name", "code", "type", "message"), + `additional_properties` = list(), #' Initialize a new AllofTagApiResponse class. #' #' @description @@ -127,6 +129,13 @@ AllofTagApiResponse <- R6::R6Class( if (!is.null(this_object$`message`)) { self$`message` <- this_object$`message` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -202,6 +211,13 @@ AllofTagApiResponse <- R6::R6Class( self$`code` <- this_object$`code` self$`type` <- this_object$`type` self$`message` <- this_object$`message` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to AllofTagApiResponse diff --git a/samples/client/petstore/R/R/animal.R b/samples/client/petstore/R/R/animal.R index af3277925dc..17c49a82569 100644 --- a/samples/client/petstore/R/R/animal.R +++ b/samples/client/petstore/R/R/animal.R @@ -9,7 +9,8 @@ #' @format An \code{R6Class} generator object #' @field className character #' @field color character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -18,7 +19,8 @@ Animal <- R6::R6Class( public = list( `className` = NULL, `color` = NULL, - `additional_properties` = NULL, + `_field_list` = c("className", "color"), + `additional_properties` = list(), #' Initialize a new Animal class. #' #' @description @@ -85,6 +87,13 @@ Animal <- R6::R6Class( if (!is.null(this_object$`color`)) { self$`color` <- this_object$`color` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -133,6 +142,13 @@ Animal <- R6::R6Class( this_object <- jsonlite::fromJSON(input_json) self$`className` <- this_object$`className` self$`color` <- this_object$`color` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Animal diff --git a/samples/client/petstore/R/R/basque_pig.R b/samples/client/petstore/R/R/basque_pig.R index 5533893c45e..a15bd94c659 100644 --- a/samples/client/petstore/R/R/basque_pig.R +++ b/samples/client/petstore/R/R/basque_pig.R @@ -9,7 +9,8 @@ #' @format An \code{R6Class} generator object #' @field className character #' @field color character -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -18,7 +19,8 @@ BasquePig <- R6::R6Class( public = list( `className` = NULL, `color` = NULL, - `additional_properties` = NULL, + `_field_list` = c("className", "color"), + `additional_properties` = list(), #' Initialize a new BasquePig class. #' #' @description @@ -85,6 +87,13 @@ BasquePig <- R6::R6Class( if (!is.null(this_object$`color`)) { self$`color` <- this_object$`color` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -133,6 +142,13 @@ BasquePig <- R6::R6Class( this_object <- jsonlite::fromJSON(input_json) self$`className` <- this_object$`className` self$`color` <- this_object$`color` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to BasquePig diff --git a/samples/client/petstore/R/R/cat.R b/samples/client/petstore/R/R/cat.R index b029e1064fd..882eed5a9b7 100644 --- a/samples/client/petstore/R/R/cat.R +++ b/samples/client/petstore/R/R/cat.R @@ -10,7 +10,8 @@ #' @field className character #' @field color character [optional] #' @field declawed character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -21,7 +22,8 @@ Cat <- R6::R6Class( `className` = NULL, `color` = NULL, `declawed` = NULL, - `additional_properties` = NULL, + `_field_list` = c("className", "color", "declawed"), + `additional_properties` = list(), #' Initialize a new Cat class. #' #' @description @@ -100,6 +102,13 @@ Cat <- R6::R6Class( if (!is.null(this_object$`declawed`)) { self$`declawed` <- this_object$`declawed` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -157,6 +166,13 @@ Cat <- R6::R6Class( self$`className` <- this_object$`className` self$`color` <- this_object$`color` self$`declawed` <- this_object$`declawed` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Cat diff --git a/samples/client/petstore/R/R/cat_all_of.R b/samples/client/petstore/R/R/cat_all_of.R index 24d913f89e0..2d77430810f 100644 --- a/samples/client/petstore/R/R/cat_all_of.R +++ b/samples/client/petstore/R/R/cat_all_of.R @@ -8,7 +8,8 @@ #' @description CatAllOf Class #' @format An \code{R6Class} generator object #' @field declawed character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -16,7 +17,8 @@ CatAllOf <- R6::R6Class( "CatAllOf", public = list( `declawed` = NULL, - `additional_properties` = NULL, + `_field_list` = c("declawed"), + `additional_properties` = list(), #' Initialize a new CatAllOf class. #' #' @description @@ -71,6 +73,13 @@ CatAllOf <- R6::R6Class( if (!is.null(this_object$`declawed`)) { self$`declawed` <- this_object$`declawed` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -110,6 +119,13 @@ CatAllOf <- R6::R6Class( fromJSONString = function(input_json) { this_object <- jsonlite::fromJSON(input_json) self$`declawed` <- this_object$`declawed` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to CatAllOf diff --git a/samples/client/petstore/R/R/category.R b/samples/client/petstore/R/R/category.R index 95593d0cd7c..1e50799abeb 100644 --- a/samples/client/petstore/R/R/category.R +++ b/samples/client/petstore/R/R/category.R @@ -9,7 +9,8 @@ #' @format An \code{R6Class} generator object #' @field id integer [optional] #' @field name character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -18,7 +19,8 @@ Category <- R6::R6Class( public = list( `id` = NULL, `name` = NULL, - `additional_properties` = NULL, + `_field_list` = c("id", "name"), + `additional_properties` = list(), #' Initialize a new Category class. #' #' @description @@ -85,6 +87,13 @@ Category <- R6::R6Class( if (!is.null(this_object$`name`)) { self$`name` <- this_object$`name` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -133,6 +142,13 @@ Category <- R6::R6Class( this_object <- jsonlite::fromJSON(input_json) self$`id` <- this_object$`id` self$`name` <- this_object$`name` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Category diff --git a/samples/client/petstore/R/R/danish_pig.R b/samples/client/petstore/R/R/danish_pig.R index 82407e0f46f..ae926fb8021 100644 --- a/samples/client/petstore/R/R/danish_pig.R +++ b/samples/client/petstore/R/R/danish_pig.R @@ -9,7 +9,8 @@ #' @format An \code{R6Class} generator object #' @field className character #' @field size integer -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -18,7 +19,8 @@ DanishPig <- R6::R6Class( public = list( `className` = NULL, `size` = NULL, - `additional_properties` = NULL, + `_field_list` = c("className", "size"), + `additional_properties` = list(), #' Initialize a new DanishPig class. #' #' @description @@ -85,6 +87,13 @@ DanishPig <- R6::R6Class( if (!is.null(this_object$`size`)) { self$`size` <- this_object$`size` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -133,6 +142,13 @@ DanishPig <- R6::R6Class( this_object <- jsonlite::fromJSON(input_json) self$`className` <- this_object$`className` self$`size` <- this_object$`size` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to DanishPig diff --git a/samples/client/petstore/R/R/dog.R b/samples/client/petstore/R/R/dog.R index 6c651ed4ca4..25a7d14396a 100644 --- a/samples/client/petstore/R/R/dog.R +++ b/samples/client/petstore/R/R/dog.R @@ -10,7 +10,8 @@ #' @field className character #' @field color character [optional] #' @field breed character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -21,7 +22,8 @@ Dog <- R6::R6Class( `className` = NULL, `color` = NULL, `breed` = NULL, - `additional_properties` = NULL, + `_field_list` = c("className", "color", "breed"), + `additional_properties` = list(), #' Initialize a new Dog class. #' #' @description @@ -100,6 +102,13 @@ Dog <- R6::R6Class( if (!is.null(this_object$`breed`)) { self$`breed` <- this_object$`breed` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -157,6 +166,13 @@ Dog <- R6::R6Class( self$`className` <- this_object$`className` self$`color` <- this_object$`color` self$`breed` <- this_object$`breed` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Dog diff --git a/samples/client/petstore/R/R/dog_all_of.R b/samples/client/petstore/R/R/dog_all_of.R index f566a558dde..8eb7912a406 100644 --- a/samples/client/petstore/R/R/dog_all_of.R +++ b/samples/client/petstore/R/R/dog_all_of.R @@ -8,7 +8,8 @@ #' @description DogAllOf Class #' @format An \code{R6Class} generator object #' @field breed character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -16,7 +17,8 @@ DogAllOf <- R6::R6Class( "DogAllOf", public = list( `breed` = NULL, - `additional_properties` = NULL, + `_field_list` = c("breed"), + `additional_properties` = list(), #' Initialize a new DogAllOf class. #' #' @description @@ -71,6 +73,13 @@ DogAllOf <- R6::R6Class( if (!is.null(this_object$`breed`)) { self$`breed` <- this_object$`breed` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -110,6 +119,13 @@ DogAllOf <- R6::R6Class( fromJSONString = function(input_json) { this_object <- jsonlite::fromJSON(input_json) self$`breed` <- this_object$`breed` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to DogAllOf diff --git a/samples/client/petstore/R/R/model_api_response.R b/samples/client/petstore/R/R/model_api_response.R index a12add88cba..ed0f63e51b8 100644 --- a/samples/client/petstore/R/R/model_api_response.R +++ b/samples/client/petstore/R/R/model_api_response.R @@ -10,7 +10,8 @@ #' @field code integer [optional] #' @field type character [optional] #' @field message character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -20,7 +21,8 @@ ModelApiResponse <- R6::R6Class( `code` = NULL, `type` = NULL, `message` = NULL, - `additional_properties` = NULL, + `_field_list` = c("code", "type", "message"), + `additional_properties` = list(), #' Initialize a new ModelApiResponse class. #' #' @description @@ -99,6 +101,13 @@ ModelApiResponse <- R6::R6Class( if (!is.null(this_object$`message`)) { self$`message` <- this_object$`message` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -156,6 +165,13 @@ ModelApiResponse <- R6::R6Class( self$`code` <- this_object$`code` self$`type` <- this_object$`type` self$`message` <- this_object$`message` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to ModelApiResponse diff --git a/samples/client/petstore/R/R/nested_one_of.R b/samples/client/petstore/R/R/nested_one_of.R index 01143c027a1..4aa8162d7eb 100644 --- a/samples/client/petstore/R/R/nested_one_of.R +++ b/samples/client/petstore/R/R/nested_one_of.R @@ -9,7 +9,8 @@ #' @format An \code{R6Class} generator object #' @field size integer [optional] #' @field nested_pig \link{Pig} [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -18,7 +19,8 @@ NestedOneOf <- R6::R6Class( public = list( `size` = NULL, `nested_pig` = NULL, - `additional_properties` = NULL, + `_field_list` = c("size", "nested_pig"), + `additional_properties` = list(), #' Initialize a new NestedOneOf class. #' #' @description @@ -87,6 +89,13 @@ NestedOneOf <- R6::R6Class( nested_pig_object$fromJSON(jsonlite::toJSON(this_object$nested_pig, auto_unbox = TRUE, digits = NA)) self$`nested_pig` <- nested_pig_object } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -135,6 +144,13 @@ NestedOneOf <- R6::R6Class( this_object <- jsonlite::fromJSON(input_json) self$`size` <- this_object$`size` self$`nested_pig` <- Pig$new()$fromJSON(jsonlite::toJSON(this_object$nested_pig, auto_unbox = TRUE, digits = NA)) + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to NestedOneOf diff --git a/samples/client/petstore/R/R/order.R b/samples/client/petstore/R/R/order.R index b37f0763b07..706f12c60e5 100644 --- a/samples/client/petstore/R/R/order.R +++ b/samples/client/petstore/R/R/order.R @@ -11,9 +11,10 @@ #' @field petId integer [optional] #' @field quantity integer [optional] #' @field shipDate character [optional] -#' @field status character [optional] +#' @field status Order Status character [optional] #' @field complete character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -26,7 +27,8 @@ Order <- R6::R6Class( `shipDate` = NULL, `status` = NULL, `complete` = NULL, - `additional_properties` = NULL, + `_field_list` = c("id", "petId", "quantity", "shipDate", "status", "complete"), + `additional_properties` = list(), #' Initialize a new Order class. #' #' @description @@ -141,6 +143,13 @@ Order <- R6::R6Class( if (!is.null(this_object$`complete`)) { self$`complete` <- this_object$`complete` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -225,6 +234,13 @@ Order <- R6::R6Class( self$`shipDate` <- this_object$`shipDate` self$`status` <- this_object$`status` self$`complete` <- this_object$`complete` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Order diff --git a/samples/client/petstore/R/R/pet.R b/samples/client/petstore/R/R/pet.R index 9dd8e7390d7..f6cb7a3d669 100644 --- a/samples/client/petstore/R/R/pet.R +++ b/samples/client/petstore/R/R/pet.R @@ -12,8 +12,9 @@ #' @field name character #' @field photoUrls list(character) #' @field tags list(\link{Tag}) [optional] -#' @field status character [optional] -#' @field additional_properties named list(character) [optional] +#' @field status pet status in the store character [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -26,7 +27,8 @@ Pet <- R6::R6Class( `photoUrls` = NULL, `tags` = NULL, `status` = NULL, - `additional_properties` = NULL, + `_field_list` = c("id", "category", "name", "photoUrls", "tags", "status"), + `additional_properties` = list(), #' Initialize a new Pet class. #' #' @description @@ -145,6 +147,13 @@ Pet <- R6::R6Class( if (!is.null(this_object$`status`)) { self$`status` <- this_object$`status` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -229,6 +238,13 @@ Pet <- R6::R6Class( self$`photoUrls` <- ApiClient$new()$deserializeObj(this_object$`photoUrls`, "array[character]", loadNamespace("petstore")) self$`tags` <- ApiClient$new()$deserializeObj(this_object$`tags`, "array[Tag]", loadNamespace("petstore")) self$`status` <- this_object$`status` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Pet diff --git a/samples/client/petstore/R/R/special.R b/samples/client/petstore/R/R/special.R index 388300f0b47..6f6a2bee918 100644 --- a/samples/client/petstore/R/R/special.R +++ b/samples/client/petstore/R/R/special.R @@ -13,7 +13,8 @@ #' @field 123_number character [optional] #' @field array[test] character [optional] #' @field empty_string character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -26,7 +27,8 @@ Special <- R6::R6Class( `123_number` = NULL, `array[test]` = NULL, `empty_string` = NULL, - `additional_properties` = NULL, + `_field_list` = c("item_self", "item_private", "item_super", "123_number", "array[test]", "empty_string"), + `additional_properties` = list(), #' Initialize a new Special class. #' #' @description @@ -141,6 +143,13 @@ Special <- R6::R6Class( if (!is.null(this_object$`empty_string`)) { self$`empty_string` <- this_object$`empty_string` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -225,6 +234,13 @@ Special <- R6::R6Class( self$`123_number` <- this_object$`123_number` self$`array[test]` <- this_object$`array[test]` self$`empty_string` <- this_object$`empty_string` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Special diff --git a/samples/client/petstore/R/R/tag.R b/samples/client/petstore/R/R/tag.R index 2475ccbdd88..639c14c4dd5 100644 --- a/samples/client/petstore/R/R/tag.R +++ b/samples/client/petstore/R/R/tag.R @@ -9,7 +9,8 @@ #' @format An \code{R6Class} generator object #' @field id integer [optional] #' @field name character [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -18,7 +19,8 @@ Tag <- R6::R6Class( public = list( `id` = NULL, `name` = NULL, - `additional_properties` = NULL, + `_field_list` = c("id", "name"), + `additional_properties` = list(), #' Initialize a new Tag class. #' #' @description @@ -85,6 +87,13 @@ Tag <- R6::R6Class( if (!is.null(this_object$`name`)) { self$`name` <- this_object$`name` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -133,6 +142,13 @@ Tag <- R6::R6Class( this_object <- jsonlite::fromJSON(input_json) self$`id` <- this_object$`id` self$`name` <- this_object$`name` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Tag diff --git a/samples/client/petstore/R/R/update_pet_request.R b/samples/client/petstore/R/R/update_pet_request.R index 6f0b39689fa..8e5d1689a4c 100644 --- a/samples/client/petstore/R/R/update_pet_request.R +++ b/samples/client/petstore/R/R/update_pet_request.R @@ -9,7 +9,8 @@ #' @format An \code{R6Class} generator object #' @field jsonData \link{Pet} [optional] #' @field binaryDataN2Information data.frame [optional] -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -18,7 +19,8 @@ UpdatePetRequest <- R6::R6Class( public = list( `jsonData` = NULL, `binaryDataN2Information` = NULL, - `additional_properties` = NULL, + `_field_list` = c("jsonData", "binaryDataN2Information"), + `additional_properties` = list(), #' Initialize a new UpdatePetRequest class. #' #' @description @@ -86,6 +88,13 @@ UpdatePetRequest <- R6::R6Class( if (!is.null(this_object$`binaryDataN2Information`)) { self$`binaryDataN2Information` <- this_object$`binaryDataN2Information` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -134,6 +143,13 @@ UpdatePetRequest <- R6::R6Class( this_object <- jsonlite::fromJSON(input_json) self$`jsonData` <- Pet$new()$fromJSON(jsonlite::toJSON(this_object$jsonData, auto_unbox = TRUE, digits = NA)) self$`binaryDataN2Information` <- this_object$`binaryDataN2Information` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to UpdatePetRequest diff --git a/samples/client/petstore/R/R/user.R b/samples/client/petstore/R/R/user.R index bf4c323d5ce..1be67705420 100644 --- a/samples/client/petstore/R/R/user.R +++ b/samples/client/petstore/R/R/user.R @@ -14,8 +14,9 @@ #' @field email character [optional] #' @field password character [optional] #' @field phone character [optional] -#' @field userStatus integer [optional] -#' @field additional_properties named list(character) [optional] +#' @field userStatus User Status integer [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -30,7 +31,8 @@ User <- R6::R6Class( `password` = NULL, `phone` = NULL, `userStatus` = NULL, - `additional_properties` = NULL, + `_field_list` = c("id", "username", "firstName", "lastName", "email", "password", "phone", "userStatus"), + `additional_properties` = list(), #' Initialize a new User class. #' #' @description @@ -169,6 +171,13 @@ User <- R6::R6Class( if (!is.null(this_object$`userStatus`)) { self$`userStatus` <- this_object$`userStatus` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -271,6 +280,13 @@ User <- R6::R6Class( self$`password` <- this_object$`password` self$`phone` <- this_object$`phone` self$`userStatus` <- this_object$`userStatus` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to User diff --git a/samples/client/petstore/R/R/whale.R b/samples/client/petstore/R/R/whale.R index 0e9b7f2dc8f..458f5d6f86c 100644 --- a/samples/client/petstore/R/R/whale.R +++ b/samples/client/petstore/R/R/whale.R @@ -10,7 +10,8 @@ #' @field hasBaleen character [optional] #' @field hasTeeth character [optional] #' @field className character -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -20,7 +21,8 @@ Whale <- R6::R6Class( `hasBaleen` = NULL, `hasTeeth` = NULL, `className` = NULL, - `additional_properties` = NULL, + `_field_list` = c("hasBaleen", "hasTeeth", "className"), + `additional_properties` = list(), #' Initialize a new Whale class. #' #' @description @@ -99,6 +101,13 @@ Whale <- R6::R6Class( if (!is.null(this_object$`className`)) { self$`className` <- this_object$`className` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -156,6 +165,13 @@ Whale <- R6::R6Class( self$`hasBaleen` <- this_object$`hasBaleen` self$`hasTeeth` <- this_object$`hasTeeth` self$`className` <- this_object$`className` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Whale diff --git a/samples/client/petstore/R/R/zebra.R b/samples/client/petstore/R/R/zebra.R index aff7c8ddedc..4250d51d39c 100644 --- a/samples/client/petstore/R/R/zebra.R +++ b/samples/client/petstore/R/R/zebra.R @@ -9,7 +9,8 @@ #' @format An \code{R6Class} generator object #' @field type character [optional] #' @field className character -#' @field additional_properties named list(character) [optional] +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -18,7 +19,8 @@ Zebra <- R6::R6Class( public = list( `type` = NULL, `className` = NULL, - `additional_properties` = NULL, + `_field_list` = c("type", "className"), + `additional_properties` = list(), #' Initialize a new Zebra class. #' #' @description @@ -85,6 +87,13 @@ Zebra <- R6::R6Class( if (!is.null(this_object$`className`)) { self$`className` <- this_object$`className` } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' To JSON string @@ -133,6 +142,13 @@ Zebra <- R6::R6Class( this_object <- jsonlite::fromJSON(input_json) self$`type` <- this_object$`type` self$`className` <- this_object$`className` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + self }, #' Validate JSON input with respect to Zebra