diff --git a/.gitignore b/.gitignore index 3e0166838b2..850adb6fac6 100644 --- a/.gitignore +++ b/.gitignore @@ -224,6 +224,8 @@ samples/client/petstore/R/**/petstore.Rcheck/ samples/client/petstore/R/**/*.tar.gz samples/client/petstore/R/R.Rproj samples/client/petstore/R/man/ +samples/client/petstore/R-httr2-wrapper/man/ +samples/client/petstore/R-httr2/man/ # elixir samples/client/petstore/elixir/_build/ 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 d4ae8000cd3..c7a0ab1e07a 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 @@ -176,7 +176,10 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig { typeMapping.put("map", "map"); typeMapping.put("object", "object"); + // no need for import mapping as R doesn't reqiure api,model import + // https://github.com/OpenAPITools/openapi-generator/issues/2217 importMapping.clear(); + cliOptions.clear(); cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "R package name (convention: lowercase).") .defaultValue("openapi")); @@ -587,31 +590,6 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig { var.vendorExtensions.put("x-r-doc-type", constructRdocType(var)); } } - - // remove model imports to avoid error - List> imports = objs.getImports(); - final String prefix = modelPackage(); - Iterator> iterator = imports.iterator(); - while (iterator.hasNext()) { - String _import = iterator.next().get("import"); - if (_import.startsWith(prefix)) - iterator.remove(); - } - - // recursively add import for mapping one type to multiple imports - List> recursiveImports = objs.getImports(); - if (recursiveImports != null) { - ListIterator> listIterator = imports.listIterator(); - while (listIterator.hasNext()) { - String _import = listIterator.next().get("import"); - // if the import package happens to be found in the importMapping (key) - // add the corresponding import package to the list - if (importMapping.containsKey(_import)) { - listIterator.add(createMapping("import", importMapping.get(_import))); - } - } - } - return postProcessModelsEnum(objs); } diff --git a/modules/openapi-generator/src/test/resources/3_0/r/petstore.yaml b/modules/openapi-generator/src/test/resources/3_0/r/petstore.yaml index 084ced168fc..3fb60324940 100644 --- a/modules/openapi-generator/src/test/resources/3_0/r/petstore.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/r/petstore.yaml @@ -1001,3 +1001,11 @@ components: type: string required: - className + Date: + description: to test the model name `Date` + type: object + properties: + className: + type: string + required: + - className diff --git a/samples/client/petstore/R-httr2-wrapper/.openapi-generator/FILES b/samples/client/petstore/R-httr2-wrapper/.openapi-generator/FILES index b2a3dba4543..c1007a68c4d 100644 --- a/samples/client/petstore/R-httr2-wrapper/.openapi-generator/FILES +++ b/samples/client/petstore/R-httr2-wrapper/.openapi-generator/FILES @@ -17,6 +17,7 @@ R/cat.R R/cat_all_of.R R/category.R R/danish_pig.R +R/date.R R/dog.R R/dog_all_of.R R/fake_api.R @@ -47,6 +48,7 @@ docs/Cat.md docs/CatAllOf.md docs/Category.md docs/DanishPig.md +docs/Date.md docs/Dog.md docs/DogAllOf.md docs/FakeApi.md diff --git a/samples/client/petstore/R-httr2-wrapper/NAMESPACE b/samples/client/petstore/R-httr2-wrapper/NAMESPACE index f4687ea9592..fe9db16d34b 100644 --- a/samples/client/petstore/R-httr2-wrapper/NAMESPACE +++ b/samples/client/petstore/R-httr2-wrapper/NAMESPACE @@ -25,6 +25,7 @@ export(Cat) export(CatAllOf) export(Category) export(DanishPig) +export(Date) export(Dog) export(DogAllOf) export(Mammal) diff --git a/samples/client/petstore/R-httr2-wrapper/R/date.R b/samples/client/petstore/R-httr2-wrapper/R/date.R new file mode 100644 index 00000000000..bc6e98db8bb --- /dev/null +++ b/samples/client/petstore/R-httr2-wrapper/R/date.R @@ -0,0 +1,211 @@ +#' Create a new Date +#' +#' @description +#' to test the model name `Date` +#' +#' @docType class +#' @title Date +#' @description Date Class +#' @format An \code{R6Class} generator object +#' @field className character +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +Date <- R6::R6Class( + "Date", + public = list( + `className` = NULL, + `_field_list` = c("className"), + `additional_properties` = list(), + #' Initialize a new Date class. + #' + #' @description + #' Initialize a new Date class. + #' + #' @param className className + #' @param additional_properties additonal properties (optional) + #' @param ... Other optional arguments. + #' @export + initialize = function( + `className`, additional_properties = NULL, ... + ) { + if (!missing(`className`)) { + stopifnot(is.character(`className`), length(`className`) == 1) + self$`className` <- `className` + } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Date in JSON format + #' @export + toJSON = function() { + DateObject <- list() + if (!is.null(self$`className`)) { + DateObject[["className"]] <- + self$`className` + } + for (key in names(self$additional_properties)) { + DateObject[[key]] <- self$additional_properties[[key]] + } + + DateObject + }, + #' Deserialize JSON string into an instance of Date + #' + #' @description + #' Deserialize JSON string into an instance of Date + #' + #' @param input_json the JSON input + #' @return the instance of Date + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`className`)) { + self$`className` <- this_object$`className` + } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Date in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`className`)) { + sprintf( + '"className": + "%s" + ', + self$`className` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + 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 Date + #' + #' @description + #' Deserialize JSON string into an instance of Date + #' + #' @param input_json the JSON input + #' @return the instance of Date + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`className` <- this_object$`className` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + + self + }, + #' Validate JSON input with respect to Date + #' + #' @description + #' Validate JSON input with respect to Date 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` + if (!is.null(input_json$`className`)) { + stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1) + } else { + stop(paste("The JSON input `", input, "` is invalid for Date: the required field `className` is missing.")) + } + }, + #' To string (JSON format) + #' + #' @description + #' To string (JSON format) + #' + #' @return String representation of Date + #' @export + toString = function() { + self$toJSONString() + }, + #' Return true if the values in all fields are valid. + #' + #' @description + #' Return true if the values in all fields are valid. + #' + #' @return true if the values in all fields are valid. + #' @export + isValid = function() { + # check if the required `className` is null + if (is.null(self$`className`)) { + return(FALSE) + } + + TRUE + }, + #' Return a list of invalid fields (if any). + #' + #' @description + #' Return a list of invalid fields (if any). + #' + #' @return A list of invalid fields (if any). + #' @export + getInvalidFields = function() { + invalid_fields <- list() + # check if the required `className` is null + if (is.null(self$`className`)) { + invalid_fields["className"] <- "Non-nullable required field `className` cannot be null." + } + + invalid_fields + }, + #' Print the object + #' + #' @description + #' Print the object + #' + #' @export + print = function() { + print(jsonlite::prettify(self$toJSONString())) + invisible(self) + }), + # Lock the class to prevent modifications to the method or field + lock_class = TRUE +) +## Uncomment below to unlock the class to allow modifications of the method or field +#Date$unlock() +# +## Below is an example to define the print fnuction +#Date$set("public", "print", function(...) { +# print(jsonlite::prettify(self$toJSONString())) +# invisible(self) +#}) +## Uncomment below to lock the class to prevent modifications to the method or field +#Date$lock() + diff --git a/samples/client/petstore/R-httr2-wrapper/README.md b/samples/client/petstore/R-httr2-wrapper/README.md index b71e5202220..4982d4b0d8e 100644 --- a/samples/client/petstore/R-httr2-wrapper/README.md +++ b/samples/client/petstore/R-httr2-wrapper/README.md @@ -98,6 +98,7 @@ Class | Method | HTTP request | Description - [CatAllOf](docs/CatAllOf.md) - [Category](docs/Category.md) - [DanishPig](docs/DanishPig.md) + - [Date](docs/Date.md) - [Dog](docs/Dog.md) - [DogAllOf](docs/DogAllOf.md) - [Mammal](docs/Mammal.md) diff --git a/samples/client/petstore/R-httr2-wrapper/docs/Date.md b/samples/client/petstore/R-httr2-wrapper/docs/Date.md new file mode 100644 index 00000000000..e2863f0c071 --- /dev/null +++ b/samples/client/petstore/R-httr2-wrapper/docs/Date.md @@ -0,0 +1,10 @@ +# petstore::Date + +to test the model name `Date` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **character** | | + + diff --git a/samples/client/petstore/R-httr2-wrapper/tests/testthat/test_date.R b/samples/client/petstore/R-httr2-wrapper/tests/testthat/test_date.R new file mode 100644 index 00000000000..214fd8a352f --- /dev/null +++ b/samples/client/petstore/R-httr2-wrapper/tests/testthat/test_date.R @@ -0,0 +1,13 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test Date") + +model_instance <- Date$new() + +test_that("className", { + # tests for the property `className` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`className`, "EXPECTED_RESULT") +}) diff --git a/samples/client/petstore/R-httr2/.openapi-generator/FILES b/samples/client/petstore/R-httr2/.openapi-generator/FILES index 2e11de9d1ab..d539ea462da 100644 --- a/samples/client/petstore/R-httr2/.openapi-generator/FILES +++ b/samples/client/petstore/R-httr2/.openapi-generator/FILES @@ -17,6 +17,7 @@ R/cat.R R/cat_all_of.R R/category.R R/danish_pig.R +R/date.R R/dog.R R/dog_all_of.R R/fake_api.R @@ -46,6 +47,7 @@ docs/Cat.md docs/CatAllOf.md docs/Category.md docs/DanishPig.md +docs/Date.md docs/Dog.md docs/DogAllOf.md docs/FakeApi.md diff --git a/samples/client/petstore/R-httr2/NAMESPACE b/samples/client/petstore/R-httr2/NAMESPACE index 9a41dbdcab3..fbdc3618b41 100644 --- a/samples/client/petstore/R-httr2/NAMESPACE +++ b/samples/client/petstore/R-httr2/NAMESPACE @@ -23,6 +23,7 @@ export(Cat) export(CatAllOf) export(Category) export(DanishPig) +export(Date) export(Dog) export(DogAllOf) export(Mammal) diff --git a/samples/client/petstore/R-httr2/R/date.R b/samples/client/petstore/R-httr2/R/date.R new file mode 100644 index 00000000000..39a6305eea5 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/date.R @@ -0,0 +1,178 @@ +#' Create a new Date +#' +#' @description +#' to test the model name `Date` +#' +#' @docType class +#' @title Date +#' @description Date Class +#' @format An \code{R6Class} generator object +#' @field className character +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +Date <- R6::R6Class( + "Date", + public = list( + `className` = NULL, + #' Initialize a new Date class. + #' + #' @description + #' Initialize a new Date class. + #' + #' @param className className + #' @param ... Other optional arguments. + #' @export + initialize = function( + `className`, ... + ) { + if (!missing(`className`)) { + stopifnot(is.character(`className`), length(`className`) == 1) + self$`className` <- `className` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Date in JSON format + #' @export + toJSON = function() { + DateObject <- list() + if (!is.null(self$`className`)) { + DateObject[["className"]] <- + self$`className` + } + DateObject + }, + #' Deserialize JSON string into an instance of Date + #' + #' @description + #' Deserialize JSON string into an instance of Date + #' + #' @param input_json the JSON input + #' @return the instance of Date + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`className`)) { + self$`className` <- this_object$`className` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Date in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`className`)) { + sprintf( + '"className": + "%s" + ', + self$`className` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of Date + #' + #' @description + #' Deserialize JSON string into an instance of Date + #' + #' @param input_json the JSON input + #' @return the instance of Date + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`className` <- this_object$`className` + self + }, + #' Validate JSON input with respect to Date + #' + #' @description + #' Validate JSON input with respect to Date 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` + if (!is.null(input_json$`className`)) { + stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1) + } else { + stop(paste("The JSON input `", input, "` is invalid for Date: the required field `className` is missing.")) + } + }, + #' To string (JSON format) + #' + #' @description + #' To string (JSON format) + #' + #' @return String representation of Date + #' @export + toString = function() { + self$toJSONString() + }, + #' Return true if the values in all fields are valid. + #' + #' @description + #' Return true if the values in all fields are valid. + #' + #' @return true if the values in all fields are valid. + #' @export + isValid = function() { + # check if the required `className` is null + if (is.null(self$`className`)) { + return(FALSE) + } + + TRUE + }, + #' Return a list of invalid fields (if any). + #' + #' @description + #' Return a list of invalid fields (if any). + #' + #' @return A list of invalid fields (if any). + #' @export + getInvalidFields = function() { + invalid_fields <- list() + # check if the required `className` is null + if (is.null(self$`className`)) { + invalid_fields["className"] <- "Non-nullable required field `className` cannot be null." + } + + invalid_fields + }, + #' Print the object + #' + #' @description + #' Print the object + #' + #' @export + print = function() { + print(jsonlite::prettify(self$toJSONString())) + invisible(self) + }), + # Lock the class to prevent modifications to the method or field + lock_class = TRUE +) +## Uncomment below to unlock the class to allow modifications of the method or field +#Date$unlock() +# +## Below is an example to define the print fnuction +#Date$set("public", "print", function(...) { +# print(jsonlite::prettify(self$toJSONString())) +# invisible(self) +#}) +## Uncomment below to lock the class to prevent modifications to the method or field +#Date$lock() + diff --git a/samples/client/petstore/R-httr2/README.md b/samples/client/petstore/R-httr2/README.md index b71e5202220..4982d4b0d8e 100644 --- a/samples/client/petstore/R-httr2/README.md +++ b/samples/client/petstore/R-httr2/README.md @@ -98,6 +98,7 @@ Class | Method | HTTP request | Description - [CatAllOf](docs/CatAllOf.md) - [Category](docs/Category.md) - [DanishPig](docs/DanishPig.md) + - [Date](docs/Date.md) - [Dog](docs/Dog.md) - [DogAllOf](docs/DogAllOf.md) - [Mammal](docs/Mammal.md) diff --git a/samples/client/petstore/R-httr2/docs/Date.md b/samples/client/petstore/R-httr2/docs/Date.md new file mode 100644 index 00000000000..e2863f0c071 --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/Date.md @@ -0,0 +1,10 @@ +# petstore::Date + +to test the model name `Date` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **character** | | + + diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_date.R b/samples/client/petstore/R-httr2/tests/testthat/test_date.R new file mode 100644 index 00000000000..214fd8a352f --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_date.R @@ -0,0 +1,13 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test Date") + +model_instance <- Date$new() + +test_that("className", { + # tests for the property `className` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`className`, "EXPECTED_RESULT") +}) diff --git a/samples/client/petstore/R/.openapi-generator/FILES b/samples/client/petstore/R/.openapi-generator/FILES index 2e11de9d1ab..d539ea462da 100644 --- a/samples/client/petstore/R/.openapi-generator/FILES +++ b/samples/client/petstore/R/.openapi-generator/FILES @@ -17,6 +17,7 @@ R/cat.R R/cat_all_of.R R/category.R R/danish_pig.R +R/date.R R/dog.R R/dog_all_of.R R/fake_api.R @@ -46,6 +47,7 @@ docs/Cat.md docs/CatAllOf.md docs/Category.md docs/DanishPig.md +docs/Date.md docs/Dog.md docs/DogAllOf.md docs/FakeApi.md diff --git a/samples/client/petstore/R/NAMESPACE b/samples/client/petstore/R/NAMESPACE index a62165a21d8..a38534972b8 100644 --- a/samples/client/petstore/R/NAMESPACE +++ b/samples/client/petstore/R/NAMESPACE @@ -23,6 +23,7 @@ export(Cat) export(CatAllOf) export(Category) export(DanishPig) +export(Date) export(Dog) export(DogAllOf) export(Mammal) diff --git a/samples/client/petstore/R/R/date.R b/samples/client/petstore/R/R/date.R new file mode 100644 index 00000000000..bc6e98db8bb --- /dev/null +++ b/samples/client/petstore/R/R/date.R @@ -0,0 +1,211 @@ +#' Create a new Date +#' +#' @description +#' to test the model name `Date` +#' +#' @docType class +#' @title Date +#' @description Date Class +#' @format An \code{R6Class} generator object +#' @field className character +#' @field _field_list a list of fields list(character) +#' @field additional_properties additional properties list(character) [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +Date <- R6::R6Class( + "Date", + public = list( + `className` = NULL, + `_field_list` = c("className"), + `additional_properties` = list(), + #' Initialize a new Date class. + #' + #' @description + #' Initialize a new Date class. + #' + #' @param className className + #' @param additional_properties additonal properties (optional) + #' @param ... Other optional arguments. + #' @export + initialize = function( + `className`, additional_properties = NULL, ... + ) { + if (!missing(`className`)) { + stopifnot(is.character(`className`), length(`className`) == 1) + self$`className` <- `className` + } + if (!is.null(additional_properties)) { + for (key in names(additional_properties)) { + self$additional_properties[[key]] <- additional_properties[[key]] + } + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Date in JSON format + #' @export + toJSON = function() { + DateObject <- list() + if (!is.null(self$`className`)) { + DateObject[["className"]] <- + self$`className` + } + for (key in names(self$additional_properties)) { + DateObject[[key]] <- self$additional_properties[[key]] + } + + DateObject + }, + #' Deserialize JSON string into an instance of Date + #' + #' @description + #' Deserialize JSON string into an instance of Date + #' + #' @param input_json the JSON input + #' @return the instance of Date + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`className`)) { + self$`className` <- this_object$`className` + } + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Date in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`className`)) { + sprintf( + '"className": + "%s" + ', + self$`className` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + json_obj <- jsonlite::fromJSON(json_string) + for (key in names(self$additional_properties)) { + 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 Date + #' + #' @description + #' Deserialize JSON string into an instance of Date + #' + #' @param input_json the JSON input + #' @return the instance of Date + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`className` <- this_object$`className` + # process additional properties/fields in the payload + for (key in names(this_object)) { + if (!(key %in% self$`_field_list`)) { # json key not in list of fields + self$additional_properties[[key]] <- this_object[[key]] + } + } + + self + }, + #' Validate JSON input with respect to Date + #' + #' @description + #' Validate JSON input with respect to Date 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` + if (!is.null(input_json$`className`)) { + stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1) + } else { + stop(paste("The JSON input `", input, "` is invalid for Date: the required field `className` is missing.")) + } + }, + #' To string (JSON format) + #' + #' @description + #' To string (JSON format) + #' + #' @return String representation of Date + #' @export + toString = function() { + self$toJSONString() + }, + #' Return true if the values in all fields are valid. + #' + #' @description + #' Return true if the values in all fields are valid. + #' + #' @return true if the values in all fields are valid. + #' @export + isValid = function() { + # check if the required `className` is null + if (is.null(self$`className`)) { + return(FALSE) + } + + TRUE + }, + #' Return a list of invalid fields (if any). + #' + #' @description + #' Return a list of invalid fields (if any). + #' + #' @return A list of invalid fields (if any). + #' @export + getInvalidFields = function() { + invalid_fields <- list() + # check if the required `className` is null + if (is.null(self$`className`)) { + invalid_fields["className"] <- "Non-nullable required field `className` cannot be null." + } + + invalid_fields + }, + #' Print the object + #' + #' @description + #' Print the object + #' + #' @export + print = function() { + print(jsonlite::prettify(self$toJSONString())) + invisible(self) + }), + # Lock the class to prevent modifications to the method or field + lock_class = TRUE +) +## Uncomment below to unlock the class to allow modifications of the method or field +#Date$unlock() +# +## Below is an example to define the print fnuction +#Date$set("public", "print", function(...) { +# print(jsonlite::prettify(self$toJSONString())) +# invisible(self) +#}) +## Uncomment below to lock the class to prevent modifications to the method or field +#Date$lock() + diff --git a/samples/client/petstore/R/README.md b/samples/client/petstore/R/README.md index baf7bc69609..d3f6f2a1629 100644 --- a/samples/client/petstore/R/README.md +++ b/samples/client/petstore/R/README.md @@ -98,6 +98,7 @@ Class | Method | HTTP request | Description - [CatAllOf](docs/CatAllOf.md) - [Category](docs/Category.md) - [DanishPig](docs/DanishPig.md) + - [Date](docs/Date.md) - [Dog](docs/Dog.md) - [DogAllOf](docs/DogAllOf.md) - [Mammal](docs/Mammal.md) diff --git a/samples/client/petstore/R/docs/Date.md b/samples/client/petstore/R/docs/Date.md new file mode 100644 index 00000000000..e2863f0c071 --- /dev/null +++ b/samples/client/petstore/R/docs/Date.md @@ -0,0 +1,10 @@ +# petstore::Date + +to test the model name `Date` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **character** | | + + diff --git a/samples/client/petstore/R/tests/testthat/test_date.R b/samples/client/petstore/R/tests/testthat/test_date.R new file mode 100644 index 00000000000..214fd8a352f --- /dev/null +++ b/samples/client/petstore/R/tests/testthat/test_date.R @@ -0,0 +1,13 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test Date") + +model_instance <- Date$new() + +test_that("className", { + # tests for the property `className` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`className`, "EXPECTED_RESULT") +})