From cebdbb6a119729723ec57b5d6ecc0bcd9ff4ded8 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 31 Aug 2022 15:06:40 +0800 Subject: [PATCH] add additional properties support in r client (#13317) --- bin/configs/r-client.yaml | 1 + bin/configs/r-httr2-wrapper-client.yaml | 1 + docs/generators/r.md | 1 + .../codegen/languages/RClientCodegen.java | 19 +++++++++++ .../main/resources/r/modelGeneric.mustache | 32 +++++++++++++++++-- .../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 | 20 ++++++++++-- .../client/petstore/R-httr2-wrapper/R/pet.R | 20 ++++++++++-- .../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 | 20 ++++++++++-- .../client/petstore/R-httr2-wrapper/R/whale.R | 20 ++++++++++-- .../client/petstore/R-httr2-wrapper/R/zebra.R | 20 ++++++++++-- .../petstore/R-httr2-wrapper/test_petstore.R | 11 +++++++ .../tests/testthat/test_petstore.R | 11 +++++++ .../R-httr2/R/allof_tag_api_response.R | 3 +- samples/client/petstore/R-httr2/R/animal.R | 3 +- .../client/petstore/R-httr2/R/basque_pig.R | 3 +- samples/client/petstore/R-httr2/R/cat.R | 3 +- .../client/petstore/R-httr2/R/cat_all_of.R | 3 +- samples/client/petstore/R-httr2/R/category.R | 3 +- .../client/petstore/R-httr2/R/danish_pig.R | 3 +- samples/client/petstore/R-httr2/R/dog.R | 3 +- .../client/petstore/R-httr2/R/dog_all_of.R | 3 +- .../petstore/R-httr2/R/model_api_response.R | 3 +- .../client/petstore/R-httr2/R/nested_one_of.R | 3 +- samples/client/petstore/R-httr2/R/order.R | 3 +- samples/client/petstore/R-httr2/R/pet.R | 3 +- samples/client/petstore/R-httr2/R/special.R | 3 +- samples/client/petstore/R-httr2/R/tag.R | 3 +- .../petstore/R-httr2/R/update_pet_request.R | 3 +- samples/client/petstore/R-httr2/R/user.R | 3 +- samples/client/petstore/R-httr2/R/whale.R | 3 +- samples/client/petstore/R-httr2/R/zebra.R | 3 +- .../client/petstore/R-httr2/test_petstore.R | 8 +++++ .../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 | 20 ++++++++++-- samples/client/petstore/R/R/pet.R | 20 ++++++++++-- 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 | 20 ++++++++++-- samples/client/petstore/R/R/whale.R | 20 ++++++++++-- samples/client/petstore/R/R/zebra.R | 20 ++++++++++-- 65 files changed, 785 insertions(+), 116 deletions(-) diff --git a/bin/configs/r-client.yaml b/bin/configs/r-client.yaml index 65483a37f4b..d52db86cac8 100644 --- a/bin/configs/r-client.yaml +++ b/bin/configs/r-client.yaml @@ -10,3 +10,4 @@ additionalProperties: returnExceptionOnFailure: true errorObjectType: "ModelApiResponse" operationIdNaming: PascalCase #default + disallowAdditionalPropertiesIfNotPresent: false diff --git a/bin/configs/r-httr2-wrapper-client.yaml b/bin/configs/r-httr2-wrapper-client.yaml index 796479f0dce..18b3dbc4bb1 100644 --- a/bin/configs/r-httr2-wrapper-client.yaml +++ b/bin/configs/r-httr2-wrapper-client.yaml @@ -13,3 +13,4 @@ additionalProperties: operationIdNaming: snake_case generateWrapper: true useOneOfDiscriminatorLookup: true + disallowAdditionalPropertiesIfNotPresent: false diff --git a/docs/generators/r.md b/docs/generators/r.md index 910bc5f9086..c15ba4ad718 100644 --- a/docs/generators/r.md +++ b/docs/generators/r.md @@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | Option | Description | Values | Default | | ------ | ----------- | ------ | ------- | +|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|
**false**
The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.
**true**
Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.
|true| |errorObjectType|Error object type.| |null| |exceptionPackage|Specify the exception handling package|
**default**
Use stop() for raising exceptions.
**rlang**
Use rlang package for exceptions.
|default| |generateWrapper|Generate a wrapper class (single point of access) for the R client. This option only works with `httr2` library.| |false| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java index 98670a7b596..d4ae8000cd3 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java @@ -216,6 +216,20 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig { setLibrary(HTTR); cliOptions.add(CliOption.newBoolean(GENERATE_WRAPPER, "Generate a wrapper class (single point of access) for the R client. This option only works with `httr2` library.")); + + // option to change how we process + set the data in the 'additionalProperties' keyword. + CliOption disallowAdditionalPropertiesIfNotPresentOpt = CliOption.newBoolean( + CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, + CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT_DESC).defaultValue(Boolean.TRUE.toString()); + Map disallowAdditionalPropertiesIfNotPresentOpts = new HashMap<>(); + disallowAdditionalPropertiesIfNotPresentOpts.put("false", + "The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications."); + disallowAdditionalPropertiesIfNotPresentOpts.put("true", + "Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default."); + disallowAdditionalPropertiesIfNotPresentOpt.setEnum(disallowAdditionalPropertiesIfNotPresentOpts); + cliOptions.add(disallowAdditionalPropertiesIfNotPresentOpt); + this.setDisallowAdditionalPropertiesIfNotPresent(true); + } @Override @@ -272,6 +286,11 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig { additionalProperties.put(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, useOneOfDiscriminatorLookup); } + if (additionalProperties.containsKey(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT)) { + this.setDisallowAdditionalPropertiesIfNotPresent(Boolean.parseBoolean(additionalProperties + .get(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT).toString())); + } + additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName); additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion); additionalProperties.put(CodegenConstants.EXCEPTION_ON_FAILURE, returnExceptionOnFailure); diff --git a/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache index 351bfcbde8f..633578d049a 100644 --- a/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache @@ -10,6 +10,9 @@ {{#vars}} #' @field {{name}} {{title}} {{{vendorExtensions.x-r-doc-type}}}{{^required}} [optional]{{/required}} {{/vars}} +{{#isAdditionalPropertiesTrue}} +#' @field additional_properties named list(character) [optional] +{{/isAdditionalPropertiesTrue}} #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -22,6 +25,9 @@ {{#vars}} `{{{name}}}` = NULL, {{/vars}} + {{#isAdditionalPropertiesTrue}} + `additional_properties` = NULL, + {{/isAdditionalPropertiesTrue}} #' Initialize a new {{{classname}}} class. #' #' @description @@ -33,10 +39,13 @@ {{#optionalVars}} #' @param {{name}} {{#lambdaRdocEscape}}{{{description}}}{{/lambdaRdocEscape}}{{^description}}{{{name}}}{{/description}}{{#defaultValue}}. Default to {{{.}}}.{{/defaultValue}} {{/optionalVars}} + {{#isAdditionalPropertiesTrue}} + #' @param additional_properties additonal properties (optional) + {{/isAdditionalPropertiesTrue}} #' @param ... Other optional arguments. #' @export initialize = function( - {{#requiredVars}}`{{name}}`, {{/requiredVars}}{{#optionalVars}}`{{name}}` = {{{defaultValue}}}{{^defaultValue}}NULL{{/defaultValue}}, {{/optionalVars}}... + {{#requiredVars}}`{{name}}`, {{/requiredVars}}{{#optionalVars}}`{{name}}` = {{{defaultValue}}}{{^defaultValue}}NULL{{/defaultValue}}, {{/optionalVars}}{{#isAdditionalPropertiesTrue}}additional_properties = NULL, {{/isAdditionalPropertiesTrue}}... ) { {{#requiredVars}} if (!missing(`{{name}}`)) { @@ -126,6 +135,13 @@ self$`{{name}}` <- `{{name}}` } {{/optionalVars}} + {{#isAdditionalPropertiesTrue}} + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } + {{/isAdditionalPropertiesTrue}} }, #' To JSON string #' @@ -167,7 +183,12 @@ {{/isContainer}} } {{/vars}} + {{#isAdditionalPropertiesTrue}} + for (key in names(self$additional_properties)) { + {{classname}}Object[[key]] <- self$additional_properties[[key]] + } + {{/isAdditionalPropertiesTrue}} {{classname}}Object }, #' Deserialize JSON string into an instance of {{{classname}}} @@ -266,7 +287,14 @@ {{/vars}} ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + {{#isAdditionalPropertiesTrue}} + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) + {{/isAdditionalPropertiesTrue}} }, #' Deserialize JSON string into an instance of {{{classname}}} #' 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 432d1880556..ee7d3df437d 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,6 +12,7 @@ #' @field code integer [optional] #' @field type character [optional] #' @field message character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -23,6 +24,7 @@ AllofTagApiResponse <- R6::R6Class( `code` = NULL, `type` = NULL, `message` = NULL, + `additional_properties` = NULL, #' Initialize a new AllofTagApiResponse class. #' #' @description @@ -33,10 +35,11 @@ AllofTagApiResponse <- R6::R6Class( #' @param code code #' @param type type #' @param message message + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `id` = NULL, `name` = NULL, `code` = NULL, `type` = NULL, `message` = NULL, ... + `id` = NULL, `name` = NULL, `code` = NULL, `type` = NULL, `message` = NULL, additional_properties = NULL, ... ) { if (!is.null(`id`)) { stopifnot(is.numeric(`id`), length(`id`) == 1) @@ -58,6 +61,11 @@ AllofTagApiResponse <- R6::R6Class( stopifnot(is.character(`message`), length(`message`) == 1) self$`message` <- `message` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -88,6 +96,9 @@ AllofTagApiResponse <- R6::R6Class( AllofTagApiResponseObject[["message"]] <- self$`message` } + for (key in names(self$additional_properties)) { + AllofTagApiResponseObject[[key]] <- self$additional_properties[[key]] + } AllofTagApiResponseObject }, @@ -169,7 +180,12 @@ AllofTagApiResponse <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of AllofTagApiResponse #' diff --git a/samples/client/petstore/R-httr2-wrapper/R/animal.R b/samples/client/petstore/R-httr2-wrapper/R/animal.R index 05f963143d7..af3277925dc 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/animal.R +++ b/samples/client/petstore/R-httr2-wrapper/R/animal.R @@ -9,6 +9,7 @@ #' @format An \code{R6Class} generator object #' @field className character #' @field color character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -17,6 +18,7 @@ Animal <- R6::R6Class( public = list( `className` = NULL, `color` = NULL, + `additional_properties` = NULL, #' Initialize a new Animal class. #' #' @description @@ -24,10 +26,11 @@ Animal <- R6::R6Class( #' #' @param className className #' @param color color. Default to "red". + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `className`, `color` = "red", ... + `className`, `color` = "red", additional_properties = NULL, ... ) { if (!missing(`className`)) { stopifnot(is.character(`className`), length(`className`) == 1) @@ -37,6 +40,11 @@ Animal <- R6::R6Class( stopifnot(is.character(`color`), length(`color`) == 1) self$`color` <- `color` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -55,6 +63,9 @@ Animal <- R6::R6Class( AnimalObject[["color"]] <- self$`color` } + for (key in names(self$additional_properties)) { + AnimalObject[[key]] <- self$additional_properties[[key]] + } AnimalObject }, @@ -103,7 +114,12 @@ Animal <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of 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 fccd0a82581..5533893c45e 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/basque_pig.R +++ b/samples/client/petstore/R-httr2-wrapper/R/basque_pig.R @@ -9,6 +9,7 @@ #' @format An \code{R6Class} generator object #' @field className character #' @field color character +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -17,6 +18,7 @@ BasquePig <- R6::R6Class( public = list( `className` = NULL, `color` = NULL, + `additional_properties` = NULL, #' Initialize a new BasquePig class. #' #' @description @@ -24,10 +26,11 @@ BasquePig <- R6::R6Class( #' #' @param className className #' @param color color + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `className`, `color`, ... + `className`, `color`, additional_properties = NULL, ... ) { if (!missing(`className`)) { stopifnot(is.character(`className`), length(`className`) == 1) @@ -37,6 +40,11 @@ BasquePig <- R6::R6Class( stopifnot(is.character(`color`), length(`color`) == 1) self$`color` <- `color` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -55,6 +63,9 @@ BasquePig <- R6::R6Class( BasquePigObject[["color"]] <- self$`color` } + for (key in names(self$additional_properties)) { + BasquePigObject[[key]] <- self$additional_properties[[key]] + } BasquePigObject }, @@ -103,7 +114,12 @@ BasquePig <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of BasquePig #' diff --git a/samples/client/petstore/R-httr2-wrapper/R/cat.R b/samples/client/petstore/R-httr2-wrapper/R/cat.R index 80cd2b7c7cd..b029e1064fd 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/cat.R +++ b/samples/client/petstore/R-httr2-wrapper/R/cat.R @@ -10,6 +10,7 @@ #' @field className character #' @field color character [optional] #' @field declawed character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -20,6 +21,7 @@ Cat <- R6::R6Class( `className` = NULL, `color` = NULL, `declawed` = NULL, + `additional_properties` = NULL, #' Initialize a new Cat class. #' #' @description @@ -28,10 +30,11 @@ Cat <- R6::R6Class( #' @param className className #' @param color color. Default to "red". #' @param declawed declawed + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `className`, `color` = "red", `declawed` = NULL, ... + `className`, `color` = "red", `declawed` = NULL, additional_properties = NULL, ... ) { if (!missing(`className`)) { stopifnot(is.character(`className`), length(`className`) == 1) @@ -45,6 +48,11 @@ Cat <- R6::R6Class( stopifnot(is.logical(`declawed`), length(`declawed`) == 1) self$`declawed` <- `declawed` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -67,6 +75,9 @@ Cat <- R6::R6Class( CatObject[["declawed"]] <- self$`declawed` } + for (key in names(self$additional_properties)) { + CatObject[[key]] <- self$additional_properties[[key]] + } CatObject }, @@ -126,7 +137,12 @@ Cat <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of 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 9ea1650b6a3..24d913f89e0 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,6 +8,7 @@ #' @description CatAllOf Class #' @format An \code{R6Class} generator object #' @field declawed character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -15,21 +16,28 @@ CatAllOf <- R6::R6Class( "CatAllOf", public = list( `declawed` = NULL, + `additional_properties` = NULL, #' Initialize a new CatAllOf class. #' #' @description #' Initialize a new CatAllOf class. #' #' @param declawed declawed + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `declawed` = NULL, ... + `declawed` = NULL, additional_properties = NULL, ... ) { if (!is.null(`declawed`)) { stopifnot(is.logical(`declawed`), length(`declawed`) == 1) self$`declawed` <- `declawed` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -44,6 +52,9 @@ CatAllOf <- R6::R6Class( CatAllOfObject[["declawed"]] <- self$`declawed` } + for (key in names(self$additional_properties)) { + CatAllOfObject[[key]] <- self$additional_properties[[key]] + } CatAllOfObject }, @@ -81,7 +92,12 @@ CatAllOf <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of CatAllOf #' diff --git a/samples/client/petstore/R-httr2-wrapper/R/category.R b/samples/client/petstore/R-httr2-wrapper/R/category.R index a9d1c33a84c..95593d0cd7c 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/category.R +++ b/samples/client/petstore/R-httr2-wrapper/R/category.R @@ -9,6 +9,7 @@ #' @format An \code{R6Class} generator object #' @field id integer [optional] #' @field name character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -17,6 +18,7 @@ Category <- R6::R6Class( public = list( `id` = NULL, `name` = NULL, + `additional_properties` = NULL, #' Initialize a new Category class. #' #' @description @@ -24,10 +26,11 @@ Category <- R6::R6Class( #' #' @param id id #' @param name name + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `id` = NULL, `name` = NULL, ... + `id` = NULL, `name` = NULL, additional_properties = NULL, ... ) { if (!is.null(`id`)) { stopifnot(is.numeric(`id`), length(`id`) == 1) @@ -37,6 +40,11 @@ Category <- R6::R6Class( stopifnot(is.character(`name`), length(`name`) == 1) self$`name` <- `name` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -55,6 +63,9 @@ Category <- R6::R6Class( CategoryObject[["name"]] <- self$`name` } + for (key in names(self$additional_properties)) { + CategoryObject[[key]] <- self$additional_properties[[key]] + } CategoryObject }, @@ -103,7 +114,12 @@ Category <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of 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 3432d23df82..82407e0f46f 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/danish_pig.R +++ b/samples/client/petstore/R-httr2-wrapper/R/danish_pig.R @@ -9,6 +9,7 @@ #' @format An \code{R6Class} generator object #' @field className character #' @field size integer +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -17,6 +18,7 @@ DanishPig <- R6::R6Class( public = list( `className` = NULL, `size` = NULL, + `additional_properties` = NULL, #' Initialize a new DanishPig class. #' #' @description @@ -24,10 +26,11 @@ DanishPig <- R6::R6Class( #' #' @param className className #' @param size size + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `className`, `size`, ... + `className`, `size`, additional_properties = NULL, ... ) { if (!missing(`className`)) { stopifnot(is.character(`className`), length(`className`) == 1) @@ -37,6 +40,11 @@ DanishPig <- R6::R6Class( stopifnot(is.numeric(`size`), length(`size`) == 1) self$`size` <- `size` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -55,6 +63,9 @@ DanishPig <- R6::R6Class( DanishPigObject[["size"]] <- self$`size` } + for (key in names(self$additional_properties)) { + DanishPigObject[[key]] <- self$additional_properties[[key]] + } DanishPigObject }, @@ -103,7 +114,12 @@ DanishPig <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of DanishPig #' diff --git a/samples/client/petstore/R-httr2-wrapper/R/dog.R b/samples/client/petstore/R-httr2-wrapper/R/dog.R index aade3e1cc95..6c651ed4ca4 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/dog.R +++ b/samples/client/petstore/R-httr2-wrapper/R/dog.R @@ -10,6 +10,7 @@ #' @field className character #' @field color character [optional] #' @field breed character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -20,6 +21,7 @@ Dog <- R6::R6Class( `className` = NULL, `color` = NULL, `breed` = NULL, + `additional_properties` = NULL, #' Initialize a new Dog class. #' #' @description @@ -28,10 +30,11 @@ Dog <- R6::R6Class( #' @param className className #' @param color color. Default to "red". #' @param breed breed + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `className`, `color` = "red", `breed` = NULL, ... + `className`, `color` = "red", `breed` = NULL, additional_properties = NULL, ... ) { if (!missing(`className`)) { stopifnot(is.character(`className`), length(`className`) == 1) @@ -45,6 +48,11 @@ Dog <- R6::R6Class( stopifnot(is.character(`breed`), length(`breed`) == 1) self$`breed` <- `breed` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -67,6 +75,9 @@ Dog <- R6::R6Class( DogObject[["breed"]] <- self$`breed` } + for (key in names(self$additional_properties)) { + DogObject[[key]] <- self$additional_properties[[key]] + } DogObject }, @@ -126,7 +137,12 @@ Dog <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of 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 717343a9492..f566a558dde 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,6 +8,7 @@ #' @description DogAllOf Class #' @format An \code{R6Class} generator object #' @field breed character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -15,21 +16,28 @@ DogAllOf <- R6::R6Class( "DogAllOf", public = list( `breed` = NULL, + `additional_properties` = NULL, #' Initialize a new DogAllOf class. #' #' @description #' Initialize a new DogAllOf class. #' #' @param breed breed + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `breed` = NULL, ... + `breed` = NULL, additional_properties = NULL, ... ) { if (!is.null(`breed`)) { stopifnot(is.character(`breed`), length(`breed`) == 1) self$`breed` <- `breed` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -44,6 +52,9 @@ DogAllOf <- R6::R6Class( DogAllOfObject[["breed"]] <- self$`breed` } + for (key in names(self$additional_properties)) { + DogAllOfObject[[key]] <- self$additional_properties[[key]] + } DogAllOfObject }, @@ -81,7 +92,12 @@ DogAllOf <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of 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 3420a44585c..a12add88cba 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,6 +10,7 @@ #' @field code integer [optional] #' @field type character [optional] #' @field message character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -19,6 +20,7 @@ ModelApiResponse <- R6::R6Class( `code` = NULL, `type` = NULL, `message` = NULL, + `additional_properties` = NULL, #' Initialize a new ModelApiResponse class. #' #' @description @@ -27,10 +29,11 @@ ModelApiResponse <- R6::R6Class( #' @param code code #' @param type type #' @param message message + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `code` = NULL, `type` = NULL, `message` = NULL, ... + `code` = NULL, `type` = NULL, `message` = NULL, additional_properties = NULL, ... ) { if (!is.null(`code`)) { stopifnot(is.numeric(`code`), length(`code`) == 1) @@ -44,6 +47,11 @@ ModelApiResponse <- R6::R6Class( stopifnot(is.character(`message`), length(`message`) == 1) self$`message` <- `message` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -66,6 +74,9 @@ ModelApiResponse <- R6::R6Class( ModelApiResponseObject[["message"]] <- self$`message` } + for (key in names(self$additional_properties)) { + ModelApiResponseObject[[key]] <- self$additional_properties[[key]] + } ModelApiResponseObject }, @@ -125,7 +136,12 @@ ModelApiResponse <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of 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 ce6c381d818..01143c027a1 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,6 +9,7 @@ #' @format An \code{R6Class} generator object #' @field size integer [optional] #' @field nested_pig \link{Pig} [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -17,6 +18,7 @@ NestedOneOf <- R6::R6Class( public = list( `size` = NULL, `nested_pig` = NULL, + `additional_properties` = NULL, #' Initialize a new NestedOneOf class. #' #' @description @@ -24,10 +26,11 @@ NestedOneOf <- R6::R6Class( #' #' @param size size #' @param nested_pig nested_pig + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `size` = NULL, `nested_pig` = NULL, ... + `size` = NULL, `nested_pig` = NULL, additional_properties = NULL, ... ) { if (!is.null(`size`)) { stopifnot(is.numeric(`size`), length(`size`) == 1) @@ -37,6 +40,11 @@ NestedOneOf <- R6::R6Class( stopifnot(R6::is.R6(`nested_pig`)) self$`nested_pig` <- `nested_pig` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -55,6 +63,9 @@ NestedOneOf <- R6::R6Class( NestedOneOfObject[["nested_pig"]] <- self$`nested_pig`$toJSON() } + for (key in names(self$additional_properties)) { + NestedOneOfObject[[key]] <- self$additional_properties[[key]] + } NestedOneOfObject }, @@ -105,7 +116,12 @@ NestedOneOf <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of NestedOneOf #' diff --git a/samples/client/petstore/R-httr2-wrapper/R/order.R b/samples/client/petstore/R-httr2-wrapper/R/order.R index cc86fbc0512..b37f0763b07 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/order.R +++ b/samples/client/petstore/R-httr2-wrapper/R/order.R @@ -13,6 +13,7 @@ #' @field shipDate character [optional] #' @field status character [optional] #' @field complete character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -25,6 +26,7 @@ Order <- R6::R6Class( `shipDate` = NULL, `status` = NULL, `complete` = NULL, + `additional_properties` = NULL, #' Initialize a new Order class. #' #' @description @@ -36,10 +38,11 @@ Order <- R6::R6Class( #' @param shipDate shipDate #' @param status Order Status #' @param complete complete. Default to FALSE. + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `id` = NULL, `petId` = NULL, `quantity` = NULL, `shipDate` = NULL, `status` = NULL, `complete` = FALSE, ... + `id` = NULL, `petId` = NULL, `quantity` = NULL, `shipDate` = NULL, `status` = NULL, `complete` = FALSE, additional_properties = NULL, ... ) { if (!is.null(`id`)) { stopifnot(is.numeric(`id`), length(`id`) == 1) @@ -65,6 +68,11 @@ Order <- R6::R6Class( stopifnot(is.logical(`complete`), length(`complete`) == 1) self$`complete` <- `complete` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -99,6 +107,9 @@ Order <- R6::R6Class( OrderObject[["complete"]] <- self$`complete` } + for (key in names(self$additional_properties)) { + OrderObject[[key]] <- self$additional_properties[[key]] + } OrderObject }, @@ -191,7 +202,12 @@ Order <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of Order #' diff --git a/samples/client/petstore/R-httr2-wrapper/R/pet.R b/samples/client/petstore/R-httr2-wrapper/R/pet.R index 707c9f1ec75..9dd8e7390d7 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/pet.R +++ b/samples/client/petstore/R-httr2-wrapper/R/pet.R @@ -13,6 +13,7 @@ #' @field photoUrls list(character) #' @field tags list(\link{Tag}) [optional] #' @field status character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -25,6 +26,7 @@ Pet <- R6::R6Class( `photoUrls` = NULL, `tags` = NULL, `status` = NULL, + `additional_properties` = NULL, #' Initialize a new Pet class. #' #' @description @@ -36,10 +38,11 @@ Pet <- R6::R6Class( #' @param category category #' @param tags tags #' @param status pet status in the store + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `name`, `photoUrls`, `id` = NULL, `category` = NULL, `tags` = NULL, `status` = NULL, ... + `name`, `photoUrls`, `id` = NULL, `category` = NULL, `tags` = NULL, `status` = NULL, additional_properties = NULL, ... ) { if (!missing(`name`)) { stopifnot(is.character(`name`), length(`name`) == 1) @@ -67,6 +70,11 @@ Pet <- R6::R6Class( stopifnot(is.character(`status`), length(`status`) == 1) self$`status` <- `status` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -101,6 +109,9 @@ Pet <- R6::R6Class( PetObject[["status"]] <- self$`status` } + for (key in names(self$additional_properties)) { + PetObject[[key]] <- self$additional_properties[[key]] + } PetObject }, @@ -195,7 +206,12 @@ Pet <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of Pet #' diff --git a/samples/client/petstore/R-httr2-wrapper/R/special.R b/samples/client/petstore/R-httr2-wrapper/R/special.R index a554310db9e..388300f0b47 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/special.R +++ b/samples/client/petstore/R-httr2-wrapper/R/special.R @@ -13,6 +13,7 @@ #' @field 123_number character [optional] #' @field array[test] character [optional] #' @field empty_string character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -25,6 +26,7 @@ Special <- R6::R6Class( `123_number` = NULL, `array[test]` = NULL, `empty_string` = NULL, + `additional_properties` = NULL, #' Initialize a new Special class. #' #' @description @@ -36,10 +38,11 @@ Special <- R6::R6Class( #' @param 123_number 123_number #' @param array[test] array[test] #' @param empty_string empty_string + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `item_self` = NULL, `item_private` = NULL, `item_super` = NULL, `123_number` = NULL, `array[test]` = NULL, `empty_string` = NULL, ... + `item_self` = NULL, `item_private` = NULL, `item_super` = NULL, `123_number` = NULL, `array[test]` = NULL, `empty_string` = NULL, additional_properties = NULL, ... ) { if (!is.null(`item_self`)) { stopifnot(is.numeric(`item_self`), length(`item_self`) == 1) @@ -65,6 +68,11 @@ Special <- R6::R6Class( stopifnot(is.character(`empty_string`), length(`empty_string`) == 1) self$`empty_string` <- `empty_string` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -99,6 +107,9 @@ Special <- R6::R6Class( SpecialObject[["empty_string"]] <- self$`empty_string` } + for (key in names(self$additional_properties)) { + SpecialObject[[key]] <- self$additional_properties[[key]] + } SpecialObject }, @@ -191,7 +202,12 @@ Special <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of Special #' diff --git a/samples/client/petstore/R-httr2-wrapper/R/tag.R b/samples/client/petstore/R-httr2-wrapper/R/tag.R index 2dc0be8e2f7..2475ccbdd88 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/tag.R +++ b/samples/client/petstore/R-httr2-wrapper/R/tag.R @@ -9,6 +9,7 @@ #' @format An \code{R6Class} generator object #' @field id integer [optional] #' @field name character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -17,6 +18,7 @@ Tag <- R6::R6Class( public = list( `id` = NULL, `name` = NULL, + `additional_properties` = NULL, #' Initialize a new Tag class. #' #' @description @@ -24,10 +26,11 @@ Tag <- R6::R6Class( #' #' @param id id #' @param name name + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `id` = NULL, `name` = NULL, ... + `id` = NULL, `name` = NULL, additional_properties = NULL, ... ) { if (!is.null(`id`)) { stopifnot(is.numeric(`id`), length(`id`) == 1) @@ -37,6 +40,11 @@ Tag <- R6::R6Class( stopifnot(is.character(`name`), length(`name`) == 1) self$`name` <- `name` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -55,6 +63,9 @@ Tag <- R6::R6Class( TagObject[["name"]] <- self$`name` } + for (key in names(self$additional_properties)) { + TagObject[[key]] <- self$additional_properties[[key]] + } TagObject }, @@ -103,7 +114,12 @@ Tag <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of 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 795498c49b3..6f0b39689fa 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,6 +9,7 @@ #' @format An \code{R6Class} generator object #' @field jsonData \link{Pet} [optional] #' @field binaryDataN2Information data.frame [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -17,6 +18,7 @@ UpdatePetRequest <- R6::R6Class( public = list( `jsonData` = NULL, `binaryDataN2Information` = NULL, + `additional_properties` = NULL, #' Initialize a new UpdatePetRequest class. #' #' @description @@ -24,10 +26,11 @@ UpdatePetRequest <- R6::R6Class( #' #' @param jsonData jsonData #' @param binaryDataN2Information binaryDataN2Information + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `jsonData` = NULL, `binaryDataN2Information` = NULL, ... + `jsonData` = NULL, `binaryDataN2Information` = NULL, additional_properties = NULL, ... ) { if (!is.null(`jsonData`)) { stopifnot(R6::is.R6(`jsonData`)) @@ -36,6 +39,11 @@ UpdatePetRequest <- R6::R6Class( if (!is.null(`binaryDataN2Information`)) { self$`binaryDataN2Information` <- `binaryDataN2Information` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -54,6 +62,9 @@ UpdatePetRequest <- R6::R6Class( UpdatePetRequestObject[["binaryDataN2Information"]] <- self$`binaryDataN2Information` } + for (key in names(self$additional_properties)) { + UpdatePetRequestObject[[key]] <- self$additional_properties[[key]] + } UpdatePetRequestObject }, @@ -104,7 +115,12 @@ UpdatePetRequest <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of UpdatePetRequest #' diff --git a/samples/client/petstore/R-httr2-wrapper/R/user.R b/samples/client/petstore/R-httr2-wrapper/R/user.R index bb90189bddd..bf4c323d5ce 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/user.R +++ b/samples/client/petstore/R-httr2-wrapper/R/user.R @@ -15,6 +15,7 @@ #' @field password character [optional] #' @field phone character [optional] #' @field userStatus integer [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -29,6 +30,7 @@ User <- R6::R6Class( `password` = NULL, `phone` = NULL, `userStatus` = NULL, + `additional_properties` = NULL, #' Initialize a new User class. #' #' @description @@ -42,10 +44,11 @@ User <- R6::R6Class( #' @param password password #' @param phone phone #' @param userStatus User Status + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `id` = NULL, `username` = NULL, `firstName` = NULL, `lastName` = NULL, `email` = NULL, `password` = NULL, `phone` = NULL, `userStatus` = NULL, ... + `id` = NULL, `username` = NULL, `firstName` = NULL, `lastName` = NULL, `email` = NULL, `password` = NULL, `phone` = NULL, `userStatus` = NULL, additional_properties = NULL, ... ) { if (!is.null(`id`)) { stopifnot(is.numeric(`id`), length(`id`) == 1) @@ -79,6 +82,11 @@ User <- R6::R6Class( stopifnot(is.numeric(`userStatus`), length(`userStatus`) == 1) self$`userStatus` <- `userStatus` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -121,6 +129,9 @@ User <- R6::R6Class( UserObject[["userStatus"]] <- self$`userStatus` } + for (key in names(self$additional_properties)) { + UserObject[[key]] <- self$additional_properties[[key]] + } UserObject }, @@ -235,7 +246,12 @@ User <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of User #' diff --git a/samples/client/petstore/R-httr2-wrapper/R/whale.R b/samples/client/petstore/R-httr2-wrapper/R/whale.R index 31738ea3622..0e9b7f2dc8f 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/whale.R +++ b/samples/client/petstore/R-httr2-wrapper/R/whale.R @@ -10,6 +10,7 @@ #' @field hasBaleen character [optional] #' @field hasTeeth character [optional] #' @field className character +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -19,6 +20,7 @@ Whale <- R6::R6Class( `hasBaleen` = NULL, `hasTeeth` = NULL, `className` = NULL, + `additional_properties` = NULL, #' Initialize a new Whale class. #' #' @description @@ -27,10 +29,11 @@ Whale <- R6::R6Class( #' @param className className #' @param hasBaleen hasBaleen #' @param hasTeeth hasTeeth + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `className`, `hasBaleen` = NULL, `hasTeeth` = NULL, ... + `className`, `hasBaleen` = NULL, `hasTeeth` = NULL, additional_properties = NULL, ... ) { if (!missing(`className`)) { stopifnot(is.character(`className`), length(`className`) == 1) @@ -44,6 +47,11 @@ Whale <- R6::R6Class( stopifnot(is.logical(`hasTeeth`), length(`hasTeeth`) == 1) self$`hasTeeth` <- `hasTeeth` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -66,6 +74,9 @@ Whale <- R6::R6Class( WhaleObject[["className"]] <- self$`className` } + for (key in names(self$additional_properties)) { + WhaleObject[[key]] <- self$additional_properties[[key]] + } WhaleObject }, @@ -125,7 +136,12 @@ Whale <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of Whale #' diff --git a/samples/client/petstore/R-httr2-wrapper/R/zebra.R b/samples/client/petstore/R-httr2-wrapper/R/zebra.R index d9d2788aca9..aff7c8ddedc 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/zebra.R +++ b/samples/client/petstore/R-httr2-wrapper/R/zebra.R @@ -9,6 +9,7 @@ #' @format An \code{R6Class} generator object #' @field type character [optional] #' @field className character +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -17,6 +18,7 @@ Zebra <- R6::R6Class( public = list( `type` = NULL, `className` = NULL, + `additional_properties` = NULL, #' Initialize a new Zebra class. #' #' @description @@ -24,10 +26,11 @@ Zebra <- R6::R6Class( #' #' @param className className #' @param type type + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `className`, `type` = NULL, ... + `className`, `type` = NULL, additional_properties = NULL, ... ) { if (!missing(`className`)) { stopifnot(is.character(`className`), length(`className`) == 1) @@ -37,6 +40,11 @@ Zebra <- R6::R6Class( stopifnot(is.character(`type`), length(`type`) == 1) self$`type` <- `type` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -55,6 +63,9 @@ Zebra <- R6::R6Class( ZebraObject[["className"]] <- self$`className` } + for (key in names(self$additional_properties)) { + ZebraObject[[key]] <- self$additional_properties[[key]] + } ZebraObject }, @@ -103,7 +114,12 @@ Zebra <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of Zebra #' diff --git a/samples/client/petstore/R-httr2-wrapper/test_petstore.R b/samples/client/petstore/R-httr2-wrapper/test_petstore.R index 786df7d788d..6cd8b7e6f85 100644 --- a/samples/client/petstore/R-httr2-wrapper/test_petstore.R +++ b/samples/client/petstore/R-httr2-wrapper/test_petstore.R @@ -3,6 +3,17 @@ install.packages("petstore_1.0.0.tar.gz",repos=NULL, type="source") library(petstore) library(jsonlite) +t <- Tag$new() +t$id <- 123 +t$additional_properties <- c("abc" = 849, "array" = list('a', 'b', 'c')) +t$additional_properties +t$additional_properties["abc"] +t$additional_properties["array"] +print(t$toJSON()) +print(t$toJSONString()) + +print("done tag") + whale_json <- '{"className": "whale", "hasBaleen": true, "hasTeeth": true}' zebra_json <- '{"className": "zebra", "type": "plains"}' 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 21b6e4e9132..92aecbfc262 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 @@ -21,6 +21,17 @@ pet_api$api_client$username <- "username123" pet_api$api_client$password <- "password123" result <- pet_api$add_pet(pet) +test_that("Additional Properties test", { + # test tag + t <- Tag$new(id = 393, name = "something") + t$additional_properties <- c("a1" = 998, "b2" = "bbccdd") + expect_equal(t$toJSONString(), "{\"id\":393,\"name\":\"something\",\"a1\":\"998\",\"b2\":\"bbccdd\"}") + + # 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_that("Test toJSON toJSONString fromJSON fromJSONString print", { # test pet expect_equal(pet_id, 123321) diff --git a/samples/client/petstore/R-httr2/R/allof_tag_api_response.R b/samples/client/petstore/R-httr2/R/allof_tag_api_response.R index 432d1880556..8fc7e22529a 100644 --- a/samples/client/petstore/R-httr2/R/allof_tag_api_response.R +++ b/samples/client/petstore/R-httr2/R/allof_tag_api_response.R @@ -88,7 +88,6 @@ AllofTagApiResponse <- R6::R6Class( AllofTagApiResponseObject[["message"]] <- self$`message` } - AllofTagApiResponseObject }, #' Deserialize JSON string into an instance of AllofTagApiResponse @@ -169,7 +168,7 @@ AllofTagApiResponse <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of AllofTagApiResponse #' diff --git a/samples/client/petstore/R-httr2/R/animal.R b/samples/client/petstore/R-httr2/R/animal.R index 05f963143d7..e750befac15 100644 --- a/samples/client/petstore/R-httr2/R/animal.R +++ b/samples/client/petstore/R-httr2/R/animal.R @@ -55,7 +55,6 @@ Animal <- R6::R6Class( AnimalObject[["color"]] <- self$`color` } - AnimalObject }, #' Deserialize JSON string into an instance of Animal @@ -103,7 +102,7 @@ Animal <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of Animal #' diff --git a/samples/client/petstore/R-httr2/R/basque_pig.R b/samples/client/petstore/R-httr2/R/basque_pig.R index fccd0a82581..8174fce65d2 100644 --- a/samples/client/petstore/R-httr2/R/basque_pig.R +++ b/samples/client/petstore/R-httr2/R/basque_pig.R @@ -55,7 +55,6 @@ BasquePig <- R6::R6Class( BasquePigObject[["color"]] <- self$`color` } - BasquePigObject }, #' Deserialize JSON string into an instance of BasquePig @@ -103,7 +102,7 @@ BasquePig <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of BasquePig #' diff --git a/samples/client/petstore/R-httr2/R/cat.R b/samples/client/petstore/R-httr2/R/cat.R index 80cd2b7c7cd..fbc5f2f2560 100644 --- a/samples/client/petstore/R-httr2/R/cat.R +++ b/samples/client/petstore/R-httr2/R/cat.R @@ -67,7 +67,6 @@ Cat <- R6::R6Class( CatObject[["declawed"]] <- self$`declawed` } - CatObject }, #' Deserialize JSON string into an instance of Cat @@ -126,7 +125,7 @@ Cat <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of Cat #' diff --git a/samples/client/petstore/R-httr2/R/cat_all_of.R b/samples/client/petstore/R-httr2/R/cat_all_of.R index 9ea1650b6a3..e0b26edae53 100644 --- a/samples/client/petstore/R-httr2/R/cat_all_of.R +++ b/samples/client/petstore/R-httr2/R/cat_all_of.R @@ -44,7 +44,6 @@ CatAllOf <- R6::R6Class( CatAllOfObject[["declawed"]] <- self$`declawed` } - CatAllOfObject }, #' Deserialize JSON string into an instance of CatAllOf @@ -81,7 +80,7 @@ CatAllOf <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of CatAllOf #' diff --git a/samples/client/petstore/R-httr2/R/category.R b/samples/client/petstore/R-httr2/R/category.R index a9d1c33a84c..405303c1a2e 100644 --- a/samples/client/petstore/R-httr2/R/category.R +++ b/samples/client/petstore/R-httr2/R/category.R @@ -55,7 +55,6 @@ Category <- R6::R6Class( CategoryObject[["name"]] <- self$`name` } - CategoryObject }, #' Deserialize JSON string into an instance of Category @@ -103,7 +102,7 @@ Category <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of Category #' diff --git a/samples/client/petstore/R-httr2/R/danish_pig.R b/samples/client/petstore/R-httr2/R/danish_pig.R index 3432d23df82..b876a063998 100644 --- a/samples/client/petstore/R-httr2/R/danish_pig.R +++ b/samples/client/petstore/R-httr2/R/danish_pig.R @@ -55,7 +55,6 @@ DanishPig <- R6::R6Class( DanishPigObject[["size"]] <- self$`size` } - DanishPigObject }, #' Deserialize JSON string into an instance of DanishPig @@ -103,7 +102,7 @@ DanishPig <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of DanishPig #' diff --git a/samples/client/petstore/R-httr2/R/dog.R b/samples/client/petstore/R-httr2/R/dog.R index aade3e1cc95..7c2595853df 100644 --- a/samples/client/petstore/R-httr2/R/dog.R +++ b/samples/client/petstore/R-httr2/R/dog.R @@ -67,7 +67,6 @@ Dog <- R6::R6Class( DogObject[["breed"]] <- self$`breed` } - DogObject }, #' Deserialize JSON string into an instance of Dog @@ -126,7 +125,7 @@ Dog <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of Dog #' diff --git a/samples/client/petstore/R-httr2/R/dog_all_of.R b/samples/client/petstore/R-httr2/R/dog_all_of.R index 717343a9492..a66cddf95d8 100644 --- a/samples/client/petstore/R-httr2/R/dog_all_of.R +++ b/samples/client/petstore/R-httr2/R/dog_all_of.R @@ -44,7 +44,6 @@ DogAllOf <- R6::R6Class( DogAllOfObject[["breed"]] <- self$`breed` } - DogAllOfObject }, #' Deserialize JSON string into an instance of DogAllOf @@ -81,7 +80,7 @@ DogAllOf <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of DogAllOf #' diff --git a/samples/client/petstore/R-httr2/R/model_api_response.R b/samples/client/petstore/R-httr2/R/model_api_response.R index 3420a44585c..f5fbf9b1497 100644 --- a/samples/client/petstore/R-httr2/R/model_api_response.R +++ b/samples/client/petstore/R-httr2/R/model_api_response.R @@ -66,7 +66,6 @@ ModelApiResponse <- R6::R6Class( ModelApiResponseObject[["message"]] <- self$`message` } - ModelApiResponseObject }, #' Deserialize JSON string into an instance of ModelApiResponse @@ -125,7 +124,7 @@ ModelApiResponse <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of ModelApiResponse #' diff --git a/samples/client/petstore/R-httr2/R/nested_one_of.R b/samples/client/petstore/R-httr2/R/nested_one_of.R index ce6c381d818..8828f09d762 100644 --- a/samples/client/petstore/R-httr2/R/nested_one_of.R +++ b/samples/client/petstore/R-httr2/R/nested_one_of.R @@ -55,7 +55,6 @@ NestedOneOf <- R6::R6Class( NestedOneOfObject[["nested_pig"]] <- self$`nested_pig`$toJSON() } - NestedOneOfObject }, #' Deserialize JSON string into an instance of NestedOneOf @@ -105,7 +104,7 @@ NestedOneOf <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of NestedOneOf #' diff --git a/samples/client/petstore/R-httr2/R/order.R b/samples/client/petstore/R-httr2/R/order.R index cc86fbc0512..f4cfcae6ec2 100644 --- a/samples/client/petstore/R-httr2/R/order.R +++ b/samples/client/petstore/R-httr2/R/order.R @@ -99,7 +99,6 @@ Order <- R6::R6Class( OrderObject[["complete"]] <- self$`complete` } - OrderObject }, #' Deserialize JSON string into an instance of Order @@ -191,7 +190,7 @@ Order <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of Order #' diff --git a/samples/client/petstore/R-httr2/R/pet.R b/samples/client/petstore/R-httr2/R/pet.R index 707c9f1ec75..e25c0052f55 100644 --- a/samples/client/petstore/R-httr2/R/pet.R +++ b/samples/client/petstore/R-httr2/R/pet.R @@ -101,7 +101,6 @@ Pet <- R6::R6Class( PetObject[["status"]] <- self$`status` } - PetObject }, #' Deserialize JSON string into an instance of Pet @@ -195,7 +194,7 @@ Pet <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of Pet #' diff --git a/samples/client/petstore/R-httr2/R/special.R b/samples/client/petstore/R-httr2/R/special.R index a554310db9e..08f3f6b7d60 100644 --- a/samples/client/petstore/R-httr2/R/special.R +++ b/samples/client/petstore/R-httr2/R/special.R @@ -99,7 +99,6 @@ Special <- R6::R6Class( SpecialObject[["empty_string"]] <- self$`empty_string` } - SpecialObject }, #' Deserialize JSON string into an instance of Special @@ -191,7 +190,7 @@ Special <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of Special #' diff --git a/samples/client/petstore/R-httr2/R/tag.R b/samples/client/petstore/R-httr2/R/tag.R index 2dc0be8e2f7..6938b12fbe8 100644 --- a/samples/client/petstore/R-httr2/R/tag.R +++ b/samples/client/petstore/R-httr2/R/tag.R @@ -55,7 +55,6 @@ Tag <- R6::R6Class( TagObject[["name"]] <- self$`name` } - TagObject }, #' Deserialize JSON string into an instance of Tag @@ -103,7 +102,7 @@ Tag <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of Tag #' diff --git a/samples/client/petstore/R-httr2/R/update_pet_request.R b/samples/client/petstore/R-httr2/R/update_pet_request.R index 795498c49b3..1ed8f672598 100644 --- a/samples/client/petstore/R-httr2/R/update_pet_request.R +++ b/samples/client/petstore/R-httr2/R/update_pet_request.R @@ -54,7 +54,6 @@ UpdatePetRequest <- R6::R6Class( UpdatePetRequestObject[["binaryDataN2Information"]] <- self$`binaryDataN2Information` } - UpdatePetRequestObject }, #' Deserialize JSON string into an instance of UpdatePetRequest @@ -104,7 +103,7 @@ UpdatePetRequest <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of UpdatePetRequest #' diff --git a/samples/client/petstore/R-httr2/R/user.R b/samples/client/petstore/R-httr2/R/user.R index bb90189bddd..6a1eaf3d76d 100644 --- a/samples/client/petstore/R-httr2/R/user.R +++ b/samples/client/petstore/R-httr2/R/user.R @@ -121,7 +121,6 @@ User <- R6::R6Class( UserObject[["userStatus"]] <- self$`userStatus` } - UserObject }, #' Deserialize JSON string into an instance of User @@ -235,7 +234,7 @@ User <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of User #' diff --git a/samples/client/petstore/R-httr2/R/whale.R b/samples/client/petstore/R-httr2/R/whale.R index 31738ea3622..5f25cd494cb 100644 --- a/samples/client/petstore/R-httr2/R/whale.R +++ b/samples/client/petstore/R-httr2/R/whale.R @@ -66,7 +66,6 @@ Whale <- R6::R6Class( WhaleObject[["className"]] <- self$`className` } - WhaleObject }, #' Deserialize JSON string into an instance of Whale @@ -125,7 +124,7 @@ Whale <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of Whale #' diff --git a/samples/client/petstore/R-httr2/R/zebra.R b/samples/client/petstore/R-httr2/R/zebra.R index d9d2788aca9..bf76abb2996 100644 --- a/samples/client/petstore/R-httr2/R/zebra.R +++ b/samples/client/petstore/R-httr2/R/zebra.R @@ -55,7 +55,6 @@ Zebra <- R6::R6Class( ZebraObject[["className"]] <- self$`className` } - ZebraObject }, #' Deserialize JSON string into an instance of Zebra @@ -103,7 +102,7 @@ Zebra <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) }, #' Deserialize JSON string into an instance of Zebra #' diff --git a/samples/client/petstore/R-httr2/test_petstore.R b/samples/client/petstore/R-httr2/test_petstore.R index 81123cd6df4..7aa5a16c639 100644 --- a/samples/client/petstore/R-httr2/test_petstore.R +++ b/samples/client/petstore/R-httr2/test_petstore.R @@ -3,6 +3,14 @@ install.packages("petstore_1.0.0.tar.gz",repos=NULL, type="source") library(petstore) library(jsonlite) +t <- Tag$new() +t$id <- 123 +#t$additional_properties <- c("abc" = 849) +print(t$toJSON()) +print(t$toJSONString()) + +print("done tag") + t <- OneOfPrimitiveTypeTest$new() #t$fromJSONString("[1,2,3]") 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 432d1880556..ee7d3df437d 100644 --- a/samples/client/petstore/R/R/allof_tag_api_response.R +++ b/samples/client/petstore/R/R/allof_tag_api_response.R @@ -12,6 +12,7 @@ #' @field code integer [optional] #' @field type character [optional] #' @field message character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -23,6 +24,7 @@ AllofTagApiResponse <- R6::R6Class( `code` = NULL, `type` = NULL, `message` = NULL, + `additional_properties` = NULL, #' Initialize a new AllofTagApiResponse class. #' #' @description @@ -33,10 +35,11 @@ AllofTagApiResponse <- R6::R6Class( #' @param code code #' @param type type #' @param message message + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `id` = NULL, `name` = NULL, `code` = NULL, `type` = NULL, `message` = NULL, ... + `id` = NULL, `name` = NULL, `code` = NULL, `type` = NULL, `message` = NULL, additional_properties = NULL, ... ) { if (!is.null(`id`)) { stopifnot(is.numeric(`id`), length(`id`) == 1) @@ -58,6 +61,11 @@ AllofTagApiResponse <- R6::R6Class( stopifnot(is.character(`message`), length(`message`) == 1) self$`message` <- `message` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -88,6 +96,9 @@ AllofTagApiResponse <- R6::R6Class( AllofTagApiResponseObject[["message"]] <- self$`message` } + for (key in names(self$additional_properties)) { + AllofTagApiResponseObject[[key]] <- self$additional_properties[[key]] + } AllofTagApiResponseObject }, @@ -169,7 +180,12 @@ AllofTagApiResponse <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of AllofTagApiResponse #' diff --git a/samples/client/petstore/R/R/animal.R b/samples/client/petstore/R/R/animal.R index 05f963143d7..af3277925dc 100644 --- a/samples/client/petstore/R/R/animal.R +++ b/samples/client/petstore/R/R/animal.R @@ -9,6 +9,7 @@ #' @format An \code{R6Class} generator object #' @field className character #' @field color character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -17,6 +18,7 @@ Animal <- R6::R6Class( public = list( `className` = NULL, `color` = NULL, + `additional_properties` = NULL, #' Initialize a new Animal class. #' #' @description @@ -24,10 +26,11 @@ Animal <- R6::R6Class( #' #' @param className className #' @param color color. Default to "red". + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `className`, `color` = "red", ... + `className`, `color` = "red", additional_properties = NULL, ... ) { if (!missing(`className`)) { stopifnot(is.character(`className`), length(`className`) == 1) @@ -37,6 +40,11 @@ Animal <- R6::R6Class( stopifnot(is.character(`color`), length(`color`) == 1) self$`color` <- `color` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -55,6 +63,9 @@ Animal <- R6::R6Class( AnimalObject[["color"]] <- self$`color` } + for (key in names(self$additional_properties)) { + AnimalObject[[key]] <- self$additional_properties[[key]] + } AnimalObject }, @@ -103,7 +114,12 @@ Animal <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of Animal #' diff --git a/samples/client/petstore/R/R/basque_pig.R b/samples/client/petstore/R/R/basque_pig.R index fccd0a82581..5533893c45e 100644 --- a/samples/client/petstore/R/R/basque_pig.R +++ b/samples/client/petstore/R/R/basque_pig.R @@ -9,6 +9,7 @@ #' @format An \code{R6Class} generator object #' @field className character #' @field color character +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -17,6 +18,7 @@ BasquePig <- R6::R6Class( public = list( `className` = NULL, `color` = NULL, + `additional_properties` = NULL, #' Initialize a new BasquePig class. #' #' @description @@ -24,10 +26,11 @@ BasquePig <- R6::R6Class( #' #' @param className className #' @param color color + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `className`, `color`, ... + `className`, `color`, additional_properties = NULL, ... ) { if (!missing(`className`)) { stopifnot(is.character(`className`), length(`className`) == 1) @@ -37,6 +40,11 @@ BasquePig <- R6::R6Class( stopifnot(is.character(`color`), length(`color`) == 1) self$`color` <- `color` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -55,6 +63,9 @@ BasquePig <- R6::R6Class( BasquePigObject[["color"]] <- self$`color` } + for (key in names(self$additional_properties)) { + BasquePigObject[[key]] <- self$additional_properties[[key]] + } BasquePigObject }, @@ -103,7 +114,12 @@ BasquePig <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of BasquePig #' diff --git a/samples/client/petstore/R/R/cat.R b/samples/client/petstore/R/R/cat.R index 80cd2b7c7cd..b029e1064fd 100644 --- a/samples/client/petstore/R/R/cat.R +++ b/samples/client/petstore/R/R/cat.R @@ -10,6 +10,7 @@ #' @field className character #' @field color character [optional] #' @field declawed character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -20,6 +21,7 @@ Cat <- R6::R6Class( `className` = NULL, `color` = NULL, `declawed` = NULL, + `additional_properties` = NULL, #' Initialize a new Cat class. #' #' @description @@ -28,10 +30,11 @@ Cat <- R6::R6Class( #' @param className className #' @param color color. Default to "red". #' @param declawed declawed + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `className`, `color` = "red", `declawed` = NULL, ... + `className`, `color` = "red", `declawed` = NULL, additional_properties = NULL, ... ) { if (!missing(`className`)) { stopifnot(is.character(`className`), length(`className`) == 1) @@ -45,6 +48,11 @@ Cat <- R6::R6Class( stopifnot(is.logical(`declawed`), length(`declawed`) == 1) self$`declawed` <- `declawed` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -67,6 +75,9 @@ Cat <- R6::R6Class( CatObject[["declawed"]] <- self$`declawed` } + for (key in names(self$additional_properties)) { + CatObject[[key]] <- self$additional_properties[[key]] + } CatObject }, @@ -126,7 +137,12 @@ Cat <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of Cat #' diff --git a/samples/client/petstore/R/R/cat_all_of.R b/samples/client/petstore/R/R/cat_all_of.R index 9ea1650b6a3..24d913f89e0 100644 --- a/samples/client/petstore/R/R/cat_all_of.R +++ b/samples/client/petstore/R/R/cat_all_of.R @@ -8,6 +8,7 @@ #' @description CatAllOf Class #' @format An \code{R6Class} generator object #' @field declawed character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -15,21 +16,28 @@ CatAllOf <- R6::R6Class( "CatAllOf", public = list( `declawed` = NULL, + `additional_properties` = NULL, #' Initialize a new CatAllOf class. #' #' @description #' Initialize a new CatAllOf class. #' #' @param declawed declawed + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `declawed` = NULL, ... + `declawed` = NULL, additional_properties = NULL, ... ) { if (!is.null(`declawed`)) { stopifnot(is.logical(`declawed`), length(`declawed`) == 1) self$`declawed` <- `declawed` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -44,6 +52,9 @@ CatAllOf <- R6::R6Class( CatAllOfObject[["declawed"]] <- self$`declawed` } + for (key in names(self$additional_properties)) { + CatAllOfObject[[key]] <- self$additional_properties[[key]] + } CatAllOfObject }, @@ -81,7 +92,12 @@ CatAllOf <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of CatAllOf #' diff --git a/samples/client/petstore/R/R/category.R b/samples/client/petstore/R/R/category.R index a9d1c33a84c..95593d0cd7c 100644 --- a/samples/client/petstore/R/R/category.R +++ b/samples/client/petstore/R/R/category.R @@ -9,6 +9,7 @@ #' @format An \code{R6Class} generator object #' @field id integer [optional] #' @field name character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -17,6 +18,7 @@ Category <- R6::R6Class( public = list( `id` = NULL, `name` = NULL, + `additional_properties` = NULL, #' Initialize a new Category class. #' #' @description @@ -24,10 +26,11 @@ Category <- R6::R6Class( #' #' @param id id #' @param name name + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `id` = NULL, `name` = NULL, ... + `id` = NULL, `name` = NULL, additional_properties = NULL, ... ) { if (!is.null(`id`)) { stopifnot(is.numeric(`id`), length(`id`) == 1) @@ -37,6 +40,11 @@ Category <- R6::R6Class( stopifnot(is.character(`name`), length(`name`) == 1) self$`name` <- `name` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -55,6 +63,9 @@ Category <- R6::R6Class( CategoryObject[["name"]] <- self$`name` } + for (key in names(self$additional_properties)) { + CategoryObject[[key]] <- self$additional_properties[[key]] + } CategoryObject }, @@ -103,7 +114,12 @@ Category <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of Category #' diff --git a/samples/client/petstore/R/R/danish_pig.R b/samples/client/petstore/R/R/danish_pig.R index 3432d23df82..82407e0f46f 100644 --- a/samples/client/petstore/R/R/danish_pig.R +++ b/samples/client/petstore/R/R/danish_pig.R @@ -9,6 +9,7 @@ #' @format An \code{R6Class} generator object #' @field className character #' @field size integer +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -17,6 +18,7 @@ DanishPig <- R6::R6Class( public = list( `className` = NULL, `size` = NULL, + `additional_properties` = NULL, #' Initialize a new DanishPig class. #' #' @description @@ -24,10 +26,11 @@ DanishPig <- R6::R6Class( #' #' @param className className #' @param size size + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `className`, `size`, ... + `className`, `size`, additional_properties = NULL, ... ) { if (!missing(`className`)) { stopifnot(is.character(`className`), length(`className`) == 1) @@ -37,6 +40,11 @@ DanishPig <- R6::R6Class( stopifnot(is.numeric(`size`), length(`size`) == 1) self$`size` <- `size` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -55,6 +63,9 @@ DanishPig <- R6::R6Class( DanishPigObject[["size"]] <- self$`size` } + for (key in names(self$additional_properties)) { + DanishPigObject[[key]] <- self$additional_properties[[key]] + } DanishPigObject }, @@ -103,7 +114,12 @@ DanishPig <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of DanishPig #' diff --git a/samples/client/petstore/R/R/dog.R b/samples/client/petstore/R/R/dog.R index aade3e1cc95..6c651ed4ca4 100644 --- a/samples/client/petstore/R/R/dog.R +++ b/samples/client/petstore/R/R/dog.R @@ -10,6 +10,7 @@ #' @field className character #' @field color character [optional] #' @field breed character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -20,6 +21,7 @@ Dog <- R6::R6Class( `className` = NULL, `color` = NULL, `breed` = NULL, + `additional_properties` = NULL, #' Initialize a new Dog class. #' #' @description @@ -28,10 +30,11 @@ Dog <- R6::R6Class( #' @param className className #' @param color color. Default to "red". #' @param breed breed + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `className`, `color` = "red", `breed` = NULL, ... + `className`, `color` = "red", `breed` = NULL, additional_properties = NULL, ... ) { if (!missing(`className`)) { stopifnot(is.character(`className`), length(`className`) == 1) @@ -45,6 +48,11 @@ Dog <- R6::R6Class( stopifnot(is.character(`breed`), length(`breed`) == 1) self$`breed` <- `breed` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -67,6 +75,9 @@ Dog <- R6::R6Class( DogObject[["breed"]] <- self$`breed` } + for (key in names(self$additional_properties)) { + DogObject[[key]] <- self$additional_properties[[key]] + } DogObject }, @@ -126,7 +137,12 @@ Dog <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of Dog #' diff --git a/samples/client/petstore/R/R/dog_all_of.R b/samples/client/petstore/R/R/dog_all_of.R index 717343a9492..f566a558dde 100644 --- a/samples/client/petstore/R/R/dog_all_of.R +++ b/samples/client/petstore/R/R/dog_all_of.R @@ -8,6 +8,7 @@ #' @description DogAllOf Class #' @format An \code{R6Class} generator object #' @field breed character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -15,21 +16,28 @@ DogAllOf <- R6::R6Class( "DogAllOf", public = list( `breed` = NULL, + `additional_properties` = NULL, #' Initialize a new DogAllOf class. #' #' @description #' Initialize a new DogAllOf class. #' #' @param breed breed + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `breed` = NULL, ... + `breed` = NULL, additional_properties = NULL, ... ) { if (!is.null(`breed`)) { stopifnot(is.character(`breed`), length(`breed`) == 1) self$`breed` <- `breed` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -44,6 +52,9 @@ DogAllOf <- R6::R6Class( DogAllOfObject[["breed"]] <- self$`breed` } + for (key in names(self$additional_properties)) { + DogAllOfObject[[key]] <- self$additional_properties[[key]] + } DogAllOfObject }, @@ -81,7 +92,12 @@ DogAllOf <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of DogAllOf #' diff --git a/samples/client/petstore/R/R/model_api_response.R b/samples/client/petstore/R/R/model_api_response.R index 3420a44585c..a12add88cba 100644 --- a/samples/client/petstore/R/R/model_api_response.R +++ b/samples/client/petstore/R/R/model_api_response.R @@ -10,6 +10,7 @@ #' @field code integer [optional] #' @field type character [optional] #' @field message character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -19,6 +20,7 @@ ModelApiResponse <- R6::R6Class( `code` = NULL, `type` = NULL, `message` = NULL, + `additional_properties` = NULL, #' Initialize a new ModelApiResponse class. #' #' @description @@ -27,10 +29,11 @@ ModelApiResponse <- R6::R6Class( #' @param code code #' @param type type #' @param message message + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `code` = NULL, `type` = NULL, `message` = NULL, ... + `code` = NULL, `type` = NULL, `message` = NULL, additional_properties = NULL, ... ) { if (!is.null(`code`)) { stopifnot(is.numeric(`code`), length(`code`) == 1) @@ -44,6 +47,11 @@ ModelApiResponse <- R6::R6Class( stopifnot(is.character(`message`), length(`message`) == 1) self$`message` <- `message` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -66,6 +74,9 @@ ModelApiResponse <- R6::R6Class( ModelApiResponseObject[["message"]] <- self$`message` } + for (key in names(self$additional_properties)) { + ModelApiResponseObject[[key]] <- self$additional_properties[[key]] + } ModelApiResponseObject }, @@ -125,7 +136,12 @@ ModelApiResponse <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of ModelApiResponse #' diff --git a/samples/client/petstore/R/R/nested_one_of.R b/samples/client/petstore/R/R/nested_one_of.R index ce6c381d818..01143c027a1 100644 --- a/samples/client/petstore/R/R/nested_one_of.R +++ b/samples/client/petstore/R/R/nested_one_of.R @@ -9,6 +9,7 @@ #' @format An \code{R6Class} generator object #' @field size integer [optional] #' @field nested_pig \link{Pig} [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -17,6 +18,7 @@ NestedOneOf <- R6::R6Class( public = list( `size` = NULL, `nested_pig` = NULL, + `additional_properties` = NULL, #' Initialize a new NestedOneOf class. #' #' @description @@ -24,10 +26,11 @@ NestedOneOf <- R6::R6Class( #' #' @param size size #' @param nested_pig nested_pig + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `size` = NULL, `nested_pig` = NULL, ... + `size` = NULL, `nested_pig` = NULL, additional_properties = NULL, ... ) { if (!is.null(`size`)) { stopifnot(is.numeric(`size`), length(`size`) == 1) @@ -37,6 +40,11 @@ NestedOneOf <- R6::R6Class( stopifnot(R6::is.R6(`nested_pig`)) self$`nested_pig` <- `nested_pig` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -55,6 +63,9 @@ NestedOneOf <- R6::R6Class( NestedOneOfObject[["nested_pig"]] <- self$`nested_pig`$toJSON() } + for (key in names(self$additional_properties)) { + NestedOneOfObject[[key]] <- self$additional_properties[[key]] + } NestedOneOfObject }, @@ -105,7 +116,12 @@ NestedOneOf <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of NestedOneOf #' diff --git a/samples/client/petstore/R/R/order.R b/samples/client/petstore/R/R/order.R index cc86fbc0512..b37f0763b07 100644 --- a/samples/client/petstore/R/R/order.R +++ b/samples/client/petstore/R/R/order.R @@ -13,6 +13,7 @@ #' @field shipDate character [optional] #' @field status character [optional] #' @field complete character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -25,6 +26,7 @@ Order <- R6::R6Class( `shipDate` = NULL, `status` = NULL, `complete` = NULL, + `additional_properties` = NULL, #' Initialize a new Order class. #' #' @description @@ -36,10 +38,11 @@ Order <- R6::R6Class( #' @param shipDate shipDate #' @param status Order Status #' @param complete complete. Default to FALSE. + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `id` = NULL, `petId` = NULL, `quantity` = NULL, `shipDate` = NULL, `status` = NULL, `complete` = FALSE, ... + `id` = NULL, `petId` = NULL, `quantity` = NULL, `shipDate` = NULL, `status` = NULL, `complete` = FALSE, additional_properties = NULL, ... ) { if (!is.null(`id`)) { stopifnot(is.numeric(`id`), length(`id`) == 1) @@ -65,6 +68,11 @@ Order <- R6::R6Class( stopifnot(is.logical(`complete`), length(`complete`) == 1) self$`complete` <- `complete` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -99,6 +107,9 @@ Order <- R6::R6Class( OrderObject[["complete"]] <- self$`complete` } + for (key in names(self$additional_properties)) { + OrderObject[[key]] <- self$additional_properties[[key]] + } OrderObject }, @@ -191,7 +202,12 @@ Order <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of Order #' diff --git a/samples/client/petstore/R/R/pet.R b/samples/client/petstore/R/R/pet.R index 707c9f1ec75..9dd8e7390d7 100644 --- a/samples/client/petstore/R/R/pet.R +++ b/samples/client/petstore/R/R/pet.R @@ -13,6 +13,7 @@ #' @field photoUrls list(character) #' @field tags list(\link{Tag}) [optional] #' @field status character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -25,6 +26,7 @@ Pet <- R6::R6Class( `photoUrls` = NULL, `tags` = NULL, `status` = NULL, + `additional_properties` = NULL, #' Initialize a new Pet class. #' #' @description @@ -36,10 +38,11 @@ Pet <- R6::R6Class( #' @param category category #' @param tags tags #' @param status pet status in the store + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `name`, `photoUrls`, `id` = NULL, `category` = NULL, `tags` = NULL, `status` = NULL, ... + `name`, `photoUrls`, `id` = NULL, `category` = NULL, `tags` = NULL, `status` = NULL, additional_properties = NULL, ... ) { if (!missing(`name`)) { stopifnot(is.character(`name`), length(`name`) == 1) @@ -67,6 +70,11 @@ Pet <- R6::R6Class( stopifnot(is.character(`status`), length(`status`) == 1) self$`status` <- `status` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -101,6 +109,9 @@ Pet <- R6::R6Class( PetObject[["status"]] <- self$`status` } + for (key in names(self$additional_properties)) { + PetObject[[key]] <- self$additional_properties[[key]] + } PetObject }, @@ -195,7 +206,12 @@ Pet <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of Pet #' diff --git a/samples/client/petstore/R/R/special.R b/samples/client/petstore/R/R/special.R index a554310db9e..388300f0b47 100644 --- a/samples/client/petstore/R/R/special.R +++ b/samples/client/petstore/R/R/special.R @@ -13,6 +13,7 @@ #' @field 123_number character [optional] #' @field array[test] character [optional] #' @field empty_string character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -25,6 +26,7 @@ Special <- R6::R6Class( `123_number` = NULL, `array[test]` = NULL, `empty_string` = NULL, + `additional_properties` = NULL, #' Initialize a new Special class. #' #' @description @@ -36,10 +38,11 @@ Special <- R6::R6Class( #' @param 123_number 123_number #' @param array[test] array[test] #' @param empty_string empty_string + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `item_self` = NULL, `item_private` = NULL, `item_super` = NULL, `123_number` = NULL, `array[test]` = NULL, `empty_string` = NULL, ... + `item_self` = NULL, `item_private` = NULL, `item_super` = NULL, `123_number` = NULL, `array[test]` = NULL, `empty_string` = NULL, additional_properties = NULL, ... ) { if (!is.null(`item_self`)) { stopifnot(is.numeric(`item_self`), length(`item_self`) == 1) @@ -65,6 +68,11 @@ Special <- R6::R6Class( stopifnot(is.character(`empty_string`), length(`empty_string`) == 1) self$`empty_string` <- `empty_string` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -99,6 +107,9 @@ Special <- R6::R6Class( SpecialObject[["empty_string"]] <- self$`empty_string` } + for (key in names(self$additional_properties)) { + SpecialObject[[key]] <- self$additional_properties[[key]] + } SpecialObject }, @@ -191,7 +202,12 @@ Special <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of Special #' diff --git a/samples/client/petstore/R/R/tag.R b/samples/client/petstore/R/R/tag.R index 2dc0be8e2f7..2475ccbdd88 100644 --- a/samples/client/petstore/R/R/tag.R +++ b/samples/client/petstore/R/R/tag.R @@ -9,6 +9,7 @@ #' @format An \code{R6Class} generator object #' @field id integer [optional] #' @field name character [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -17,6 +18,7 @@ Tag <- R6::R6Class( public = list( `id` = NULL, `name` = NULL, + `additional_properties` = NULL, #' Initialize a new Tag class. #' #' @description @@ -24,10 +26,11 @@ Tag <- R6::R6Class( #' #' @param id id #' @param name name + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `id` = NULL, `name` = NULL, ... + `id` = NULL, `name` = NULL, additional_properties = NULL, ... ) { if (!is.null(`id`)) { stopifnot(is.numeric(`id`), length(`id`) == 1) @@ -37,6 +40,11 @@ Tag <- R6::R6Class( stopifnot(is.character(`name`), length(`name`) == 1) self$`name` <- `name` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -55,6 +63,9 @@ Tag <- R6::R6Class( TagObject[["name"]] <- self$`name` } + for (key in names(self$additional_properties)) { + TagObject[[key]] <- self$additional_properties[[key]] + } TagObject }, @@ -103,7 +114,12 @@ Tag <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of Tag #' diff --git a/samples/client/petstore/R/R/update_pet_request.R b/samples/client/petstore/R/R/update_pet_request.R index 795498c49b3..6f0b39689fa 100644 --- a/samples/client/petstore/R/R/update_pet_request.R +++ b/samples/client/petstore/R/R/update_pet_request.R @@ -9,6 +9,7 @@ #' @format An \code{R6Class} generator object #' @field jsonData \link{Pet} [optional] #' @field binaryDataN2Information data.frame [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -17,6 +18,7 @@ UpdatePetRequest <- R6::R6Class( public = list( `jsonData` = NULL, `binaryDataN2Information` = NULL, + `additional_properties` = NULL, #' Initialize a new UpdatePetRequest class. #' #' @description @@ -24,10 +26,11 @@ UpdatePetRequest <- R6::R6Class( #' #' @param jsonData jsonData #' @param binaryDataN2Information binaryDataN2Information + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `jsonData` = NULL, `binaryDataN2Information` = NULL, ... + `jsonData` = NULL, `binaryDataN2Information` = NULL, additional_properties = NULL, ... ) { if (!is.null(`jsonData`)) { stopifnot(R6::is.R6(`jsonData`)) @@ -36,6 +39,11 @@ UpdatePetRequest <- R6::R6Class( if (!is.null(`binaryDataN2Information`)) { self$`binaryDataN2Information` <- `binaryDataN2Information` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -54,6 +62,9 @@ UpdatePetRequest <- R6::R6Class( UpdatePetRequestObject[["binaryDataN2Information"]] <- self$`binaryDataN2Information` } + for (key in names(self$additional_properties)) { + UpdatePetRequestObject[[key]] <- self$additional_properties[[key]] + } UpdatePetRequestObject }, @@ -104,7 +115,12 @@ UpdatePetRequest <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of UpdatePetRequest #' diff --git a/samples/client/petstore/R/R/user.R b/samples/client/petstore/R/R/user.R index bb90189bddd..bf4c323d5ce 100644 --- a/samples/client/petstore/R/R/user.R +++ b/samples/client/petstore/R/R/user.R @@ -15,6 +15,7 @@ #' @field password character [optional] #' @field phone character [optional] #' @field userStatus integer [optional] +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -29,6 +30,7 @@ User <- R6::R6Class( `password` = NULL, `phone` = NULL, `userStatus` = NULL, + `additional_properties` = NULL, #' Initialize a new User class. #' #' @description @@ -42,10 +44,11 @@ User <- R6::R6Class( #' @param password password #' @param phone phone #' @param userStatus User Status + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `id` = NULL, `username` = NULL, `firstName` = NULL, `lastName` = NULL, `email` = NULL, `password` = NULL, `phone` = NULL, `userStatus` = NULL, ... + `id` = NULL, `username` = NULL, `firstName` = NULL, `lastName` = NULL, `email` = NULL, `password` = NULL, `phone` = NULL, `userStatus` = NULL, additional_properties = NULL, ... ) { if (!is.null(`id`)) { stopifnot(is.numeric(`id`), length(`id`) == 1) @@ -79,6 +82,11 @@ User <- R6::R6Class( stopifnot(is.numeric(`userStatus`), length(`userStatus`) == 1) self$`userStatus` <- `userStatus` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -121,6 +129,9 @@ User <- R6::R6Class( UserObject[["userStatus"]] <- self$`userStatus` } + for (key in names(self$additional_properties)) { + UserObject[[key]] <- self$additional_properties[[key]] + } UserObject }, @@ -235,7 +246,12 @@ User <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of User #' diff --git a/samples/client/petstore/R/R/whale.R b/samples/client/petstore/R/R/whale.R index 31738ea3622..0e9b7f2dc8f 100644 --- a/samples/client/petstore/R/R/whale.R +++ b/samples/client/petstore/R/R/whale.R @@ -10,6 +10,7 @@ #' @field hasBaleen character [optional] #' @field hasTeeth character [optional] #' @field className character +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -19,6 +20,7 @@ Whale <- R6::R6Class( `hasBaleen` = NULL, `hasTeeth` = NULL, `className` = NULL, + `additional_properties` = NULL, #' Initialize a new Whale class. #' #' @description @@ -27,10 +29,11 @@ Whale <- R6::R6Class( #' @param className className #' @param hasBaleen hasBaleen #' @param hasTeeth hasTeeth + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `className`, `hasBaleen` = NULL, `hasTeeth` = NULL, ... + `className`, `hasBaleen` = NULL, `hasTeeth` = NULL, additional_properties = NULL, ... ) { if (!missing(`className`)) { stopifnot(is.character(`className`), length(`className`) == 1) @@ -44,6 +47,11 @@ Whale <- R6::R6Class( stopifnot(is.logical(`hasTeeth`), length(`hasTeeth`) == 1) self$`hasTeeth` <- `hasTeeth` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -66,6 +74,9 @@ Whale <- R6::R6Class( WhaleObject[["className"]] <- self$`className` } + for (key in names(self$additional_properties)) { + WhaleObject[[key]] <- self$additional_properties[[key]] + } WhaleObject }, @@ -125,7 +136,12 @@ Whale <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of Whale #' diff --git a/samples/client/petstore/R/R/zebra.R b/samples/client/petstore/R/R/zebra.R index d9d2788aca9..aff7c8ddedc 100644 --- a/samples/client/petstore/R/R/zebra.R +++ b/samples/client/petstore/R/R/zebra.R @@ -9,6 +9,7 @@ #' @format An \code{R6Class} generator object #' @field type character [optional] #' @field className character +#' @field additional_properties named list(character) [optional] #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -17,6 +18,7 @@ Zebra <- R6::R6Class( public = list( `type` = NULL, `className` = NULL, + `additional_properties` = NULL, #' Initialize a new Zebra class. #' #' @description @@ -24,10 +26,11 @@ Zebra <- R6::R6Class( #' #' @param className className #' @param type type + #' @param additional_properties additonal properties (optional) #' @param ... Other optional arguments. #' @export initialize = function( - `className`, `type` = NULL, ... + `className`, `type` = NULL, additional_properties = NULL, ... ) { if (!missing(`className`)) { stopifnot(is.character(`className`), length(`className`) == 1) @@ -37,6 +40,11 @@ Zebra <- R6::R6Class( stopifnot(is.character(`type`), length(`type`) == 1) self$`type` <- `type` } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } }, #' To JSON string #' @@ -55,6 +63,9 @@ Zebra <- R6::R6Class( ZebraObject[["className"]] <- self$`className` } + for (key in names(self$additional_properties)) { + ZebraObject[[key]] <- self$additional_properties[[key]] + } ZebraObject }, @@ -103,7 +114,12 @@ Zebra <- R6::R6Class( } ) jsoncontent <- paste(jsoncontent, collapse = ",") - as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + json_obj[[key]] <- self$additional_properties[[key]] + } + json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) }, #' Deserialize JSON string into an instance of Zebra #'