From c3970d73483d002e05e0896938332d18bc2d1766 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 23 Jun 2022 20:47:12 +0800 Subject: [PATCH] update r model doc (#12676) --- .../main/resources/r/modelGeneric.mustache | 54 ++++++++++++++-- .../petstore/R/R/allof_tag_api_response.R | 57 ++++++++++++++--- samples/client/petstore/R/R/animal.R | 51 +++++++++++++-- samples/client/petstore/R/R/basque_pig.R | 51 +++++++++++++-- samples/client/petstore/R/R/cat.R | 53 ++++++++++++++-- samples/client/petstore/R/R/cat_all_of.R | 49 +++++++++++++-- samples/client/petstore/R/R/category.R | 51 +++++++++++++-- samples/client/petstore/R/R/danish_pig.R | 51 +++++++++++++-- samples/client/petstore/R/R/dog.R | 53 ++++++++++++++-- samples/client/petstore/R/R/dog_all_of.R | 49 +++++++++++++-- .../client/petstore/R/R/model_api_response.R | 53 ++++++++++++++-- samples/client/petstore/R/R/order.R | 59 ++++++++++++++--- samples/client/petstore/R/R/pet.R | 59 ++++++++++++++--- samples/client/petstore/R/R/special.R | 53 ++++++++++++++-- samples/client/petstore/R/R/tag.R | 51 +++++++++++++-- .../client/petstore/R/R/update_pet_request.R | 51 +++++++++++++-- samples/client/petstore/R/R/user.R | 63 +++++++++++++++---- 17 files changed, 805 insertions(+), 103 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache index 4927eb52699..638dbccd836 100644 --- a/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache @@ -2,14 +2,10 @@ {{#model}} #' @docType class #' @title {{classname}} -#' #' @description {{classname}} Class -#' #' @format An \code{R6Class} generator object -#' {{#vars}} #' @field {{name}} {{title}} {{#isContainer}}{{#isArray}}list( {{/isArray}}{{#isMap}}named list( {{/isMap}}{{/isContainer}}{{^isPrimitiveType}}\link{{=<% %>=}}{<%/isPrimitiveType%><%={{ }}=%>{{#isContainer}}{{#items}}{{dataType}}{{/items}}{{/isContainer}}{{^isContainer}}{{dataType}}{{/isContainer}}{{=<% %>=}}<%^isPrimitiveType%>}<%={{ }}=%>{{/isPrimitiveType}}{{#isContainer}}{{#isArray}} ){{/isArray}}{{#isMap}} ){{/isMap}}{{/isContainer}} {{^required}}[optional]{{/required}} -#' {{/vars}} #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON @@ -27,6 +23,19 @@ {{#vars}} `{{{name}}}` = NULL, {{/vars}} + #' Initialize a new {{{classname}}} class. + #' + #' @description + #' Initialize a new {{{classname}}} class. + #' + {{#requiredVars}} + #' @param {{name}} {{{description}}}{{^description}}{{{name}}}{{/description}} + {{/requiredVars}} + {{#optionalVars}} + #' @param {{name}} {{{description}}}{{^description}}{{{name}}}{{/description}}{{#defaultValue}}. Default to {{{.}}}.{{/defaultValue}} + {{/optionalVars}} + #' @param ... Other optional arguments. + #' @export initialize = function( {{#requiredVars}}`{{name}}`, {{/requiredVars}}{{#optionalVars}}`{{name}}`={{{defaultValue}}}{{^defaultValue}}NULL{{/defaultValue}}, {{/optionalVars}}... ) { @@ -119,6 +128,13 @@ } {{/optionalVars}} }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return {{{classname}}} in JSON format + #' @export toJSON = function() { {{classname}}Object <- list() {{#vars}} @@ -155,6 +171,14 @@ {{classname}}Object }, + #' Deserialize JSON string into an instance of {{{classname}}} + #' + #' @description + #' Deserialize JSON string into an instance of {{{classname}}} + #' + #' @param {{classname}}Json the JSON input + #' @return the instance of {{{classname}}} + #' @export fromJSON = function({{classname}}Json) { {{classname}}Object <- jsonlite::fromJSON({{classname}}Json) {{#vars}} @@ -176,6 +200,13 @@ {{/vars}} self }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return {{{classname}}} in JSON format + #' @export toJSONString = function() { jsoncontent <- c( {{#vars}} @@ -237,6 +268,14 @@ jsoncontent <- paste(jsoncontent, collapse = ",") paste('{', jsoncontent, '}', sep = "") }, + #' Deserialize JSON string into an instance of {{{classname}}} + #' + #' @description + #' Deserialize JSON string into an instance of {{{classname}}} + #' + #' @param {{classname}}Json the JSON input + #' @return the instance of {{{classname}}} + #' @export fromJSONString = function({{classname}}Json) { {{classname}}Object <- jsonlite::fromJSON({{classname}}Json) {{#vars}} @@ -255,6 +294,13 @@ {{/vars}} self }, + #' Validate JSON input with respect to {{classname}} + #' + #' @description + #' Validate JSON input with respect to {{classname}} and throw an exception if invalid + #' + #' @param input the JSON input + #' @export validateJSON = function(input) { input_json <- jsonlite::fromJSON(input) {{#requiredVars}} 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 6141dc37413..66fe3f812ff 100644 --- a/samples/client/petstore/R/R/allof_tag_api_response.R +++ b/samples/client/petstore/R/R/allof_tag_api_response.R @@ -8,21 +8,13 @@ #' @docType class #' @title AllofTagApiResponse -#' #' @description AllofTagApiResponse Class -#' #' @format An \code{R6Class} generator object -#' #' @field id integer [optional] -#' #' @field name character [optional] -#' #' @field code integer [optional] -#' #' @field type character [optional] -#' #' @field message character [optional] -#' #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -34,6 +26,18 @@ AllofTagApiResponse <- R6::R6Class( `code` = NULL, `type` = NULL, `message` = NULL, + #' Initialize a new AllofTagApiResponse class. + #' + #' @description + #' Initialize a new AllofTagApiResponse class. + #' + #' @param id id + #' @param name name + #' @param code code + #' @param type type + #' @param message message + #' @param ... Other optional arguments. + #' @export initialize = function( `id`=NULL, `name`=NULL, `code`=NULL, `type`=NULL, `message`=NULL, ... ) { @@ -58,6 +62,13 @@ AllofTagApiResponse <- R6::R6Class( self$`message` <- `message` } }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return AllofTagApiResponse in JSON format + #' @export toJSON = function() { AllofTagApiResponseObject <- list() if (!is.null(self$`id`)) { @@ -83,6 +94,14 @@ AllofTagApiResponse <- R6::R6Class( AllofTagApiResponseObject }, + #' Deserialize JSON string into an instance of AllofTagApiResponse + #' + #' @description + #' Deserialize JSON string into an instance of AllofTagApiResponse + #' + #' @param AllofTagApiResponseJson the JSON input + #' @return the instance of AllofTagApiResponse + #' @export fromJSON = function(AllofTagApiResponseJson) { AllofTagApiResponseObject <- jsonlite::fromJSON(AllofTagApiResponseJson) if (!is.null(AllofTagApiResponseObject$`id`)) { @@ -102,6 +121,13 @@ AllofTagApiResponse <- R6::R6Class( } self }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return AllofTagApiResponse in JSON format + #' @export toJSONString = function() { jsoncontent <- c( if (!is.null(self$`id`)) { @@ -143,6 +169,14 @@ AllofTagApiResponse <- R6::R6Class( jsoncontent <- paste(jsoncontent, collapse = ",") paste('{', jsoncontent, '}', sep = "") }, + #' Deserialize JSON string into an instance of AllofTagApiResponse + #' + #' @description + #' Deserialize JSON string into an instance of AllofTagApiResponse + #' + #' @param AllofTagApiResponseJson the JSON input + #' @return the instance of AllofTagApiResponse + #' @export fromJSONString = function(AllofTagApiResponseJson) { AllofTagApiResponseObject <- jsonlite::fromJSON(AllofTagApiResponseJson) self$`id` <- AllofTagApiResponseObject$`id` @@ -152,6 +186,13 @@ AllofTagApiResponse <- R6::R6Class( self$`message` <- AllofTagApiResponseObject$`message` self }, + #' Validate JSON input with respect to AllofTagApiResponse + #' + #' @description + #' Validate JSON input with respect to AllofTagApiResponse and throw an exception if invalid + #' + #' @param input the JSON input + #' @export validateJSON = function(input) { input_json <- jsonlite::fromJSON(input) } diff --git a/samples/client/petstore/R/R/animal.R b/samples/client/petstore/R/R/animal.R index 86e043d62f6..fae32d068a0 100644 --- a/samples/client/petstore/R/R/animal.R +++ b/samples/client/petstore/R/R/animal.R @@ -8,15 +8,10 @@ #' @docType class #' @title Animal -#' #' @description Animal Class -#' #' @format An \code{R6Class} generator object -#' #' @field className character -#' #' @field color character [optional] -#' #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -25,6 +20,15 @@ Animal <- R6::R6Class( public = list( `className` = NULL, `color` = NULL, + #' Initialize a new Animal class. + #' + #' @description + #' Initialize a new Animal class. + #' + #' @param className className + #' @param color color. Default to 'red'. + #' @param ... Other optional arguments. + #' @export initialize = function( `className`, `color`='red', ... ) { @@ -37,6 +41,13 @@ Animal <- R6::R6Class( self$`color` <- `color` } }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Animal in JSON format + #' @export toJSON = function() { AnimalObject <- list() if (!is.null(self$`className`)) { @@ -50,6 +61,14 @@ Animal <- R6::R6Class( AnimalObject }, + #' Deserialize JSON string into an instance of Animal + #' + #' @description + #' Deserialize JSON string into an instance of Animal + #' + #' @param AnimalJson the JSON input + #' @return the instance of Animal + #' @export fromJSON = function(AnimalJson) { AnimalObject <- jsonlite::fromJSON(AnimalJson) if (!is.null(AnimalObject$`className`)) { @@ -60,6 +79,13 @@ Animal <- R6::R6Class( } self }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Animal in JSON format + #' @export toJSONString = function() { jsoncontent <- c( if (!is.null(self$`className`)) { @@ -80,12 +106,27 @@ Animal <- R6::R6Class( jsoncontent <- paste(jsoncontent, collapse = ",") paste('{', jsoncontent, '}', sep = "") }, + #' Deserialize JSON string into an instance of Animal + #' + #' @description + #' Deserialize JSON string into an instance of Animal + #' + #' @param AnimalJson the JSON input + #' @return the instance of Animal + #' @export fromJSONString = function(AnimalJson) { AnimalObject <- jsonlite::fromJSON(AnimalJson) self$`className` <- AnimalObject$`className` self$`color` <- AnimalObject$`color` self }, + #' Validate JSON input with respect to Animal + #' + #' @description + #' Validate JSON input with respect to Animal and throw an exception if invalid + #' + #' @param input the JSON input + #' @export validateJSON = function(input) { input_json <- jsonlite::fromJSON(input) # check the required field `className` diff --git a/samples/client/petstore/R/R/basque_pig.R b/samples/client/petstore/R/R/basque_pig.R index 3534bd2cc5c..ab045fd66a3 100644 --- a/samples/client/petstore/R/R/basque_pig.R +++ b/samples/client/petstore/R/R/basque_pig.R @@ -8,15 +8,10 @@ #' @docType class #' @title BasquePig -#' #' @description BasquePig Class -#' #' @format An \code{R6Class} generator object -#' #' @field className character -#' #' @field color character -#' #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -25,6 +20,15 @@ BasquePig <- R6::R6Class( public = list( `className` = NULL, `color` = NULL, + #' Initialize a new BasquePig class. + #' + #' @description + #' Initialize a new BasquePig class. + #' + #' @param className className + #' @param color color + #' @param ... Other optional arguments. + #' @export initialize = function( `className`, `color`, ... ) { @@ -37,6 +41,13 @@ BasquePig <- R6::R6Class( self$`color` <- `color` } }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return BasquePig in JSON format + #' @export toJSON = function() { BasquePigObject <- list() if (!is.null(self$`className`)) { @@ -50,6 +61,14 @@ BasquePig <- R6::R6Class( BasquePigObject }, + #' Deserialize JSON string into an instance of BasquePig + #' + #' @description + #' Deserialize JSON string into an instance of BasquePig + #' + #' @param BasquePigJson the JSON input + #' @return the instance of BasquePig + #' @export fromJSON = function(BasquePigJson) { BasquePigObject <- jsonlite::fromJSON(BasquePigJson) if (!is.null(BasquePigObject$`className`)) { @@ -60,6 +79,13 @@ BasquePig <- R6::R6Class( } self }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return BasquePig in JSON format + #' @export toJSONString = function() { jsoncontent <- c( if (!is.null(self$`className`)) { @@ -80,12 +106,27 @@ BasquePig <- R6::R6Class( jsoncontent <- paste(jsoncontent, collapse = ",") paste('{', jsoncontent, '}', sep = "") }, + #' Deserialize JSON string into an instance of BasquePig + #' + #' @description + #' Deserialize JSON string into an instance of BasquePig + #' + #' @param BasquePigJson the JSON input + #' @return the instance of BasquePig + #' @export fromJSONString = function(BasquePigJson) { BasquePigObject <- jsonlite::fromJSON(BasquePigJson) self$`className` <- BasquePigObject$`className` self$`color` <- BasquePigObject$`color` self }, + #' Validate JSON input with respect to BasquePig + #' + #' @description + #' Validate JSON input with respect to BasquePig and throw an exception if invalid + #' + #' @param input the JSON input + #' @export validateJSON = function(input) { input_json <- jsonlite::fromJSON(input) # check the required field `className` diff --git a/samples/client/petstore/R/R/cat.R b/samples/client/petstore/R/R/cat.R index 97c75ad6135..7154e09ea7f 100644 --- a/samples/client/petstore/R/R/cat.R +++ b/samples/client/petstore/R/R/cat.R @@ -8,17 +8,11 @@ #' @docType class #' @title Cat -#' #' @description Cat Class -#' #' @format An \code{R6Class} generator object -#' #' @field className character -#' #' @field color character [optional] -#' #' @field declawed character [optional] -#' #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -29,6 +23,16 @@ Cat <- R6::R6Class( `className` = NULL, `color` = NULL, `declawed` = NULL, + #' Initialize a new Cat class. + #' + #' @description + #' Initialize a new Cat class. + #' + #' @param className className + #' @param color color. Default to 'red'. + #' @param declawed declawed + #' @param ... Other optional arguments. + #' @export initialize = function( `className`, `color`='red', `declawed`=NULL, ... ) { @@ -45,6 +49,13 @@ Cat <- R6::R6Class( self$`declawed` <- `declawed` } }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Cat in JSON format + #' @export toJSON = function() { CatObject <- list() if (!is.null(self$`className`)) { @@ -62,6 +73,14 @@ Cat <- R6::R6Class( CatObject }, + #' Deserialize JSON string into an instance of Cat + #' + #' @description + #' Deserialize JSON string into an instance of Cat + #' + #' @param CatJson the JSON input + #' @return the instance of Cat + #' @export fromJSON = function(CatJson) { CatObject <- jsonlite::fromJSON(CatJson) if (!is.null(CatObject$`className`)) { @@ -75,6 +94,13 @@ Cat <- R6::R6Class( } self }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Cat in JSON format + #' @export toJSONString = function() { jsoncontent <- c( if (!is.null(self$`className`)) { @@ -102,6 +128,14 @@ Cat <- R6::R6Class( jsoncontent <- paste(jsoncontent, collapse = ",") paste('{', jsoncontent, '}', sep = "") }, + #' Deserialize JSON string into an instance of Cat + #' + #' @description + #' Deserialize JSON string into an instance of Cat + #' + #' @param CatJson the JSON input + #' @return the instance of Cat + #' @export fromJSONString = function(CatJson) { CatObject <- jsonlite::fromJSON(CatJson) self$`className` <- CatObject$`className` @@ -109,6 +143,13 @@ Cat <- R6::R6Class( self$`declawed` <- CatObject$`declawed` self }, + #' Validate JSON input with respect to Cat + #' + #' @description + #' Validate JSON input with respect to Cat and throw an exception if invalid + #' + #' @param input the JSON input + #' @export validateJSON = function(input) { input_json <- jsonlite::fromJSON(input) # check the required field `className` diff --git a/samples/client/petstore/R/R/cat_all_of.R b/samples/client/petstore/R/R/cat_all_of.R index 6b5478aba50..a018a3d868f 100644 --- a/samples/client/petstore/R/R/cat_all_of.R +++ b/samples/client/petstore/R/R/cat_all_of.R @@ -8,13 +8,9 @@ #' @docType class #' @title CatAllOf -#' #' @description CatAllOf Class -#' #' @format An \code{R6Class} generator object -#' #' @field declawed character [optional] -#' #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -22,6 +18,14 @@ CatAllOf <- R6::R6Class( 'CatAllOf', public = list( `declawed` = NULL, + #' Initialize a new CatAllOf class. + #' + #' @description + #' Initialize a new CatAllOf class. + #' + #' @param declawed declawed + #' @param ... Other optional arguments. + #' @export initialize = function( `declawed`=NULL, ... ) { @@ -30,6 +34,13 @@ CatAllOf <- R6::R6Class( self$`declawed` <- `declawed` } }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return CatAllOf in JSON format + #' @export toJSON = function() { CatAllOfObject <- list() if (!is.null(self$`declawed`)) { @@ -39,6 +50,14 @@ CatAllOf <- R6::R6Class( CatAllOfObject }, + #' Deserialize JSON string into an instance of CatAllOf + #' + #' @description + #' Deserialize JSON string into an instance of CatAllOf + #' + #' @param CatAllOfJson the JSON input + #' @return the instance of CatAllOf + #' @export fromJSON = function(CatAllOfJson) { CatAllOfObject <- jsonlite::fromJSON(CatAllOfJson) if (!is.null(CatAllOfObject$`declawed`)) { @@ -46,6 +65,13 @@ CatAllOf <- R6::R6Class( } self }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return CatAllOf in JSON format + #' @export toJSONString = function() { jsoncontent <- c( if (!is.null(self$`declawed`)) { @@ -59,11 +85,26 @@ CatAllOf <- R6::R6Class( jsoncontent <- paste(jsoncontent, collapse = ",") paste('{', jsoncontent, '}', sep = "") }, + #' Deserialize JSON string into an instance of CatAllOf + #' + #' @description + #' Deserialize JSON string into an instance of CatAllOf + #' + #' @param CatAllOfJson the JSON input + #' @return the instance of CatAllOf + #' @export fromJSONString = function(CatAllOfJson) { CatAllOfObject <- jsonlite::fromJSON(CatAllOfJson) self$`declawed` <- CatAllOfObject$`declawed` self }, + #' Validate JSON input with respect to CatAllOf + #' + #' @description + #' Validate JSON input with respect to CatAllOf and throw an exception if invalid + #' + #' @param input the JSON input + #' @export validateJSON = function(input) { input_json <- jsonlite::fromJSON(input) } diff --git a/samples/client/petstore/R/R/category.R b/samples/client/petstore/R/R/category.R index 3fbe15d1d22..402ff0d5a15 100644 --- a/samples/client/petstore/R/R/category.R +++ b/samples/client/petstore/R/R/category.R @@ -8,15 +8,10 @@ #' @docType class #' @title Category -#' #' @description Category Class -#' #' @format An \code{R6Class} generator object -#' #' @field id integer [optional] -#' #' @field name character [optional] -#' #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -25,6 +20,15 @@ Category <- R6::R6Class( public = list( `id` = NULL, `name` = NULL, + #' Initialize a new Category class. + #' + #' @description + #' Initialize a new Category class. + #' + #' @param id id + #' @param name name + #' @param ... Other optional arguments. + #' @export initialize = function( `id`=NULL, `name`=NULL, ... ) { @@ -37,6 +41,13 @@ Category <- R6::R6Class( self$`name` <- `name` } }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Category in JSON format + #' @export toJSON = function() { CategoryObject <- list() if (!is.null(self$`id`)) { @@ -50,6 +61,14 @@ Category <- R6::R6Class( CategoryObject }, + #' Deserialize JSON string into an instance of Category + #' + #' @description + #' Deserialize JSON string into an instance of Category + #' + #' @param CategoryJson the JSON input + #' @return the instance of Category + #' @export fromJSON = function(CategoryJson) { CategoryObject <- jsonlite::fromJSON(CategoryJson) if (!is.null(CategoryObject$`id`)) { @@ -60,6 +79,13 @@ Category <- R6::R6Class( } self }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Category in JSON format + #' @export toJSONString = function() { jsoncontent <- c( if (!is.null(self$`id`)) { @@ -80,12 +106,27 @@ Category <- R6::R6Class( jsoncontent <- paste(jsoncontent, collapse = ",") paste('{', jsoncontent, '}', sep = "") }, + #' Deserialize JSON string into an instance of Category + #' + #' @description + #' Deserialize JSON string into an instance of Category + #' + #' @param CategoryJson the JSON input + #' @return the instance of Category + #' @export fromJSONString = function(CategoryJson) { CategoryObject <- jsonlite::fromJSON(CategoryJson) self$`id` <- CategoryObject$`id` self$`name` <- CategoryObject$`name` self }, + #' Validate JSON input with respect to Category + #' + #' @description + #' Validate JSON input with respect to Category and throw an exception if invalid + #' + #' @param input the JSON input + #' @export validateJSON = function(input) { input_json <- jsonlite::fromJSON(input) } diff --git a/samples/client/petstore/R/R/danish_pig.R b/samples/client/petstore/R/R/danish_pig.R index 9f6ec81b004..6307ef28fd4 100644 --- a/samples/client/petstore/R/R/danish_pig.R +++ b/samples/client/petstore/R/R/danish_pig.R @@ -8,15 +8,10 @@ #' @docType class #' @title DanishPig -#' #' @description DanishPig Class -#' #' @format An \code{R6Class} generator object -#' #' @field className character -#' #' @field size integer -#' #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -25,6 +20,15 @@ DanishPig <- R6::R6Class( public = list( `className` = NULL, `size` = NULL, + #' Initialize a new DanishPig class. + #' + #' @description + #' Initialize a new DanishPig class. + #' + #' @param className className + #' @param size size + #' @param ... Other optional arguments. + #' @export initialize = function( `className`, `size`, ... ) { @@ -37,6 +41,13 @@ DanishPig <- R6::R6Class( self$`size` <- `size` } }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return DanishPig in JSON format + #' @export toJSON = function() { DanishPigObject <- list() if (!is.null(self$`className`)) { @@ -50,6 +61,14 @@ DanishPig <- R6::R6Class( DanishPigObject }, + #' Deserialize JSON string into an instance of DanishPig + #' + #' @description + #' Deserialize JSON string into an instance of DanishPig + #' + #' @param DanishPigJson the JSON input + #' @return the instance of DanishPig + #' @export fromJSON = function(DanishPigJson) { DanishPigObject <- jsonlite::fromJSON(DanishPigJson) if (!is.null(DanishPigObject$`className`)) { @@ -60,6 +79,13 @@ DanishPig <- R6::R6Class( } self }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return DanishPig in JSON format + #' @export toJSONString = function() { jsoncontent <- c( if (!is.null(self$`className`)) { @@ -80,12 +106,27 @@ DanishPig <- R6::R6Class( jsoncontent <- paste(jsoncontent, collapse = ",") paste('{', jsoncontent, '}', sep = "") }, + #' Deserialize JSON string into an instance of DanishPig + #' + #' @description + #' Deserialize JSON string into an instance of DanishPig + #' + #' @param DanishPigJson the JSON input + #' @return the instance of DanishPig + #' @export fromJSONString = function(DanishPigJson) { DanishPigObject <- jsonlite::fromJSON(DanishPigJson) self$`className` <- DanishPigObject$`className` self$`size` <- DanishPigObject$`size` self }, + #' Validate JSON input with respect to DanishPig + #' + #' @description + #' Validate JSON input with respect to DanishPig and throw an exception if invalid + #' + #' @param input the JSON input + #' @export validateJSON = function(input) { input_json <- jsonlite::fromJSON(input) # check the required field `className` diff --git a/samples/client/petstore/R/R/dog.R b/samples/client/petstore/R/R/dog.R index b94645612f3..35843d69017 100644 --- a/samples/client/petstore/R/R/dog.R +++ b/samples/client/petstore/R/R/dog.R @@ -8,17 +8,11 @@ #' @docType class #' @title Dog -#' #' @description Dog Class -#' #' @format An \code{R6Class} generator object -#' #' @field className character -#' #' @field color character [optional] -#' #' @field breed character [optional] -#' #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -29,6 +23,16 @@ Dog <- R6::R6Class( `className` = NULL, `color` = NULL, `breed` = NULL, + #' Initialize a new Dog class. + #' + #' @description + #' Initialize a new Dog class. + #' + #' @param className className + #' @param color color. Default to 'red'. + #' @param breed breed + #' @param ... Other optional arguments. + #' @export initialize = function( `className`, `color`='red', `breed`=NULL, ... ) { @@ -45,6 +49,13 @@ Dog <- R6::R6Class( self$`breed` <- `breed` } }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Dog in JSON format + #' @export toJSON = function() { DogObject <- list() if (!is.null(self$`className`)) { @@ -62,6 +73,14 @@ Dog <- R6::R6Class( DogObject }, + #' Deserialize JSON string into an instance of Dog + #' + #' @description + #' Deserialize JSON string into an instance of Dog + #' + #' @param DogJson the JSON input + #' @return the instance of Dog + #' @export fromJSON = function(DogJson) { DogObject <- jsonlite::fromJSON(DogJson) if (!is.null(DogObject$`className`)) { @@ -75,6 +94,13 @@ Dog <- R6::R6Class( } self }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Dog in JSON format + #' @export toJSONString = function() { jsoncontent <- c( if (!is.null(self$`className`)) { @@ -102,6 +128,14 @@ Dog <- R6::R6Class( jsoncontent <- paste(jsoncontent, collapse = ",") paste('{', jsoncontent, '}', sep = "") }, + #' Deserialize JSON string into an instance of Dog + #' + #' @description + #' Deserialize JSON string into an instance of Dog + #' + #' @param DogJson the JSON input + #' @return the instance of Dog + #' @export fromJSONString = function(DogJson) { DogObject <- jsonlite::fromJSON(DogJson) self$`className` <- DogObject$`className` @@ -109,6 +143,13 @@ Dog <- R6::R6Class( self$`breed` <- DogObject$`breed` self }, + #' Validate JSON input with respect to Dog + #' + #' @description + #' Validate JSON input with respect to Dog and throw an exception if invalid + #' + #' @param input the JSON input + #' @export validateJSON = function(input) { input_json <- jsonlite::fromJSON(input) # check the required field `className` diff --git a/samples/client/petstore/R/R/dog_all_of.R b/samples/client/petstore/R/R/dog_all_of.R index bb7eabb456d..624bf12ce6f 100644 --- a/samples/client/petstore/R/R/dog_all_of.R +++ b/samples/client/petstore/R/R/dog_all_of.R @@ -8,13 +8,9 @@ #' @docType class #' @title DogAllOf -#' #' @description DogAllOf Class -#' #' @format An \code{R6Class} generator object -#' #' @field breed character [optional] -#' #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -22,6 +18,14 @@ DogAllOf <- R6::R6Class( 'DogAllOf', public = list( `breed` = NULL, + #' Initialize a new DogAllOf class. + #' + #' @description + #' Initialize a new DogAllOf class. + #' + #' @param breed breed + #' @param ... Other optional arguments. + #' @export initialize = function( `breed`=NULL, ... ) { @@ -30,6 +34,13 @@ DogAllOf <- R6::R6Class( self$`breed` <- `breed` } }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return DogAllOf in JSON format + #' @export toJSON = function() { DogAllOfObject <- list() if (!is.null(self$`breed`)) { @@ -39,6 +50,14 @@ DogAllOf <- R6::R6Class( DogAllOfObject }, + #' Deserialize JSON string into an instance of DogAllOf + #' + #' @description + #' Deserialize JSON string into an instance of DogAllOf + #' + #' @param DogAllOfJson the JSON input + #' @return the instance of DogAllOf + #' @export fromJSON = function(DogAllOfJson) { DogAllOfObject <- jsonlite::fromJSON(DogAllOfJson) if (!is.null(DogAllOfObject$`breed`)) { @@ -46,6 +65,13 @@ DogAllOf <- R6::R6Class( } self }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return DogAllOf in JSON format + #' @export toJSONString = function() { jsoncontent <- c( if (!is.null(self$`breed`)) { @@ -59,11 +85,26 @@ DogAllOf <- R6::R6Class( jsoncontent <- paste(jsoncontent, collapse = ",") paste('{', jsoncontent, '}', sep = "") }, + #' Deserialize JSON string into an instance of DogAllOf + #' + #' @description + #' Deserialize JSON string into an instance of DogAllOf + #' + #' @param DogAllOfJson the JSON input + #' @return the instance of DogAllOf + #' @export fromJSONString = function(DogAllOfJson) { DogAllOfObject <- jsonlite::fromJSON(DogAllOfJson) self$`breed` <- DogAllOfObject$`breed` self }, + #' Validate JSON input with respect to DogAllOf + #' + #' @description + #' Validate JSON input with respect to DogAllOf and throw an exception if invalid + #' + #' @param input the JSON input + #' @export validateJSON = function(input) { input_json <- jsonlite::fromJSON(input) } diff --git a/samples/client/petstore/R/R/model_api_response.R b/samples/client/petstore/R/R/model_api_response.R index 1d7ce8238c1..eadb8f5e44e 100644 --- a/samples/client/petstore/R/R/model_api_response.R +++ b/samples/client/petstore/R/R/model_api_response.R @@ -8,17 +8,11 @@ #' @docType class #' @title ModelApiResponse -#' #' @description ModelApiResponse Class -#' #' @format An \code{R6Class} generator object -#' #' @field code integer [optional] -#' #' @field type character [optional] -#' #' @field message character [optional] -#' #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -28,6 +22,16 @@ ModelApiResponse <- R6::R6Class( `code` = NULL, `type` = NULL, `message` = NULL, + #' Initialize a new ModelApiResponse class. + #' + #' @description + #' Initialize a new ModelApiResponse class. + #' + #' @param code code + #' @param type type + #' @param message message + #' @param ... Other optional arguments. + #' @export initialize = function( `code`=NULL, `type`=NULL, `message`=NULL, ... ) { @@ -44,6 +48,13 @@ ModelApiResponse <- R6::R6Class( self$`message` <- `message` } }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return ModelApiResponse in JSON format + #' @export toJSON = function() { ModelApiResponseObject <- list() if (!is.null(self$`code`)) { @@ -61,6 +72,14 @@ ModelApiResponse <- R6::R6Class( ModelApiResponseObject }, + #' Deserialize JSON string into an instance of ModelApiResponse + #' + #' @description + #' Deserialize JSON string into an instance of ModelApiResponse + #' + #' @param ModelApiResponseJson the JSON input + #' @return the instance of ModelApiResponse + #' @export fromJSON = function(ModelApiResponseJson) { ModelApiResponseObject <- jsonlite::fromJSON(ModelApiResponseJson) if (!is.null(ModelApiResponseObject$`code`)) { @@ -74,6 +93,13 @@ ModelApiResponse <- R6::R6Class( } self }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return ModelApiResponse in JSON format + #' @export toJSONString = function() { jsoncontent <- c( if (!is.null(self$`code`)) { @@ -101,6 +127,14 @@ ModelApiResponse <- R6::R6Class( jsoncontent <- paste(jsoncontent, collapse = ",") paste('{', jsoncontent, '}', sep = "") }, + #' Deserialize JSON string into an instance of ModelApiResponse + #' + #' @description + #' Deserialize JSON string into an instance of ModelApiResponse + #' + #' @param ModelApiResponseJson the JSON input + #' @return the instance of ModelApiResponse + #' @export fromJSONString = function(ModelApiResponseJson) { ModelApiResponseObject <- jsonlite::fromJSON(ModelApiResponseJson) self$`code` <- ModelApiResponseObject$`code` @@ -108,6 +142,13 @@ ModelApiResponse <- R6::R6Class( self$`message` <- ModelApiResponseObject$`message` self }, + #' Validate JSON input with respect to ModelApiResponse + #' + #' @description + #' Validate JSON input with respect to ModelApiResponse and throw an exception if invalid + #' + #' @param input the JSON input + #' @export validateJSON = function(input) { input_json <- jsonlite::fromJSON(input) } diff --git a/samples/client/petstore/R/R/order.R b/samples/client/petstore/R/R/order.R index 958a4836c8f..ef5ef2bcd28 100644 --- a/samples/client/petstore/R/R/order.R +++ b/samples/client/petstore/R/R/order.R @@ -8,23 +8,14 @@ #' @docType class #' @title Order -#' #' @description Order Class -#' #' @format An \code{R6Class} generator object -#' #' @field id integer [optional] -#' #' @field petId integer [optional] -#' #' @field quantity integer [optional] -#' #' @field shipDate character [optional] -#' #' @field status character [optional] -#' #' @field complete character [optional] -#' #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -37,6 +28,19 @@ Order <- R6::R6Class( `shipDate` = NULL, `status` = NULL, `complete` = NULL, + #' Initialize a new Order class. + #' + #' @description + #' Initialize a new Order class. + #' + #' @param id id + #' @param petId petId + #' @param quantity quantity + #' @param shipDate shipDate + #' @param status Order Status + #' @param complete complete. Default to FALSE. + #' @param ... Other optional arguments. + #' @export initialize = function( `id`=NULL, `petId`=NULL, `quantity`=NULL, `shipDate`=NULL, `status`=NULL, `complete`=FALSE, ... ) { @@ -65,6 +69,13 @@ Order <- R6::R6Class( self$`complete` <- `complete` } }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Order in JSON format + #' @export toJSON = function() { OrderObject <- list() if (!is.null(self$`id`)) { @@ -94,6 +105,14 @@ Order <- R6::R6Class( OrderObject }, + #' Deserialize JSON string into an instance of Order + #' + #' @description + #' Deserialize JSON string into an instance of Order + #' + #' @param OrderJson the JSON input + #' @return the instance of Order + #' @export fromJSON = function(OrderJson) { OrderObject <- jsonlite::fromJSON(OrderJson) if (!is.null(OrderObject$`id`)) { @@ -116,6 +135,13 @@ Order <- R6::R6Class( } self }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Order in JSON format + #' @export toJSONString = function() { jsoncontent <- c( if (!is.null(self$`id`)) { @@ -164,6 +190,14 @@ Order <- R6::R6Class( jsoncontent <- paste(jsoncontent, collapse = ",") paste('{', jsoncontent, '}', sep = "") }, + #' Deserialize JSON string into an instance of Order + #' + #' @description + #' Deserialize JSON string into an instance of Order + #' + #' @param OrderJson the JSON input + #' @return the instance of Order + #' @export fromJSONString = function(OrderJson) { OrderObject <- jsonlite::fromJSON(OrderJson) self$`id` <- OrderObject$`id` @@ -174,6 +208,13 @@ Order <- R6::R6Class( self$`complete` <- OrderObject$`complete` self }, + #' Validate JSON input with respect to Order + #' + #' @description + #' Validate JSON input with respect to Order and throw an exception if invalid + #' + #' @param input the JSON input + #' @export validateJSON = function(input) { input_json <- jsonlite::fromJSON(input) } diff --git a/samples/client/petstore/R/R/pet.R b/samples/client/petstore/R/R/pet.R index f26d36da4b9..c6d63fb5bce 100644 --- a/samples/client/petstore/R/R/pet.R +++ b/samples/client/petstore/R/R/pet.R @@ -8,23 +8,14 @@ #' @docType class #' @title Pet -#' #' @description Pet Class -#' #' @format An \code{R6Class} generator object -#' #' @field id integer [optional] -#' #' @field category \link{Category} [optional] -#' #' @field name character -#' #' @field photoUrls list( character ) -#' #' @field tags list( \link{Tag} ) [optional] -#' #' @field status character [optional] -#' #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -37,6 +28,19 @@ Pet <- R6::R6Class( `photoUrls` = NULL, `tags` = NULL, `status` = NULL, + #' Initialize a new Pet class. + #' + #' @description + #' Initialize a new Pet class. + #' + #' @param name name + #' @param photoUrls photoUrls + #' @param id id + #' @param category category + #' @param tags tags + #' @param status pet status in the store + #' @param ... Other optional arguments. + #' @export initialize = function( `name`, `photoUrls`, `id`=NULL, `category`=NULL, `tags`=NULL, `status`=NULL, ... ) { @@ -67,6 +71,13 @@ Pet <- R6::R6Class( self$`status` <- `status` } }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Pet in JSON format + #' @export toJSON = function() { PetObject <- list() if (!is.null(self$`id`)) { @@ -96,6 +107,14 @@ Pet <- R6::R6Class( PetObject }, + #' Deserialize JSON string into an instance of Pet + #' + #' @description + #' Deserialize JSON string into an instance of Pet + #' + #' @param PetJson the JSON input + #' @return the instance of Pet + #' @export fromJSON = function(PetJson) { PetObject <- jsonlite::fromJSON(PetJson) if (!is.null(PetObject$`id`)) { @@ -120,6 +139,13 @@ Pet <- R6::R6Class( } self }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Pet in JSON format + #' @export toJSONString = function() { jsoncontent <- c( if (!is.null(self$`id`)) { @@ -168,6 +194,14 @@ Pet <- R6::R6Class( jsoncontent <- paste(jsoncontent, collapse = ",") paste('{', jsoncontent, '}', sep = "") }, + #' Deserialize JSON string into an instance of Pet + #' + #' @description + #' Deserialize JSON string into an instance of Pet + #' + #' @param PetJson the JSON input + #' @return the instance of Pet + #' @export fromJSONString = function(PetJson) { PetObject <- jsonlite::fromJSON(PetJson) self$`id` <- PetObject$`id` @@ -178,6 +212,13 @@ Pet <- R6::R6Class( self$`status` <- PetObject$`status` self }, + #' Validate JSON input with respect to Pet + #' + #' @description + #' Validate JSON input with respect to Pet and throw an exception if invalid + #' + #' @param input the JSON input + #' @export validateJSON = function(input) { input_json <- jsonlite::fromJSON(input) # check the required field `name` diff --git a/samples/client/petstore/R/R/special.R b/samples/client/petstore/R/R/special.R index 9efeaac05a9..42a518939e1 100644 --- a/samples/client/petstore/R/R/special.R +++ b/samples/client/petstore/R/R/special.R @@ -8,17 +8,11 @@ #' @docType class #' @title Special -#' #' @description Special Class -#' #' @format An \code{R6Class} generator object -#' #' @field item_self integer [optional] -#' #' @field item_private character [optional] -#' #' @field item_super character [optional] -#' #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -28,6 +22,16 @@ Special <- R6::R6Class( `item_self` = NULL, `item_private` = NULL, `item_super` = NULL, + #' Initialize a new Special class. + #' + #' @description + #' Initialize a new Special class. + #' + #' @param item_self item_self + #' @param item_private item_private + #' @param item_super item_super + #' @param ... Other optional arguments. + #' @export initialize = function( `item_self`=NULL, `item_private`=NULL, `item_super`=NULL, ... ) { @@ -44,6 +48,13 @@ Special <- R6::R6Class( self$`item_super` <- `item_super` } }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Special in JSON format + #' @export toJSON = function() { SpecialObject <- list() if (!is.null(self$`item_self`)) { @@ -61,6 +72,14 @@ Special <- R6::R6Class( SpecialObject }, + #' Deserialize JSON string into an instance of Special + #' + #' @description + #' Deserialize JSON string into an instance of Special + #' + #' @param SpecialJson the JSON input + #' @return the instance of Special + #' @export fromJSON = function(SpecialJson) { SpecialObject <- jsonlite::fromJSON(SpecialJson) if (!is.null(SpecialObject$`self`)) { @@ -74,6 +93,13 @@ Special <- R6::R6Class( } self }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Special in JSON format + #' @export toJSONString = function() { jsoncontent <- c( if (!is.null(self$`item_self`)) { @@ -101,6 +127,14 @@ Special <- R6::R6Class( jsoncontent <- paste(jsoncontent, collapse = ",") paste('{', jsoncontent, '}', sep = "") }, + #' Deserialize JSON string into an instance of Special + #' + #' @description + #' Deserialize JSON string into an instance of Special + #' + #' @param SpecialJson the JSON input + #' @return the instance of Special + #' @export fromJSONString = function(SpecialJson) { SpecialObject <- jsonlite::fromJSON(SpecialJson) self$`item_self` <- SpecialObject$`item_self` @@ -108,6 +142,13 @@ Special <- R6::R6Class( self$`item_super` <- SpecialObject$`item_super` self }, + #' Validate JSON input with respect to Special + #' + #' @description + #' Validate JSON input with respect to Special and throw an exception if invalid + #' + #' @param input the JSON input + #' @export validateJSON = function(input) { input_json <- jsonlite::fromJSON(input) } diff --git a/samples/client/petstore/R/R/tag.R b/samples/client/petstore/R/R/tag.R index 9bbbd8fbf65..2eb257fb049 100644 --- a/samples/client/petstore/R/R/tag.R +++ b/samples/client/petstore/R/R/tag.R @@ -8,15 +8,10 @@ #' @docType class #' @title Tag -#' #' @description Tag Class -#' #' @format An \code{R6Class} generator object -#' #' @field id integer [optional] -#' #' @field name character [optional] -#' #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -25,6 +20,15 @@ Tag <- R6::R6Class( public = list( `id` = NULL, `name` = NULL, + #' Initialize a new Tag class. + #' + #' @description + #' Initialize a new Tag class. + #' + #' @param id id + #' @param name name + #' @param ... Other optional arguments. + #' @export initialize = function( `id`=NULL, `name`=NULL, ... ) { @@ -37,6 +41,13 @@ Tag <- R6::R6Class( self$`name` <- `name` } }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Tag in JSON format + #' @export toJSON = function() { TagObject <- list() if (!is.null(self$`id`)) { @@ -50,6 +61,14 @@ Tag <- R6::R6Class( TagObject }, + #' Deserialize JSON string into an instance of Tag + #' + #' @description + #' Deserialize JSON string into an instance of Tag + #' + #' @param TagJson the JSON input + #' @return the instance of Tag + #' @export fromJSON = function(TagJson) { TagObject <- jsonlite::fromJSON(TagJson) if (!is.null(TagObject$`id`)) { @@ -60,6 +79,13 @@ Tag <- R6::R6Class( } self }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Tag in JSON format + #' @export toJSONString = function() { jsoncontent <- c( if (!is.null(self$`id`)) { @@ -80,12 +106,27 @@ Tag <- R6::R6Class( jsoncontent <- paste(jsoncontent, collapse = ",") paste('{', jsoncontent, '}', sep = "") }, + #' Deserialize JSON string into an instance of Tag + #' + #' @description + #' Deserialize JSON string into an instance of Tag + #' + #' @param TagJson the JSON input + #' @return the instance of Tag + #' @export fromJSONString = function(TagJson) { TagObject <- jsonlite::fromJSON(TagJson) self$`id` <- TagObject$`id` self$`name` <- TagObject$`name` self }, + #' Validate JSON input with respect to Tag + #' + #' @description + #' Validate JSON input with respect to Tag and throw an exception if invalid + #' + #' @param input the JSON input + #' @export validateJSON = function(input) { input_json <- jsonlite::fromJSON(input) } diff --git a/samples/client/petstore/R/R/update_pet_request.R b/samples/client/petstore/R/R/update_pet_request.R index b6c5b8886e5..89e9f162513 100644 --- a/samples/client/petstore/R/R/update_pet_request.R +++ b/samples/client/petstore/R/R/update_pet_request.R @@ -8,15 +8,10 @@ #' @docType class #' @title UpdatePetRequest -#' #' @description UpdatePetRequest Class -#' #' @format An \code{R6Class} generator object -#' #' @field jsonData \link{Pet} [optional] -#' #' @field binaryDataN2Information data.frame [optional] -#' #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -25,6 +20,15 @@ UpdatePetRequest <- R6::R6Class( public = list( `jsonData` = NULL, `binaryDataN2Information` = NULL, + #' Initialize a new UpdatePetRequest class. + #' + #' @description + #' Initialize a new UpdatePetRequest class. + #' + #' @param jsonData jsonData + #' @param binaryDataN2Information binaryDataN2Information + #' @param ... Other optional arguments. + #' @export initialize = function( `jsonData`=NULL, `binaryDataN2Information`=NULL, ... ) { @@ -36,6 +40,13 @@ UpdatePetRequest <- R6::R6Class( self$`binaryDataN2Information` <- `binaryDataN2Information` } }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return UpdatePetRequest in JSON format + #' @export toJSON = function() { UpdatePetRequestObject <- list() if (!is.null(self$`jsonData`)) { @@ -49,6 +60,14 @@ UpdatePetRequest <- R6::R6Class( UpdatePetRequestObject }, + #' Deserialize JSON string into an instance of UpdatePetRequest + #' + #' @description + #' Deserialize JSON string into an instance of UpdatePetRequest + #' + #' @param UpdatePetRequestJson the JSON input + #' @return the instance of UpdatePetRequest + #' @export fromJSON = function(UpdatePetRequestJson) { UpdatePetRequestObject <- jsonlite::fromJSON(UpdatePetRequestJson) if (!is.null(UpdatePetRequestObject$`jsonData`)) { @@ -61,6 +80,13 @@ UpdatePetRequest <- R6::R6Class( } self }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return UpdatePetRequest in JSON format + #' @export toJSONString = function() { jsoncontent <- c( if (!is.null(self$`jsonData`)) { @@ -81,12 +107,27 @@ UpdatePetRequest <- R6::R6Class( jsoncontent <- paste(jsoncontent, collapse = ",") paste('{', jsoncontent, '}', sep = "") }, + #' Deserialize JSON string into an instance of UpdatePetRequest + #' + #' @description + #' Deserialize JSON string into an instance of UpdatePetRequest + #' + #' @param UpdatePetRequestJson the JSON input + #' @return the instance of UpdatePetRequest + #' @export fromJSONString = function(UpdatePetRequestJson) { UpdatePetRequestObject <- jsonlite::fromJSON(UpdatePetRequestJson) self$`jsonData` <- Pet$new()$fromJSON(jsonlite::toJSON(UpdatePetRequestObject$jsonData, auto_unbox = TRUE, digits = NA)) self$`binaryDataN2Information` <- UpdatePetRequestObject$`binaryDataN2Information` self }, + #' Validate JSON input with respect to UpdatePetRequest + #' + #' @description + #' Validate JSON input with respect to UpdatePetRequest and throw an exception if invalid + #' + #' @param input the JSON input + #' @export validateJSON = function(input) { input_json <- jsonlite::fromJSON(input) } diff --git a/samples/client/petstore/R/R/user.R b/samples/client/petstore/R/R/user.R index f5ba491a774..94c4a0574c6 100644 --- a/samples/client/petstore/R/R/user.R +++ b/samples/client/petstore/R/R/user.R @@ -8,27 +8,16 @@ #' @docType class #' @title User -#' #' @description User Class -#' #' @format An \code{R6Class} generator object -#' #' @field id integer [optional] -#' #' @field username character [optional] -#' #' @field firstName character [optional] -#' #' @field lastName character [optional] -#' #' @field email character [optional] -#' #' @field password character [optional] -#' #' @field phone character [optional] -#' #' @field userStatus integer [optional] -#' #' @importFrom R6 R6Class #' @importFrom jsonlite fromJSON toJSON #' @export @@ -43,6 +32,21 @@ User <- R6::R6Class( `password` = NULL, `phone` = NULL, `userStatus` = NULL, + #' Initialize a new User class. + #' + #' @description + #' Initialize a new User class. + #' + #' @param id id + #' @param username username + #' @param firstName firstName + #' @param lastName lastName + #' @param email email + #' @param password password + #' @param phone phone + #' @param userStatus User Status + #' @param ... Other optional arguments. + #' @export initialize = function( `id`=NULL, `username`=NULL, `firstName`=NULL, `lastName`=NULL, `email`=NULL, `password`=NULL, `phone`=NULL, `userStatus`=NULL, ... ) { @@ -79,6 +83,13 @@ User <- R6::R6Class( self$`userStatus` <- `userStatus` } }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return User in JSON format + #' @export toJSON = function() { UserObject <- list() if (!is.null(self$`id`)) { @@ -116,6 +127,14 @@ User <- R6::R6Class( UserObject }, + #' Deserialize JSON string into an instance of User + #' + #' @description + #' Deserialize JSON string into an instance of User + #' + #' @param UserJson the JSON input + #' @return the instance of User + #' @export fromJSON = function(UserJson) { UserObject <- jsonlite::fromJSON(UserJson) if (!is.null(UserObject$`id`)) { @@ -144,6 +163,13 @@ User <- R6::R6Class( } self }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return User in JSON format + #' @export toJSONString = function() { jsoncontent <- c( if (!is.null(self$`id`)) { @@ -206,6 +232,14 @@ User <- R6::R6Class( jsoncontent <- paste(jsoncontent, collapse = ",") paste('{', jsoncontent, '}', sep = "") }, + #' Deserialize JSON string into an instance of User + #' + #' @description + #' Deserialize JSON string into an instance of User + #' + #' @param UserJson the JSON input + #' @return the instance of User + #' @export fromJSONString = function(UserJson) { UserObject <- jsonlite::fromJSON(UserJson) self$`id` <- UserObject$`id` @@ -218,6 +252,13 @@ User <- R6::R6Class( self$`userStatus` <- UserObject$`userStatus` self }, + #' Validate JSON input with respect to User + #' + #' @description + #' Validate JSON input with respect to User and throw an exception if invalid + #' + #' @param input the JSON input + #' @export validateJSON = function(input) { input_json <- jsonlite::fromJSON(input) }