From d74c49b93d610f12b50ffcf7290bff39a5e0f67b Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sun, 23 Oct 2022 20:40:53 +0800 Subject: [PATCH] better error handling in the r client (#13800) --- .../main/resources/r/modelGeneric.mustache | 102 ++++++++++++------ .../R/allof_tag_api_response.R | 20 +++- .../petstore/R-httr2-wrapper/R/animal.R | 12 ++- .../petstore/R-httr2-wrapper/R/basque_pig.R | 16 ++- .../client/petstore/R-httr2-wrapper/R/cat.R | 16 ++- .../petstore/R-httr2-wrapper/R/cat_all_of.R | 4 +- .../petstore/R-httr2-wrapper/R/category.R | 8 +- .../petstore/R-httr2-wrapper/R/danish_pig.R | 16 ++- .../client/petstore/R-httr2-wrapper/R/date.R | 28 +++-- .../client/petstore/R-httr2-wrapper/R/dog.R | 16 ++- .../petstore/R-httr2-wrapper/R/dog_all_of.R | 4 +- .../petstore/R-httr2-wrapper/R/format_test.R | 54 +++++++--- .../R-httr2-wrapper/R/model_api_response.R | 12 ++- .../R-httr2-wrapper/R/nested_one_of.R | 4 +- .../client/petstore/R-httr2-wrapper/R/order.R | 22 ++-- .../client/petstore/R-httr2-wrapper/R/pet.R | 16 ++- .../petstore/R-httr2-wrapper/R/special.R | 24 +++-- .../client/petstore/R-httr2-wrapper/R/tag.R | 8 +- .../client/petstore/R-httr2-wrapper/R/user.R | 32 ++++-- .../client/petstore/R-httr2-wrapper/R/whale.R | 16 ++- .../client/petstore/R-httr2-wrapper/R/zebra.R | 12 ++- .../tests/testthat/test_petstore.R | 6 +- .../R-httr2/R/allof_tag_api_response.R | 20 +++- samples/client/petstore/R-httr2/R/animal.R | 12 ++- .../client/petstore/R-httr2/R/basque_pig.R | 16 ++- samples/client/petstore/R-httr2/R/cat.R | 16 ++- .../client/petstore/R-httr2/R/cat_all_of.R | 4 +- samples/client/petstore/R-httr2/R/category.R | 8 +- .../client/petstore/R-httr2/R/danish_pig.R | 16 ++- samples/client/petstore/R-httr2/R/date.R | 28 +++-- samples/client/petstore/R-httr2/R/dog.R | 16 ++- .../client/petstore/R-httr2/R/dog_all_of.R | 4 +- .../client/petstore/R-httr2/R/format_test.R | 54 +++++++--- .../petstore/R-httr2/R/model_api_response.R | 12 ++- .../client/petstore/R-httr2/R/nested_one_of.R | 4 +- samples/client/petstore/R-httr2/R/order.R | 22 ++-- samples/client/petstore/R-httr2/R/pet.R | 16 ++- samples/client/petstore/R-httr2/R/special.R | 24 +++-- samples/client/petstore/R-httr2/R/tag.R | 8 +- samples/client/petstore/R-httr2/R/user.R | 32 ++++-- samples/client/petstore/R-httr2/R/whale.R | 16 ++- samples/client/petstore/R-httr2/R/zebra.R | 12 ++- .../petstore/R/R/allof_tag_api_response.R | 20 +++- samples/client/petstore/R/R/animal.R | 12 ++- samples/client/petstore/R/R/basque_pig.R | 16 ++- samples/client/petstore/R/R/cat.R | 16 ++- samples/client/petstore/R/R/cat_all_of.R | 4 +- samples/client/petstore/R/R/category.R | 8 +- samples/client/petstore/R/R/danish_pig.R | 16 ++- samples/client/petstore/R/R/date.R | 28 +++-- samples/client/petstore/R/R/dog.R | 16 ++- samples/client/petstore/R/R/dog_all_of.R | 4 +- samples/client/petstore/R/R/format_test.R | 54 +++++++--- .../client/petstore/R/R/model_api_response.R | 12 ++- samples/client/petstore/R/R/nested_one_of.R | 4 +- samples/client/petstore/R/R/order.R | 22 ++-- samples/client/petstore/R/R/pet.R | 16 ++- samples/client/petstore/R/R/special.R | 24 +++-- samples/client/petstore/R/R/tag.R | 8 +- samples/client/petstore/R/R/user.R | 32 ++++-- samples/client/petstore/R/R/whale.R | 16 ++- samples/client/petstore/R/R/zebra.R | 12 ++- 62 files changed, 827 insertions(+), 301 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache index 216160f1bb98..451f41a5b426 100644 --- a/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/r/modelGeneric.mustache @@ -60,37 +60,49 @@ } {{/isEnum}} {{#isInteger}} - stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1) + if (!(is.numeric(`{{name}}`) && length(`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be an integer:", `{{name}}`)) + } {{/isInteger}} {{#isLong}} - stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1) + if (!(is.numeric(`{{name}}`) && length(`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be an integer:", `{{name}}`)) + } {{/isLong}} {{#isFloat}} - stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1) + if (!(is.numeric(`{{name}}`) && length(`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be a number:", `{{name}}`)) + } {{/isFloat}} {{#isDouble}} - stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1) + if (!(is.numeric(`{{name}}`) && length(`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be a number:", `{{name}}`)) + } {{/isDouble}} {{#isString}} - stopifnot(is.character(`{{name}}`), length(`{{name}}`) == 1) + if (!(is.character(`{{name}}`) && length(`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be a string:", `{{name}}`)) + } {{/isString}} {{#isBoolean}} - stopifnot(is.logical(`{{name}}`), length(`{{name}}`) == 1) + if (!(is.logical(`{{name}}`) && length(`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be a boolean:", `{{name}}`)) + } {{/isBoolean}} {{#isDate}} - if (!is.character(`{{name}}`)) { - stop(paste("Error! Invalid Date. Must be a string:", `{{name}}`)) + if (!(is.character(`{{name}}`) && length(`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be a string:", `{{name}}`)) } {{/isDate}} {{#isDateTime}} - if (!is.character(`{{name}}`)) { - stop(paste("Error! Invalid DateTime. Must be a string:", `{{name}}`)) + if (!(is.character(`{{name}}`) && length(`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be a string:", `{{name}}`)) } {{/isDateTime}} {{#isUri}} # to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r if (!stringr::str_detect(`{{name}}`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) { - stop(paste("Error! Invalid URL:", `{{name}}`)) + stop(paste("Error! Invalid data for `{{name}}`. Must be a URL:", `{{name}}`)) } {{/isUri}} {{^isPrimitiveType}} @@ -120,37 +132,49 @@ } {{/isEnum}} {{#isInteger}} - stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1) + if (!(is.numeric(`{{name}}`) && length(`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be an integer:", `{{name}}`)) + } {{/isInteger}} {{#isLong}} - stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1) + if (!(is.numeric(`{{name}}`) && length(`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be an integer:", `{{name}}`)) + } {{/isLong}} {{#isFloat}} - stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1) + if (!(is.numeric(`{{name}}`) && length(`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be a number:", `{{name}}`)) + } {{/isFloat}} {{#isDouble}} - stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1) + if (!(is.numeric(`{{name}}`) && length(`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be a number:", `{{name}}`)) + } {{/isDouble}} {{#isString}} - stopifnot(is.character(`{{name}}`), length(`{{name}}`) == 1) + if (!(is.character(`{{name}}`) && length(`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be a string:", `{{name}}`)) + } {{/isString}} {{#isBoolean}} - stopifnot(is.logical(`{{name}}`), length(`{{name}}`) == 1) + if (!(is.logical(`{{name}}`) && length(`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be a boolean:", `{{name}}`)) + } {{/isBoolean}} {{#isDate}} if (!is.character(`{{name}}`)) { - stop(paste("Error! Invalid Date. Must be a string:", `{{name}}`)) + stop(paste("Error! Invalid data for `{{name}}`. Must be a string:", `{{name}}`)) } {{/isDate}} {{#isDateTime}} if (!is.character(`{{name}}`)) { - stop(paste("Error! Invalid DateTime. Must be a string:", `{{name}}`)) + stop(paste("Error! Invalid data for `{{name}}`. Must be a string:", `{{name}}`)) } {{/isDateTime}} {{#isUri}} # to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r if (!stringr::str_detect(`{{name}}`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) { - stop(paste("Error! Invalid URL:", `{{name}}`)) + stop(paste("Error! Invalid data for `{{name}}`. Must be a URL:", `{{name}}`)) } {{/isUri}} {{^isPrimitiveType}} @@ -259,7 +283,7 @@ {{#isUri}} # to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r if (!stringr::str_detect(this_object$`{{baseName}}`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) { - stop(paste("Error! Invalid URL:", this_object$`{{baseName}}`)) + stop(paste("Error! Invalid data for `{{baseName}}`. Must be a URL:", this_object$`{{baseName}}`)) } {{/isUri}} self$`{{name}}` <- this_object$`{{baseName}}` @@ -391,7 +415,7 @@ {{#isUri}} # to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r if (!stringr::str_detect(this_object$`{{name}}`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) { - stop(paste("Error! Invalid URL:", this_object$`{{name}}`)) + stop(paste("Error! Invalid data for `{{name}}`. Must be a URL:", this_object$`{{name}}`)) } {{/isUri}} self$`{{name}}` <- this_object$`{{name}}` @@ -426,33 +450,49 @@ if (!is.null(input_json$`{{name}}`)) { {{^isContainer}} {{#isInteger}} - stopifnot(is.numeric(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1) + if (!(is.numeric(input_json$`{{name}}`) && length(input_json$`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be an integer:", input_json$`{{name}}`)) + } {{/isInteger}} {{#isLong}} - stopifnot(is.numeric(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1) + if (!(is.numeric(input_json$`{{name}}`) && length(input_json$`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be an integer:", input_json$`{{name}}`)) + } {{/isLong}} {{#isFloat}} - stopifnot(is.numeric(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1) + if (!(is.numeric(input_json$`{{name}}`) && length(input_json$`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be a number:", input_json$`{{name}}`)) + } {{/isFloat}} {{#isDouble}} - stopifnot(is.numeric(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1) + if (!(is.numeric(input_json$`{{name}}`) && length(input_json$`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be a number:", input_json$`{{name}}`)) + } {{/isDouble}} {{#isString}} - stopifnot(is.character(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1) + if (!(is.character(input_json$`{{name}}`) && length(input_json$`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be a string:", input_json$`{{name}}`)) + } {{/isString}} {{#isBoolean}} - stopifnot(is.logical(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1) + if (!(is.logical(input_json$`{{name}}`) && length(input_json$`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be a boolean:", input_json$`{{name}}`)) + } {{/isBoolean}} {{#isDate}} - stopifnot(is.character(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1) + if (!(is.character(input_json$`{{name}}`) && length(input_json$`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be a string:", input_json$`{{name}}`)) + } {{/isDate}} {{#isDateTime}} - stopifnot(is.character(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1) + if (!(is.character(input_json$`{{name}}`) && length(input_json$`{{name}}`) == 1)) { + stop(paste("Error! Invalid data for `{{name}}`. Must be a string:", input_json$`{{name}}`)) + } {{/isDateTime}} {{#isUri}} # to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r if (!stringr::str_detect(input_json$`{{name}}`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) { - stop(paste("Error! Invalid URL:", input_json$`{{name}}`)) + stop(paste("Error! Invalid data for `{{name}}`. Must be a URL:", input_json$`{{name}}`)) } {{/isUri}} {{^isPrimitiveType}} 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 e485c15e4ca7..220d89ee5036 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 @@ -42,23 +42,33 @@ AllofTagApiResponse <- R6::R6Class( #' @export initialize = function(`id` = NULL, `name` = NULL, `code` = NULL, `type` = NULL, `message` = NULL, additional_properties = NULL, ...) { if (!is.null(`id`)) { - stopifnot(is.numeric(`id`), length(`id`) == 1) + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } self$`id` <- `id` } if (!is.null(`name`)) { - stopifnot(is.character(`name`), length(`name`) == 1) + if (!(is.character(`name`) && length(`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", `name`)) + } self$`name` <- `name` } if (!is.null(`code`)) { - stopifnot(is.numeric(`code`), length(`code`) == 1) + if (!(is.numeric(`code`) && length(`code`) == 1)) { + stop(paste("Error! Invalid data for `code`. Must be an integer:", `code`)) + } self$`code` <- `code` } if (!is.null(`type`)) { - stopifnot(is.character(`type`), length(`type`) == 1) + if (!(is.character(`type`) && length(`type`) == 1)) { + stop(paste("Error! Invalid data for `type`. Must be a string:", `type`)) + } self$`type` <- `type` } if (!is.null(`message`)) { - stopifnot(is.character(`message`), length(`message`) == 1) + if (!(is.character(`message`) && length(`message`) == 1)) { + stop(paste("Error! Invalid data for `message`. Must be a string:", `message`)) + } self$`message` <- `message` } if (!is.null(additional_properties)) { diff --git a/samples/client/petstore/R-httr2-wrapper/R/animal.R b/samples/client/petstore/R-httr2-wrapper/R/animal.R index 632b160087dd..b506bced42f9 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/animal.R +++ b/samples/client/petstore/R-httr2-wrapper/R/animal.R @@ -35,11 +35,15 @@ Animal <- R6::R6Class( #' @export initialize = function(`className`, `color` = "red", additional_properties = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!is.null(`color`)) { - stopifnot(is.character(`color`), length(`color`) == 1) + if (!(is.character(`color`) && length(`color`) == 1)) { + stop(paste("Error! Invalid data for `color`. Must be a string:", `color`)) + } self$`color` <- `color` } if (!is.null(additional_properties)) { @@ -162,7 +166,9 @@ Animal <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Animal: the required field `className` is missing.")) } 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 2335bbe37c0b..ac83042c8cfd 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/basque_pig.R +++ b/samples/client/petstore/R-httr2-wrapper/R/basque_pig.R @@ -33,11 +33,15 @@ BasquePig <- R6::R6Class( #' @export initialize = function(`className`, `color`, additional_properties = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!missing(`color`)) { - stopifnot(is.character(`color`), length(`color`) == 1) + if (!(is.character(`color`) && length(`color`) == 1)) { + stop(paste("Error! Invalid data for `color`. Must be a string:", `color`)) + } self$`color` <- `color` } if (!is.null(additional_properties)) { @@ -160,13 +164,17 @@ BasquePig <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for BasquePig: the required field `className` is missing.")) } # check the required field `color` if (!is.null(input_json$`color`)) { - stopifnot(is.character(input_json$`color`), length(input_json$`color`) == 1) + if (!(is.character(input_json$`color`) && length(input_json$`color`) == 1)) { + stop(paste("Error! Invalid data for `color`. Must be a string:", input_json$`color`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for BasquePig: the required field `color` is missing.")) } diff --git a/samples/client/petstore/R-httr2-wrapper/R/cat.R b/samples/client/petstore/R-httr2-wrapper/R/cat.R index 60d417950b1b..f74e2d887ddd 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/cat.R +++ b/samples/client/petstore/R-httr2-wrapper/R/cat.R @@ -37,15 +37,21 @@ Cat <- R6::R6Class( #' @export initialize = function(`className`, `color` = "red", `declawed` = NULL, additional_properties = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!is.null(`color`)) { - stopifnot(is.character(`color`), length(`color`) == 1) + if (!(is.character(`color`) && length(`color`) == 1)) { + stop(paste("Error! Invalid data for `color`. Must be a string:", `color`)) + } self$`color` <- `color` } if (!is.null(`declawed`)) { - stopifnot(is.logical(`declawed`), length(`declawed`) == 1) + if (!(is.logical(`declawed`) && length(`declawed`) == 1)) { + stop(paste("Error! Invalid data for `declawed`. Must be a boolean:", `declawed`)) + } self$`declawed` <- `declawed` } if (!is.null(additional_properties)) { @@ -184,7 +190,9 @@ Cat <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Cat: the required field `className` is missing.")) } 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 c3969fc0550e..197e1a46e3a5 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 @@ -30,7 +30,9 @@ CatAllOf <- R6::R6Class( #' @export initialize = function(`declawed` = NULL, additional_properties = NULL, ...) { if (!is.null(`declawed`)) { - stopifnot(is.logical(`declawed`), length(`declawed`) == 1) + if (!(is.logical(`declawed`) && length(`declawed`) == 1)) { + stop(paste("Error! Invalid data for `declawed`. Must be a boolean:", `declawed`)) + } self$`declawed` <- `declawed` } if (!is.null(additional_properties)) { diff --git a/samples/client/petstore/R-httr2-wrapper/R/category.R b/samples/client/petstore/R-httr2-wrapper/R/category.R index 2de263a56822..2646d01bd723 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/category.R +++ b/samples/client/petstore/R-httr2-wrapper/R/category.R @@ -33,11 +33,15 @@ Category <- R6::R6Class( #' @export initialize = function(`id` = NULL, `name` = NULL, additional_properties = NULL, ...) { if (!is.null(`id`)) { - stopifnot(is.numeric(`id`), length(`id`) == 1) + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } self$`id` <- `id` } if (!is.null(`name`)) { - stopifnot(is.character(`name`), length(`name`) == 1) + if (!(is.character(`name`) && length(`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", `name`)) + } self$`name` <- `name` } if (!is.null(additional_properties)) { 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 737bfad4b971..06cf5096a889 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/danish_pig.R +++ b/samples/client/petstore/R-httr2-wrapper/R/danish_pig.R @@ -33,11 +33,15 @@ DanishPig <- R6::R6Class( #' @export initialize = function(`className`, `size`, additional_properties = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!missing(`size`)) { - stopifnot(is.numeric(`size`), length(`size`) == 1) + if (!(is.numeric(`size`) && length(`size`) == 1)) { + stop(paste("Error! Invalid data for `size`. Must be an integer:", `size`)) + } self$`size` <- `size` } if (!is.null(additional_properties)) { @@ -160,13 +164,17 @@ DanishPig <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for DanishPig: the required field `className` is missing.")) } # check the required field `size` if (!is.null(input_json$`size`)) { - stopifnot(is.numeric(input_json$`size`), length(input_json$`size`) == 1) + if (!(is.numeric(input_json$`size`) && length(input_json$`size`) == 1)) { + stop(paste("Error! Invalid data for `size`. Must be an integer:", input_json$`size`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for DanishPig: the required field `size` is missing.")) } diff --git a/samples/client/petstore/R-httr2-wrapper/R/date.R b/samples/client/petstore/R-httr2-wrapper/R/date.R index a26b7977d4ff..79945bc8cfcf 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/date.R +++ b/samples/client/petstore/R-httr2-wrapper/R/date.R @@ -36,19 +36,25 @@ Date <- R6::R6Class( #' @export initialize = function(`className`, `url_property`, `percent_description` = NULL, additional_properties = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!missing(`url_property`)) { - stopifnot(is.character(`url_property`), length(`url_property`) == 1) + if (!(is.character(`url_property`) && length(`url_property`) == 1)) { + stop(paste("Error! Invalid data for `url_property`. Must be a string:", `url_property`)) + } # to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r if (!stringr::str_detect(`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) { - stop(paste("Error! Invalid URL:", `url_property`)) + stop(paste("Error! Invalid data for `url_property`. Must be a URL:", `url_property`)) } self$`url_property` <- `url_property` } if (!is.null(`percent_description`)) { - stopifnot(is.character(`percent_description`), length(`percent_description`) == 1) + if (!(is.character(`percent_description`) && length(`percent_description`) == 1)) { + stop(paste("Error! Invalid data for `percent_description`. Must be a string:", `percent_description`)) + } self$`percent_description` <- `percent_description` } if (!is.null(additional_properties)) { @@ -103,7 +109,7 @@ Date <- R6::R6Class( if (!is.null(this_object$`url_property`)) { # to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r if (!stringr::str_detect(this_object$`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) { - stop(paste("Error! Invalid URL:", this_object$`url_property`)) + stop(paste("Error! Invalid data for `url_property`. Must be a URL:", this_object$`url_property`)) } self$`url_property` <- this_object$`url_property` } @@ -172,7 +178,7 @@ Date <- R6::R6Class( self$`percent_description` <- this_object$`percent_description` # to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r if (!stringr::str_detect(this_object$`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) { - stop(paste("Error! Invalid URL:", this_object$`url_property`)) + stop(paste("Error! Invalid data for `url_property`. Must be a URL:", this_object$`url_property`)) } self$`url_property` <- this_object$`url_property` # process additional properties/fields in the payload @@ -195,16 +201,20 @@ Date <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Date: the required field `className` is missing.")) } # check the required field `url_property` if (!is.null(input_json$`url_property`)) { - stopifnot(is.character(input_json$`url_property`), length(input_json$`url_property`) == 1) + if (!(is.character(input_json$`url_property`) && length(input_json$`url_property`) == 1)) { + stop(paste("Error! Invalid data for `url_property`. Must be a string:", input_json$`url_property`)) + } # to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r if (!stringr::str_detect(input_json$`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) { - stop(paste("Error! Invalid URL:", input_json$`url_property`)) + stop(paste("Error! Invalid data for `url_property`. Must be a URL:", input_json$`url_property`)) } } else { stop(paste("The JSON input `", input, "` is invalid for Date: the required field `url_property` is missing.")) diff --git a/samples/client/petstore/R-httr2-wrapper/R/dog.R b/samples/client/petstore/R-httr2-wrapper/R/dog.R index 67fb8a315e23..a814c57d5869 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/dog.R +++ b/samples/client/petstore/R-httr2-wrapper/R/dog.R @@ -37,15 +37,21 @@ Dog <- R6::R6Class( #' @export initialize = function(`className`, `color` = "red", `breed` = NULL, additional_properties = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!is.null(`color`)) { - stopifnot(is.character(`color`), length(`color`) == 1) + if (!(is.character(`color`) && length(`color`) == 1)) { + stop(paste("Error! Invalid data for `color`. Must be a string:", `color`)) + } self$`color` <- `color` } if (!is.null(`breed`)) { - stopifnot(is.character(`breed`), length(`breed`) == 1) + if (!(is.character(`breed`) && length(`breed`) == 1)) { + stop(paste("Error! Invalid data for `breed`. Must be a string:", `breed`)) + } self$`breed` <- `breed` } if (!is.null(additional_properties)) { @@ -184,7 +190,9 @@ Dog <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Dog: the required field `className` is missing.")) } 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 ea44d583d744..17608478eedf 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 @@ -30,7 +30,9 @@ DogAllOf <- R6::R6Class( #' @export initialize = function(`breed` = NULL, additional_properties = NULL, ...) { if (!is.null(`breed`)) { - stopifnot(is.character(`breed`), length(`breed`) == 1) + if (!(is.character(`breed`) && length(`breed`) == 1)) { + stop(paste("Error! Invalid data for `breed`. Must be a string:", `breed`)) + } self$`breed` <- `breed` } if (!is.null(additional_properties)) { diff --git a/samples/client/petstore/R-httr2-wrapper/R/format_test.R b/samples/client/petstore/R-httr2-wrapper/R/format_test.R index 872553d583c4..4bd74e3a7275 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/format_test.R +++ b/samples/client/petstore/R-httr2-wrapper/R/format_test.R @@ -78,37 +78,51 @@ FormatTest <- R6::R6Class( self$`byte` <- `byte` } if (!missing(`date`)) { - if (!is.character(`date`)) { - stop(paste("Error! Invalid Date. Must be a string:", `date`)) + if (!(is.character(`date`) && length(`date`) == 1)) { + stop(paste("Error! Invalid data for `date`. Must be a string:", `date`)) } self$`date` <- `date` } if (!missing(`password`)) { - stopifnot(is.character(`password`), length(`password`) == 1) + if (!(is.character(`password`) && length(`password`) == 1)) { + stop(paste("Error! Invalid data for `password`. Must be a string:", `password`)) + } self$`password` <- `password` } if (!is.null(`integer`)) { - stopifnot(is.numeric(`integer`), length(`integer`) == 1) + if (!(is.numeric(`integer`) && length(`integer`) == 1)) { + stop(paste("Error! Invalid data for `integer`. Must be an integer:", `integer`)) + } self$`integer` <- `integer` } if (!is.null(`int32`)) { - stopifnot(is.numeric(`int32`), length(`int32`) == 1) + if (!(is.numeric(`int32`) && length(`int32`) == 1)) { + stop(paste("Error! Invalid data for `int32`. Must be an integer:", `int32`)) + } self$`int32` <- `int32` } if (!is.null(`int64`)) { - stopifnot(is.numeric(`int64`), length(`int64`) == 1) + if (!(is.numeric(`int64`) && length(`int64`) == 1)) { + stop(paste("Error! Invalid data for `int64`. Must be an integer:", `int64`)) + } self$`int64` <- `int64` } if (!is.null(`float`)) { - stopifnot(is.numeric(`float`), length(`float`) == 1) + if (!(is.numeric(`float`) && length(`float`) == 1)) { + stop(paste("Error! Invalid data for `float`. Must be a number:", `float`)) + } self$`float` <- `float` } if (!is.null(`double`)) { - stopifnot(is.numeric(`double`), length(`double`) == 1) + if (!(is.numeric(`double`) && length(`double`) == 1)) { + stop(paste("Error! Invalid data for `double`. Must be a number:", `double`)) + } self$`double` <- `double` } if (!is.null(`string`)) { - stopifnot(is.character(`string`), length(`string`) == 1) + if (!(is.character(`string`) && length(`string`) == 1)) { + stop(paste("Error! Invalid data for `string`. Must be a string:", `string`)) + } self$`string` <- `string` } if (!is.null(`binary`)) { @@ -116,20 +130,26 @@ FormatTest <- R6::R6Class( } if (!is.null(`dateTime`)) { if (!is.character(`dateTime`)) { - stop(paste("Error! Invalid DateTime. Must be a string:", `dateTime`)) + stop(paste("Error! Invalid data for `dateTime`. Must be a string:", `dateTime`)) } self$`dateTime` <- `dateTime` } if (!is.null(`uuid`)) { - stopifnot(is.character(`uuid`), length(`uuid`) == 1) + if (!(is.character(`uuid`) && length(`uuid`) == 1)) { + stop(paste("Error! Invalid data for `uuid`. Must be a string:", `uuid`)) + } self$`uuid` <- `uuid` } if (!is.null(`pattern_with_digits`)) { - stopifnot(is.character(`pattern_with_digits`), length(`pattern_with_digits`) == 1) + if (!(is.character(`pattern_with_digits`) && length(`pattern_with_digits`) == 1)) { + stop(paste("Error! Invalid data for `pattern_with_digits`. Must be a string:", `pattern_with_digits`)) + } self$`pattern_with_digits` <- `pattern_with_digits` } if (!is.null(`pattern_with_digits_and_delimiter`)) { - stopifnot(is.character(`pattern_with_digits_and_delimiter`), length(`pattern_with_digits_and_delimiter`) == 1) + if (!(is.character(`pattern_with_digits_and_delimiter`) && length(`pattern_with_digits_and_delimiter`) == 1)) { + stop(paste("Error! Invalid data for `pattern_with_digits_and_delimiter`. Must be a string:", `pattern_with_digits_and_delimiter`)) + } self$`pattern_with_digits_and_delimiter` <- `pattern_with_digits_and_delimiter` } if (!is.null(additional_properties)) { @@ -470,13 +490,17 @@ FormatTest <- R6::R6Class( } # check the required field `date` if (!is.null(input_json$`date`)) { - stopifnot(is.character(input_json$`date`), length(input_json$`date`) == 1) + if (!(is.character(input_json$`date`) && length(input_json$`date`) == 1)) { + stop(paste("Error! Invalid data for `date`. Must be a string:", input_json$`date`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `date` is missing.")) } # check the required field `password` if (!is.null(input_json$`password`)) { - stopifnot(is.character(input_json$`password`), length(input_json$`password`) == 1) + if (!(is.character(input_json$`password`) && length(input_json$`password`) == 1)) { + stop(paste("Error! Invalid data for `password`. Must be a string:", input_json$`password`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `password` is missing.")) } 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 03059bb52259..b0e4bbba7e97 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 @@ -36,15 +36,21 @@ ModelApiResponse <- R6::R6Class( #' @export initialize = function(`code` = NULL, `type` = NULL, `message` = NULL, additional_properties = NULL, ...) { if (!is.null(`code`)) { - stopifnot(is.numeric(`code`), length(`code`) == 1) + if (!(is.numeric(`code`) && length(`code`) == 1)) { + stop(paste("Error! Invalid data for `code`. Must be an integer:", `code`)) + } self$`code` <- `code` } if (!is.null(`type`)) { - stopifnot(is.character(`type`), length(`type`) == 1) + if (!(is.character(`type`) && length(`type`) == 1)) { + stop(paste("Error! Invalid data for `type`. Must be a string:", `type`)) + } self$`type` <- `type` } if (!is.null(`message`)) { - stopifnot(is.character(`message`), length(`message`) == 1) + if (!(is.character(`message`) && length(`message`) == 1)) { + stop(paste("Error! Invalid data for `message`. Must be a string:", `message`)) + } self$`message` <- `message` } if (!is.null(additional_properties)) { 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 68b0db6b3712..73f4e938cbd3 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 @@ -33,7 +33,9 @@ NestedOneOf <- R6::R6Class( #' @export initialize = function(`size` = NULL, `nested_pig` = NULL, additional_properties = NULL, ...) { if (!is.null(`size`)) { - stopifnot(is.numeric(`size`), length(`size`) == 1) + if (!(is.numeric(`size`) && length(`size`) == 1)) { + stop(paste("Error! Invalid data for `size`. Must be an integer:", `size`)) + } self$`size` <- `size` } if (!is.null(`nested_pig`)) { diff --git a/samples/client/petstore/R-httr2-wrapper/R/order.R b/samples/client/petstore/R-httr2-wrapper/R/order.R index 74f319e45dbc..266468962695 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/order.R +++ b/samples/client/petstore/R-httr2-wrapper/R/order.R @@ -45,20 +45,26 @@ Order <- R6::R6Class( #' @export initialize = function(`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) + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } self$`id` <- `id` } if (!is.null(`petId`)) { - stopifnot(is.numeric(`petId`), length(`petId`) == 1) + if (!(is.numeric(`petId`) && length(`petId`) == 1)) { + stop(paste("Error! Invalid data for `petId`. Must be an integer:", `petId`)) + } self$`petId` <- `petId` } if (!is.null(`quantity`)) { - stopifnot(is.numeric(`quantity`), length(`quantity`) == 1) + if (!(is.numeric(`quantity`) && length(`quantity`) == 1)) { + stop(paste("Error! Invalid data for `quantity`. Must be an integer:", `quantity`)) + } self$`quantity` <- `quantity` } if (!is.null(`shipDate`)) { if (!is.character(`shipDate`)) { - stop(paste("Error! Invalid DateTime. Must be a string:", `shipDate`)) + stop(paste("Error! Invalid data for `shipDate`. Must be a string:", `shipDate`)) } self$`shipDate` <- `shipDate` } @@ -66,11 +72,15 @@ Order <- R6::R6Class( if (!(`status` %in% c("placed", "approved", "delivered"))) { stop(paste("Error! \"", `status`, "\" cannot be assigned to `status`. Must be \"placed\", \"approved\", \"delivered\".", sep = "")) } - stopifnot(is.character(`status`), length(`status`) == 1) + if (!(is.character(`status`) && length(`status`) == 1)) { + stop(paste("Error! Invalid data for `status`. Must be a string:", `status`)) + } self$`status` <- `status` } if (!is.null(`complete`)) { - stopifnot(is.logical(`complete`), length(`complete`) == 1) + if (!(is.logical(`complete`) && length(`complete`) == 1)) { + stop(paste("Error! Invalid data for `complete`. Must be a boolean:", `complete`)) + } self$`complete` <- `complete` } if (!is.null(additional_properties)) { diff --git a/samples/client/petstore/R-httr2-wrapper/R/pet.R b/samples/client/petstore/R-httr2-wrapper/R/pet.R index 63318448c0c4..8be5a0583359 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/pet.R +++ b/samples/client/petstore/R-httr2-wrapper/R/pet.R @@ -45,7 +45,9 @@ Pet <- R6::R6Class( #' @export initialize = function(`name`, `photoUrls`, `id` = NULL, `category` = NULL, `tags` = NULL, `status` = NULL, additional_properties = NULL, ...) { if (!missing(`name`)) { - stopifnot(is.character(`name`), length(`name`) == 1) + if (!(is.character(`name`) && length(`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", `name`)) + } self$`name` <- `name` } if (!missing(`photoUrls`)) { @@ -54,7 +56,9 @@ Pet <- R6::R6Class( self$`photoUrls` <- `photoUrls` } if (!is.null(`id`)) { - stopifnot(is.numeric(`id`), length(`id`) == 1) + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } self$`id` <- `id` } if (!is.null(`category`)) { @@ -70,7 +74,9 @@ Pet <- R6::R6Class( if (!(`status` %in% c("available", "pending", "sold"))) { stop(paste("Error! \"", `status`, "\" cannot be assigned to `status`. Must be \"available\", \"pending\", \"sold\".", sep = "")) } - stopifnot(is.character(`status`), length(`status`) == 1) + if (!(is.character(`status`) && length(`status`) == 1)) { + stop(paste("Error! Invalid data for `status`. Must be a string:", `status`)) + } self$`status` <- `status` } if (!is.null(additional_properties)) { @@ -265,7 +271,9 @@ Pet <- R6::R6Class( input_json <- jsonlite::fromJSON(input) # check the required field `name` if (!is.null(input_json$`name`)) { - stopifnot(is.character(input_json$`name`), length(input_json$`name`) == 1) + if (!(is.character(input_json$`name`) && length(input_json$`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", input_json$`name`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Pet: the required field `name` is missing.")) } diff --git a/samples/client/petstore/R-httr2-wrapper/R/special.R b/samples/client/petstore/R-httr2-wrapper/R/special.R index 33f06cc6a672..39664bea75ce 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/special.R +++ b/samples/client/petstore/R-httr2-wrapper/R/special.R @@ -56,27 +56,39 @@ Special <- R6::R6Class( self$`set_test` <- `set_test` } if (!is.null(`item_self`)) { - stopifnot(is.numeric(`item_self`), length(`item_self`) == 1) + if (!(is.numeric(`item_self`) && length(`item_self`) == 1)) { + stop(paste("Error! Invalid data for `item_self`. Must be an integer:", `item_self`)) + } self$`item_self` <- `item_self` } if (!is.null(`item_private`)) { - stopifnot(is.character(`item_private`), length(`item_private`) == 1) + if (!(is.character(`item_private`) && length(`item_private`) == 1)) { + stop(paste("Error! Invalid data for `item_private`. Must be a string:", `item_private`)) + } self$`item_private` <- `item_private` } if (!is.null(`item_super`)) { - stopifnot(is.character(`item_super`), length(`item_super`) == 1) + if (!(is.character(`item_super`) && length(`item_super`) == 1)) { + stop(paste("Error! Invalid data for `item_super`. Must be a string:", `item_super`)) + } self$`item_super` <- `item_super` } if (!is.null(`123_number`)) { - stopifnot(is.character(`123_number`), length(`123_number`) == 1) + if (!(is.character(`123_number`) && length(`123_number`) == 1)) { + stop(paste("Error! Invalid data for `123_number`. Must be a string:", `123_number`)) + } self$`123_number` <- `123_number` } if (!is.null(`array[test]`)) { - stopifnot(is.character(`array[test]`), length(`array[test]`) == 1) + if (!(is.character(`array[test]`) && length(`array[test]`) == 1)) { + stop(paste("Error! Invalid data for `array[test]`. Must be a string:", `array[test]`)) + } self$`array[test]` <- `array[test]` } if (!is.null(`empty_string`)) { - stopifnot(is.character(`empty_string`), length(`empty_string`) == 1) + if (!(is.character(`empty_string`) && length(`empty_string`) == 1)) { + stop(paste("Error! Invalid data for `empty_string`. Must be a string:", `empty_string`)) + } self$`empty_string` <- `empty_string` } if (!is.null(additional_properties)) { diff --git a/samples/client/petstore/R-httr2-wrapper/R/tag.R b/samples/client/petstore/R-httr2-wrapper/R/tag.R index bd4aac10e2f6..be068d1474c5 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/tag.R +++ b/samples/client/petstore/R-httr2-wrapper/R/tag.R @@ -33,11 +33,15 @@ Tag <- R6::R6Class( #' @export initialize = function(`id` = NULL, `name` = NULL, additional_properties = NULL, ...) { if (!is.null(`id`)) { - stopifnot(is.numeric(`id`), length(`id`) == 1) + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } self$`id` <- `id` } if (!is.null(`name`)) { - stopifnot(is.character(`name`), length(`name`) == 1) + if (!(is.character(`name`) && length(`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", `name`)) + } self$`name` <- `name` } if (!is.null(additional_properties)) { diff --git a/samples/client/petstore/R-httr2-wrapper/R/user.R b/samples/client/petstore/R-httr2-wrapper/R/user.R index 153aacb3ea52..43b51ffa41c2 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/user.R +++ b/samples/client/petstore/R-httr2-wrapper/R/user.R @@ -51,35 +51,51 @@ User <- R6::R6Class( #' @export initialize = function(`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) + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } self$`id` <- `id` } if (!is.null(`username`)) { - stopifnot(is.character(`username`), length(`username`) == 1) + if (!(is.character(`username`) && length(`username`) == 1)) { + stop(paste("Error! Invalid data for `username`. Must be a string:", `username`)) + } self$`username` <- `username` } if (!is.null(`firstName`)) { - stopifnot(is.character(`firstName`), length(`firstName`) == 1) + if (!(is.character(`firstName`) && length(`firstName`) == 1)) { + stop(paste("Error! Invalid data for `firstName`. Must be a string:", `firstName`)) + } self$`firstName` <- `firstName` } if (!is.null(`lastName`)) { - stopifnot(is.character(`lastName`), length(`lastName`) == 1) + if (!(is.character(`lastName`) && length(`lastName`) == 1)) { + stop(paste("Error! Invalid data for `lastName`. Must be a string:", `lastName`)) + } self$`lastName` <- `lastName` } if (!is.null(`email`)) { - stopifnot(is.character(`email`), length(`email`) == 1) + if (!(is.character(`email`) && length(`email`) == 1)) { + stop(paste("Error! Invalid data for `email`. Must be a string:", `email`)) + } self$`email` <- `email` } if (!is.null(`password`)) { - stopifnot(is.character(`password`), length(`password`) == 1) + if (!(is.character(`password`) && length(`password`) == 1)) { + stop(paste("Error! Invalid data for `password`. Must be a string:", `password`)) + } self$`password` <- `password` } if (!is.null(`phone`)) { - stopifnot(is.character(`phone`), length(`phone`) == 1) + if (!(is.character(`phone`) && length(`phone`) == 1)) { + stop(paste("Error! Invalid data for `phone`. Must be a string:", `phone`)) + } self$`phone` <- `phone` } if (!is.null(`userStatus`)) { - stopifnot(is.numeric(`userStatus`), length(`userStatus`) == 1) + if (!(is.numeric(`userStatus`) && length(`userStatus`) == 1)) { + stop(paste("Error! Invalid data for `userStatus`. Must be an integer:", `userStatus`)) + } self$`userStatus` <- `userStatus` } if (!is.null(additional_properties)) { diff --git a/samples/client/petstore/R-httr2-wrapper/R/whale.R b/samples/client/petstore/R-httr2-wrapper/R/whale.R index 936b3a2573ed..dc70b1dd33e5 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/whale.R +++ b/samples/client/petstore/R-httr2-wrapper/R/whale.R @@ -36,15 +36,21 @@ Whale <- R6::R6Class( #' @export initialize = function(`className`, `hasBaleen` = NULL, `hasTeeth` = NULL, additional_properties = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!is.null(`hasBaleen`)) { - stopifnot(is.logical(`hasBaleen`), length(`hasBaleen`) == 1) + if (!(is.logical(`hasBaleen`) && length(`hasBaleen`) == 1)) { + stop(paste("Error! Invalid data for `hasBaleen`. Must be a boolean:", `hasBaleen`)) + } self$`hasBaleen` <- `hasBaleen` } if (!is.null(`hasTeeth`)) { - stopifnot(is.logical(`hasTeeth`), length(`hasTeeth`) == 1) + if (!(is.logical(`hasTeeth`) && length(`hasTeeth`) == 1)) { + stop(paste("Error! Invalid data for `hasTeeth`. Must be a boolean:", `hasTeeth`)) + } self$`hasTeeth` <- `hasTeeth` } if (!is.null(additional_properties)) { @@ -183,7 +189,9 @@ Whale <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Whale: the required field `className` is missing.")) } diff --git a/samples/client/petstore/R-httr2-wrapper/R/zebra.R b/samples/client/petstore/R-httr2-wrapper/R/zebra.R index 5c090e84cbb9..c8d06d23d6a5 100644 --- a/samples/client/petstore/R-httr2-wrapper/R/zebra.R +++ b/samples/client/petstore/R-httr2-wrapper/R/zebra.R @@ -33,14 +33,18 @@ Zebra <- R6::R6Class( #' @export initialize = function(`className`, `type` = NULL, additional_properties = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!is.null(`type`)) { if (!(`type` %in% c("plains", "mountain", "grevys"))) { stop(paste("Error! \"", `type`, "\" cannot be assigned to `type`. Must be \"plains\", \"mountain\", \"grevys\".", sep = "")) } - stopifnot(is.character(`type`), length(`type`) == 1) + if (!(is.character(`type`) && length(`type`) == 1)) { + stop(paste("Error! Invalid data for `type`. Must be a string:", `type`)) + } self$`type` <- `type` } if (!is.null(additional_properties)) { @@ -169,7 +173,9 @@ Zebra <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Zebra: the required field `className` is missing.")) } 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 2ee7d0aa0c90..38ce56f57334 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 @@ -600,7 +600,7 @@ test_that("Tests URL validation", { Date$public_methods$validateJSON(valid_json) # shouldn't throw exception invalid_json <- '{"className":"date","percent_description":"abc","url_property":"invalid_url"}' - expect_error(Date$public_methods$validateJSON(invalid_json), 'Error! Invalid URL: invalid_url') # should throw exception + expect_error(Date$public_methods$validateJSON(invalid_json), 'Error! Invalid data for `url_property`. Must be a URL: invalid_url') # should throw exception # test fromJSONString with valid data d <- Date$new() @@ -611,7 +611,7 @@ test_that("Tests URL validation", { # test fromJSONString with invalid data d <- Date$new() - expect_error(d$fromJSONString(invalid_json), 'Error! Invalid URL: invalid_url') # should throw exception + expect_error(d$fromJSONString(invalid_json), 'Error! Invalid data for `url_property`. Must be a URL: invalid_url') # should throw exception }) @@ -621,5 +621,5 @@ test_that("Order and datetime test", { expect_equal(t$toJSONString(), "{\"id\":393,\"petId\":12930,\"quantity\":12,\"shipDate\":\"2019-09-29T19:39:29Z\",\"status\":\"approved\",\"complete\":false}") - expect_error(Order$new(id = 393, petId = 12930, quantity = 12, shipDate = TRUE, status = "approved"), "Error! Invalid DateTime. Must be a string: TRUE") + expect_error(Order$new(id = 393, petId = 12930, quantity = 12, shipDate = TRUE, status = "approved"), "Error! Invalid data for `shipDate`. Must be a string: TRUE") }) 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 de8c4c800347..c4134b53e68f 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 @@ -37,23 +37,33 @@ AllofTagApiResponse <- R6::R6Class( #' @export initialize = function(`id` = NULL, `name` = NULL, `code` = NULL, `type` = NULL, `message` = NULL, ...) { if (!is.null(`id`)) { - stopifnot(is.numeric(`id`), length(`id`) == 1) + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } self$`id` <- `id` } if (!is.null(`name`)) { - stopifnot(is.character(`name`), length(`name`) == 1) + if (!(is.character(`name`) && length(`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", `name`)) + } self$`name` <- `name` } if (!is.null(`code`)) { - stopifnot(is.numeric(`code`), length(`code`) == 1) + if (!(is.numeric(`code`) && length(`code`) == 1)) { + stop(paste("Error! Invalid data for `code`. Must be an integer:", `code`)) + } self$`code` <- `code` } if (!is.null(`type`)) { - stopifnot(is.character(`type`), length(`type`) == 1) + if (!(is.character(`type`) && length(`type`) == 1)) { + stop(paste("Error! Invalid data for `type`. Must be a string:", `type`)) + } self$`type` <- `type` } if (!is.null(`message`)) { - stopifnot(is.character(`message`), length(`message`) == 1) + if (!(is.character(`message`) && length(`message`) == 1)) { + stop(paste("Error! Invalid data for `message`. Must be a string:", `message`)) + } self$`message` <- `message` } }, diff --git a/samples/client/petstore/R-httr2/R/animal.R b/samples/client/petstore/R-httr2/R/animal.R index f111fd1252b2..6b4d78ff5ede 100644 --- a/samples/client/petstore/R-httr2/R/animal.R +++ b/samples/client/petstore/R-httr2/R/animal.R @@ -30,11 +30,15 @@ Animal <- R6::R6Class( #' @export initialize = function(`className`, `color` = "red", ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!is.null(`color`)) { - stopifnot(is.character(`color`), length(`color`) == 1) + if (!(is.character(`color`) && length(`color`) == 1)) { + stop(paste("Error! Invalid data for `color`. Must be a string:", `color`)) + } self$`color` <- `color` } }, @@ -129,7 +133,9 @@ Animal <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Animal: the required field `className` is missing.")) } diff --git a/samples/client/petstore/R-httr2/R/basque_pig.R b/samples/client/petstore/R-httr2/R/basque_pig.R index 0a83d2b25487..28a10e6ddc44 100644 --- a/samples/client/petstore/R-httr2/R/basque_pig.R +++ b/samples/client/petstore/R-httr2/R/basque_pig.R @@ -28,11 +28,15 @@ BasquePig <- R6::R6Class( #' @export initialize = function(`className`, `color`, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!missing(`color`)) { - stopifnot(is.character(`color`), length(`color`) == 1) + if (!(is.character(`color`) && length(`color`) == 1)) { + stop(paste("Error! Invalid data for `color`. Must be a string:", `color`)) + } self$`color` <- `color` } }, @@ -127,13 +131,17 @@ BasquePig <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for BasquePig: the required field `className` is missing.")) } # check the required field `color` if (!is.null(input_json$`color`)) { - stopifnot(is.character(input_json$`color`), length(input_json$`color`) == 1) + if (!(is.character(input_json$`color`) && length(input_json$`color`) == 1)) { + stop(paste("Error! Invalid data for `color`. Must be a string:", input_json$`color`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for BasquePig: the required field `color` is missing.")) } diff --git a/samples/client/petstore/R-httr2/R/cat.R b/samples/client/petstore/R-httr2/R/cat.R index f9bfc07a9abc..eaba966de584 100644 --- a/samples/client/petstore/R-httr2/R/cat.R +++ b/samples/client/petstore/R-httr2/R/cat.R @@ -32,15 +32,21 @@ Cat <- R6::R6Class( #' @export initialize = function(`className`, `color` = "red", `declawed` = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!is.null(`color`)) { - stopifnot(is.character(`color`), length(`color`) == 1) + if (!(is.character(`color`) && length(`color`) == 1)) { + stop(paste("Error! Invalid data for `color`. Must be a string:", `color`)) + } self$`color` <- `color` } if (!is.null(`declawed`)) { - stopifnot(is.logical(`declawed`), length(`declawed`) == 1) + if (!(is.logical(`declawed`) && length(`declawed`) == 1)) { + stop(paste("Error! Invalid data for `declawed`. Must be a boolean:", `declawed`)) + } self$`declawed` <- `declawed` } }, @@ -151,7 +157,9 @@ Cat <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Cat: the required field `className` is missing.")) } 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 b54b944cd269..d2889ac4990b 100644 --- a/samples/client/petstore/R-httr2/R/cat_all_of.R +++ b/samples/client/petstore/R-httr2/R/cat_all_of.R @@ -25,7 +25,9 @@ CatAllOf <- R6::R6Class( #' @export initialize = function(`declawed` = NULL, ...) { if (!is.null(`declawed`)) { - stopifnot(is.logical(`declawed`), length(`declawed`) == 1) + if (!(is.logical(`declawed`) && length(`declawed`) == 1)) { + stop(paste("Error! Invalid data for `declawed`. Must be a boolean:", `declawed`)) + } self$`declawed` <- `declawed` } }, diff --git a/samples/client/petstore/R-httr2/R/category.R b/samples/client/petstore/R-httr2/R/category.R index ab4f475202ea..82c562286049 100644 --- a/samples/client/petstore/R-httr2/R/category.R +++ b/samples/client/petstore/R-httr2/R/category.R @@ -28,11 +28,15 @@ Category <- R6::R6Class( #' @export initialize = function(`id` = NULL, `name` = NULL, ...) { if (!is.null(`id`)) { - stopifnot(is.numeric(`id`), length(`id`) == 1) + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } self$`id` <- `id` } if (!is.null(`name`)) { - stopifnot(is.character(`name`), length(`name`) == 1) + if (!(is.character(`name`) && length(`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", `name`)) + } self$`name` <- `name` } }, diff --git a/samples/client/petstore/R-httr2/R/danish_pig.R b/samples/client/petstore/R-httr2/R/danish_pig.R index 206cdeca85a5..aea435d0fbf1 100644 --- a/samples/client/petstore/R-httr2/R/danish_pig.R +++ b/samples/client/petstore/R-httr2/R/danish_pig.R @@ -28,11 +28,15 @@ DanishPig <- R6::R6Class( #' @export initialize = function(`className`, `size`, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!missing(`size`)) { - stopifnot(is.numeric(`size`), length(`size`) == 1) + if (!(is.numeric(`size`) && length(`size`) == 1)) { + stop(paste("Error! Invalid data for `size`. Must be an integer:", `size`)) + } self$`size` <- `size` } }, @@ -127,13 +131,17 @@ DanishPig <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for DanishPig: the required field `className` is missing.")) } # check the required field `size` if (!is.null(input_json$`size`)) { - stopifnot(is.numeric(input_json$`size`), length(input_json$`size`) == 1) + if (!(is.numeric(input_json$`size`) && length(input_json$`size`) == 1)) { + stop(paste("Error! Invalid data for `size`. Must be an integer:", input_json$`size`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for DanishPig: the required field `size` is missing.")) } diff --git a/samples/client/petstore/R-httr2/R/date.R b/samples/client/petstore/R-httr2/R/date.R index 8af974b7ae57..a188cad8fce6 100644 --- a/samples/client/petstore/R-httr2/R/date.R +++ b/samples/client/petstore/R-httr2/R/date.R @@ -31,19 +31,25 @@ Date <- R6::R6Class( #' @export initialize = function(`className`, `url_property`, `percent_description` = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!missing(`url_property`)) { - stopifnot(is.character(`url_property`), length(`url_property`) == 1) + if (!(is.character(`url_property`) && length(`url_property`) == 1)) { + stop(paste("Error! Invalid data for `url_property`. Must be a string:", `url_property`)) + } # to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r if (!stringr::str_detect(`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) { - stop(paste("Error! Invalid URL:", `url_property`)) + stop(paste("Error! Invalid data for `url_property`. Must be a URL:", `url_property`)) } self$`url_property` <- `url_property` } if (!is.null(`percent_description`)) { - stopifnot(is.character(`percent_description`), length(`percent_description`) == 1) + if (!(is.character(`percent_description`) && length(`percent_description`) == 1)) { + stop(paste("Error! Invalid data for `percent_description`. Must be a string:", `percent_description`)) + } self$`percent_description` <- `percent_description` } }, @@ -89,7 +95,7 @@ Date <- R6::R6Class( if (!is.null(this_object$`url_property`)) { # to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r if (!stringr::str_detect(this_object$`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) { - stop(paste("Error! Invalid URL:", this_object$`url_property`)) + stop(paste("Error! Invalid data for `url_property`. Must be a URL:", this_object$`url_property`)) } self$`url_property` <- this_object$`url_property` } @@ -146,7 +152,7 @@ Date <- R6::R6Class( self$`percent_description` <- this_object$`percent_description` # to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r if (!stringr::str_detect(this_object$`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) { - stop(paste("Error! Invalid URL:", this_object$`url_property`)) + stop(paste("Error! Invalid data for `url_property`. Must be a URL:", this_object$`url_property`)) } self$`url_property` <- this_object$`url_property` self @@ -162,16 +168,20 @@ Date <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Date: the required field `className` is missing.")) } # check the required field `url_property` if (!is.null(input_json$`url_property`)) { - stopifnot(is.character(input_json$`url_property`), length(input_json$`url_property`) == 1) + if (!(is.character(input_json$`url_property`) && length(input_json$`url_property`) == 1)) { + stop(paste("Error! Invalid data for `url_property`. Must be a string:", input_json$`url_property`)) + } # to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r if (!stringr::str_detect(input_json$`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) { - stop(paste("Error! Invalid URL:", input_json$`url_property`)) + stop(paste("Error! Invalid data for `url_property`. Must be a URL:", input_json$`url_property`)) } } else { stop(paste("The JSON input `", input, "` is invalid for Date: the required field `url_property` is missing.")) diff --git a/samples/client/petstore/R-httr2/R/dog.R b/samples/client/petstore/R-httr2/R/dog.R index 75299cdfc78c..9585ef81a58c 100644 --- a/samples/client/petstore/R-httr2/R/dog.R +++ b/samples/client/petstore/R-httr2/R/dog.R @@ -32,15 +32,21 @@ Dog <- R6::R6Class( #' @export initialize = function(`className`, `color` = "red", `breed` = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!is.null(`color`)) { - stopifnot(is.character(`color`), length(`color`) == 1) + if (!(is.character(`color`) && length(`color`) == 1)) { + stop(paste("Error! Invalid data for `color`. Must be a string:", `color`)) + } self$`color` <- `color` } if (!is.null(`breed`)) { - stopifnot(is.character(`breed`), length(`breed`) == 1) + if (!(is.character(`breed`) && length(`breed`) == 1)) { + stop(paste("Error! Invalid data for `breed`. Must be a string:", `breed`)) + } self$`breed` <- `breed` } }, @@ -151,7 +157,9 @@ Dog <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Dog: the required field `className` is missing.")) } 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 fc8e7d0a6d65..c9ad55312255 100644 --- a/samples/client/petstore/R-httr2/R/dog_all_of.R +++ b/samples/client/petstore/R-httr2/R/dog_all_of.R @@ -25,7 +25,9 @@ DogAllOf <- R6::R6Class( #' @export initialize = function(`breed` = NULL, ...) { if (!is.null(`breed`)) { - stopifnot(is.character(`breed`), length(`breed`) == 1) + if (!(is.character(`breed`) && length(`breed`) == 1)) { + stop(paste("Error! Invalid data for `breed`. Must be a string:", `breed`)) + } self$`breed` <- `breed` } }, diff --git a/samples/client/petstore/R-httr2/R/format_test.R b/samples/client/petstore/R-httr2/R/format_test.R index aa3f0e7ac9c9..8361a769f0ff 100644 --- a/samples/client/petstore/R-httr2/R/format_test.R +++ b/samples/client/petstore/R-httr2/R/format_test.R @@ -73,37 +73,51 @@ FormatTest <- R6::R6Class( self$`byte` <- `byte` } if (!missing(`date`)) { - if (!is.character(`date`)) { - stop(paste("Error! Invalid Date. Must be a string:", `date`)) + if (!(is.character(`date`) && length(`date`) == 1)) { + stop(paste("Error! Invalid data for `date`. Must be a string:", `date`)) } self$`date` <- `date` } if (!missing(`password`)) { - stopifnot(is.character(`password`), length(`password`) == 1) + if (!(is.character(`password`) && length(`password`) == 1)) { + stop(paste("Error! Invalid data for `password`. Must be a string:", `password`)) + } self$`password` <- `password` } if (!is.null(`integer`)) { - stopifnot(is.numeric(`integer`), length(`integer`) == 1) + if (!(is.numeric(`integer`) && length(`integer`) == 1)) { + stop(paste("Error! Invalid data for `integer`. Must be an integer:", `integer`)) + } self$`integer` <- `integer` } if (!is.null(`int32`)) { - stopifnot(is.numeric(`int32`), length(`int32`) == 1) + if (!(is.numeric(`int32`) && length(`int32`) == 1)) { + stop(paste("Error! Invalid data for `int32`. Must be an integer:", `int32`)) + } self$`int32` <- `int32` } if (!is.null(`int64`)) { - stopifnot(is.numeric(`int64`), length(`int64`) == 1) + if (!(is.numeric(`int64`) && length(`int64`) == 1)) { + stop(paste("Error! Invalid data for `int64`. Must be an integer:", `int64`)) + } self$`int64` <- `int64` } if (!is.null(`float`)) { - stopifnot(is.numeric(`float`), length(`float`) == 1) + if (!(is.numeric(`float`) && length(`float`) == 1)) { + stop(paste("Error! Invalid data for `float`. Must be a number:", `float`)) + } self$`float` <- `float` } if (!is.null(`double`)) { - stopifnot(is.numeric(`double`), length(`double`) == 1) + if (!(is.numeric(`double`) && length(`double`) == 1)) { + stop(paste("Error! Invalid data for `double`. Must be a number:", `double`)) + } self$`double` <- `double` } if (!is.null(`string`)) { - stopifnot(is.character(`string`), length(`string`) == 1) + if (!(is.character(`string`) && length(`string`) == 1)) { + stop(paste("Error! Invalid data for `string`. Must be a string:", `string`)) + } self$`string` <- `string` } if (!is.null(`binary`)) { @@ -111,20 +125,26 @@ FormatTest <- R6::R6Class( } if (!is.null(`dateTime`)) { if (!is.character(`dateTime`)) { - stop(paste("Error! Invalid DateTime. Must be a string:", `dateTime`)) + stop(paste("Error! Invalid data for `dateTime`. Must be a string:", `dateTime`)) } self$`dateTime` <- `dateTime` } if (!is.null(`uuid`)) { - stopifnot(is.character(`uuid`), length(`uuid`) == 1) + if (!(is.character(`uuid`) && length(`uuid`) == 1)) { + stop(paste("Error! Invalid data for `uuid`. Must be a string:", `uuid`)) + } self$`uuid` <- `uuid` } if (!is.null(`pattern_with_digits`)) { - stopifnot(is.character(`pattern_with_digits`), length(`pattern_with_digits`) == 1) + if (!(is.character(`pattern_with_digits`) && length(`pattern_with_digits`) == 1)) { + stop(paste("Error! Invalid data for `pattern_with_digits`. Must be a string:", `pattern_with_digits`)) + } self$`pattern_with_digits` <- `pattern_with_digits` } if (!is.null(`pattern_with_digits_and_delimiter`)) { - stopifnot(is.character(`pattern_with_digits_and_delimiter`), length(`pattern_with_digits_and_delimiter`) == 1) + if (!(is.character(`pattern_with_digits_and_delimiter`) && length(`pattern_with_digits_and_delimiter`) == 1)) { + stop(paste("Error! Invalid data for `pattern_with_digits_and_delimiter`. Must be a string:", `pattern_with_digits_and_delimiter`)) + } self$`pattern_with_digits_and_delimiter` <- `pattern_with_digits_and_delimiter` } }, @@ -437,13 +457,17 @@ FormatTest <- R6::R6Class( } # check the required field `date` if (!is.null(input_json$`date`)) { - stopifnot(is.character(input_json$`date`), length(input_json$`date`) == 1) + if (!(is.character(input_json$`date`) && length(input_json$`date`) == 1)) { + stop(paste("Error! Invalid data for `date`. Must be a string:", input_json$`date`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `date` is missing.")) } # check the required field `password` if (!is.null(input_json$`password`)) { - stopifnot(is.character(input_json$`password`), length(input_json$`password`) == 1) + if (!(is.character(input_json$`password`) && length(input_json$`password`) == 1)) { + stop(paste("Error! Invalid data for `password`. Must be a string:", input_json$`password`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `password` is missing.")) } 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 de8760bdf23a..0fd0c71e99c3 100644 --- a/samples/client/petstore/R-httr2/R/model_api_response.R +++ b/samples/client/petstore/R-httr2/R/model_api_response.R @@ -31,15 +31,21 @@ ModelApiResponse <- R6::R6Class( #' @export initialize = function(`code` = NULL, `type` = NULL, `message` = NULL, ...) { if (!is.null(`code`)) { - stopifnot(is.numeric(`code`), length(`code`) == 1) + if (!(is.numeric(`code`) && length(`code`) == 1)) { + stop(paste("Error! Invalid data for `code`. Must be an integer:", `code`)) + } self$`code` <- `code` } if (!is.null(`type`)) { - stopifnot(is.character(`type`), length(`type`) == 1) + if (!(is.character(`type`) && length(`type`) == 1)) { + stop(paste("Error! Invalid data for `type`. Must be a string:", `type`)) + } self$`type` <- `type` } if (!is.null(`message`)) { - stopifnot(is.character(`message`), length(`message`) == 1) + if (!(is.character(`message`) && length(`message`) == 1)) { + stop(paste("Error! Invalid data for `message`. Must be a string:", `message`)) + } self$`message` <- `message` } }, 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 542a11c4d21f..beef5124f9b5 100644 --- a/samples/client/petstore/R-httr2/R/nested_one_of.R +++ b/samples/client/petstore/R-httr2/R/nested_one_of.R @@ -28,7 +28,9 @@ NestedOneOf <- R6::R6Class( #' @export initialize = function(`size` = NULL, `nested_pig` = NULL, ...) { if (!is.null(`size`)) { - stopifnot(is.numeric(`size`), length(`size`) == 1) + if (!(is.numeric(`size`) && length(`size`) == 1)) { + stop(paste("Error! Invalid data for `size`. Must be an integer:", `size`)) + } self$`size` <- `size` } if (!is.null(`nested_pig`)) { diff --git a/samples/client/petstore/R-httr2/R/order.R b/samples/client/petstore/R-httr2/R/order.R index 629c75bca37f..b5604d999007 100644 --- a/samples/client/petstore/R-httr2/R/order.R +++ b/samples/client/petstore/R-httr2/R/order.R @@ -40,20 +40,26 @@ Order <- R6::R6Class( #' @export initialize = function(`id` = NULL, `petId` = NULL, `quantity` = NULL, `shipDate` = NULL, `status` = NULL, `complete` = FALSE, ...) { if (!is.null(`id`)) { - stopifnot(is.numeric(`id`), length(`id`) == 1) + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } self$`id` <- `id` } if (!is.null(`petId`)) { - stopifnot(is.numeric(`petId`), length(`petId`) == 1) + if (!(is.numeric(`petId`) && length(`petId`) == 1)) { + stop(paste("Error! Invalid data for `petId`. Must be an integer:", `petId`)) + } self$`petId` <- `petId` } if (!is.null(`quantity`)) { - stopifnot(is.numeric(`quantity`), length(`quantity`) == 1) + if (!(is.numeric(`quantity`) && length(`quantity`) == 1)) { + stop(paste("Error! Invalid data for `quantity`. Must be an integer:", `quantity`)) + } self$`quantity` <- `quantity` } if (!is.null(`shipDate`)) { if (!is.character(`shipDate`)) { - stop(paste("Error! Invalid DateTime. Must be a string:", `shipDate`)) + stop(paste("Error! Invalid data for `shipDate`. Must be a string:", `shipDate`)) } self$`shipDate` <- `shipDate` } @@ -61,11 +67,15 @@ Order <- R6::R6Class( if (!(`status` %in% c("placed", "approved", "delivered"))) { stop(paste("Error! \"", `status`, "\" cannot be assigned to `status`. Must be \"placed\", \"approved\", \"delivered\".", sep = "")) } - stopifnot(is.character(`status`), length(`status`) == 1) + if (!(is.character(`status`) && length(`status`) == 1)) { + stop(paste("Error! Invalid data for `status`. Must be a string:", `status`)) + } self$`status` <- `status` } if (!is.null(`complete`)) { - stopifnot(is.logical(`complete`), length(`complete`) == 1) + if (!(is.logical(`complete`) && length(`complete`) == 1)) { + stop(paste("Error! Invalid data for `complete`. Must be a boolean:", `complete`)) + } self$`complete` <- `complete` } }, diff --git a/samples/client/petstore/R-httr2/R/pet.R b/samples/client/petstore/R-httr2/R/pet.R index f840c7ca9aba..be5b2767ef1f 100644 --- a/samples/client/petstore/R-httr2/R/pet.R +++ b/samples/client/petstore/R-httr2/R/pet.R @@ -40,7 +40,9 @@ Pet <- R6::R6Class( #' @export initialize = function(`name`, `photoUrls`, `id` = NULL, `category` = NULL, `tags` = NULL, `status` = NULL, ...) { if (!missing(`name`)) { - stopifnot(is.character(`name`), length(`name`) == 1) + if (!(is.character(`name`) && length(`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", `name`)) + } self$`name` <- `name` } if (!missing(`photoUrls`)) { @@ -49,7 +51,9 @@ Pet <- R6::R6Class( self$`photoUrls` <- `photoUrls` } if (!is.null(`id`)) { - stopifnot(is.numeric(`id`), length(`id`) == 1) + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } self$`id` <- `id` } if (!is.null(`category`)) { @@ -65,7 +69,9 @@ Pet <- R6::R6Class( if (!(`status` %in% c("available", "pending", "sold"))) { stop(paste("Error! \"", `status`, "\" cannot be assigned to `status`. Must be \"available\", \"pending\", \"sold\".", sep = "")) } - stopifnot(is.character(`status`), length(`status`) == 1) + if (!(is.character(`status`) && length(`status`) == 1)) { + stop(paste("Error! Invalid data for `status`. Must be a string:", `status`)) + } self$`status` <- `status` } }, @@ -232,7 +238,9 @@ Pet <- R6::R6Class( input_json <- jsonlite::fromJSON(input) # check the required field `name` if (!is.null(input_json$`name`)) { - stopifnot(is.character(input_json$`name`), length(input_json$`name`) == 1) + if (!(is.character(input_json$`name`) && length(input_json$`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", input_json$`name`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Pet: the required field `name` is missing.")) } diff --git a/samples/client/petstore/R-httr2/R/special.R b/samples/client/petstore/R-httr2/R/special.R index 32ced477530e..e2089142e9d6 100644 --- a/samples/client/petstore/R-httr2/R/special.R +++ b/samples/client/petstore/R-httr2/R/special.R @@ -51,27 +51,39 @@ Special <- R6::R6Class( self$`set_test` <- `set_test` } if (!is.null(`item_self`)) { - stopifnot(is.numeric(`item_self`), length(`item_self`) == 1) + if (!(is.numeric(`item_self`) && length(`item_self`) == 1)) { + stop(paste("Error! Invalid data for `item_self`. Must be an integer:", `item_self`)) + } self$`item_self` <- `item_self` } if (!is.null(`item_private`)) { - stopifnot(is.character(`item_private`), length(`item_private`) == 1) + if (!(is.character(`item_private`) && length(`item_private`) == 1)) { + stop(paste("Error! Invalid data for `item_private`. Must be a string:", `item_private`)) + } self$`item_private` <- `item_private` } if (!is.null(`item_super`)) { - stopifnot(is.character(`item_super`), length(`item_super`) == 1) + if (!(is.character(`item_super`) && length(`item_super`) == 1)) { + stop(paste("Error! Invalid data for `item_super`. Must be a string:", `item_super`)) + } self$`item_super` <- `item_super` } if (!is.null(`123_number`)) { - stopifnot(is.character(`123_number`), length(`123_number`) == 1) + if (!(is.character(`123_number`) && length(`123_number`) == 1)) { + stop(paste("Error! Invalid data for `123_number`. Must be a string:", `123_number`)) + } self$`123_number` <- `123_number` } if (!is.null(`array[test]`)) { - stopifnot(is.character(`array[test]`), length(`array[test]`) == 1) + if (!(is.character(`array[test]`) && length(`array[test]`) == 1)) { + stop(paste("Error! Invalid data for `array[test]`. Must be a string:", `array[test]`)) + } self$`array[test]` <- `array[test]` } if (!is.null(`empty_string`)) { - stopifnot(is.character(`empty_string`), length(`empty_string`) == 1) + if (!(is.character(`empty_string`) && length(`empty_string`) == 1)) { + stop(paste("Error! Invalid data for `empty_string`. Must be a string:", `empty_string`)) + } self$`empty_string` <- `empty_string` } }, diff --git a/samples/client/petstore/R-httr2/R/tag.R b/samples/client/petstore/R-httr2/R/tag.R index 8db551330141..51603e72ab3f 100644 --- a/samples/client/petstore/R-httr2/R/tag.R +++ b/samples/client/petstore/R-httr2/R/tag.R @@ -28,11 +28,15 @@ Tag <- R6::R6Class( #' @export initialize = function(`id` = NULL, `name` = NULL, ...) { if (!is.null(`id`)) { - stopifnot(is.numeric(`id`), length(`id`) == 1) + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } self$`id` <- `id` } if (!is.null(`name`)) { - stopifnot(is.character(`name`), length(`name`) == 1) + if (!(is.character(`name`) && length(`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", `name`)) + } self$`name` <- `name` } }, diff --git a/samples/client/petstore/R-httr2/R/user.R b/samples/client/petstore/R-httr2/R/user.R index c3db6eb00d76..78896afef3c4 100644 --- a/samples/client/petstore/R-httr2/R/user.R +++ b/samples/client/petstore/R-httr2/R/user.R @@ -46,35 +46,51 @@ User <- R6::R6Class( #' @export initialize = function(`id` = NULL, `username` = NULL, `firstName` = NULL, `lastName` = NULL, `email` = NULL, `password` = NULL, `phone` = NULL, `userStatus` = NULL, ...) { if (!is.null(`id`)) { - stopifnot(is.numeric(`id`), length(`id`) == 1) + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } self$`id` <- `id` } if (!is.null(`username`)) { - stopifnot(is.character(`username`), length(`username`) == 1) + if (!(is.character(`username`) && length(`username`) == 1)) { + stop(paste("Error! Invalid data for `username`. Must be a string:", `username`)) + } self$`username` <- `username` } if (!is.null(`firstName`)) { - stopifnot(is.character(`firstName`), length(`firstName`) == 1) + if (!(is.character(`firstName`) && length(`firstName`) == 1)) { + stop(paste("Error! Invalid data for `firstName`. Must be a string:", `firstName`)) + } self$`firstName` <- `firstName` } if (!is.null(`lastName`)) { - stopifnot(is.character(`lastName`), length(`lastName`) == 1) + if (!(is.character(`lastName`) && length(`lastName`) == 1)) { + stop(paste("Error! Invalid data for `lastName`. Must be a string:", `lastName`)) + } self$`lastName` <- `lastName` } if (!is.null(`email`)) { - stopifnot(is.character(`email`), length(`email`) == 1) + if (!(is.character(`email`) && length(`email`) == 1)) { + stop(paste("Error! Invalid data for `email`. Must be a string:", `email`)) + } self$`email` <- `email` } if (!is.null(`password`)) { - stopifnot(is.character(`password`), length(`password`) == 1) + if (!(is.character(`password`) && length(`password`) == 1)) { + stop(paste("Error! Invalid data for `password`. Must be a string:", `password`)) + } self$`password` <- `password` } if (!is.null(`phone`)) { - stopifnot(is.character(`phone`), length(`phone`) == 1) + if (!(is.character(`phone`) && length(`phone`) == 1)) { + stop(paste("Error! Invalid data for `phone`. Must be a string:", `phone`)) + } self$`phone` <- `phone` } if (!is.null(`userStatus`)) { - stopifnot(is.numeric(`userStatus`), length(`userStatus`) == 1) + if (!(is.numeric(`userStatus`) && length(`userStatus`) == 1)) { + stop(paste("Error! Invalid data for `userStatus`. Must be an integer:", `userStatus`)) + } self$`userStatus` <- `userStatus` } }, diff --git a/samples/client/petstore/R-httr2/R/whale.R b/samples/client/petstore/R-httr2/R/whale.R index 51a3f0b69f22..084df84385a1 100644 --- a/samples/client/petstore/R-httr2/R/whale.R +++ b/samples/client/petstore/R-httr2/R/whale.R @@ -31,15 +31,21 @@ Whale <- R6::R6Class( #' @export initialize = function(`className`, `hasBaleen` = NULL, `hasTeeth` = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!is.null(`hasBaleen`)) { - stopifnot(is.logical(`hasBaleen`), length(`hasBaleen`) == 1) + if (!(is.logical(`hasBaleen`) && length(`hasBaleen`) == 1)) { + stop(paste("Error! Invalid data for `hasBaleen`. Must be a boolean:", `hasBaleen`)) + } self$`hasBaleen` <- `hasBaleen` } if (!is.null(`hasTeeth`)) { - stopifnot(is.logical(`hasTeeth`), length(`hasTeeth`) == 1) + if (!(is.logical(`hasTeeth`) && length(`hasTeeth`) == 1)) { + stop(paste("Error! Invalid data for `hasTeeth`. Must be a boolean:", `hasTeeth`)) + } self$`hasTeeth` <- `hasTeeth` } }, @@ -150,7 +156,9 @@ Whale <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Whale: the required field `className` is missing.")) } diff --git a/samples/client/petstore/R-httr2/R/zebra.R b/samples/client/petstore/R-httr2/R/zebra.R index 7feafc3745ca..0a1aa587e113 100644 --- a/samples/client/petstore/R-httr2/R/zebra.R +++ b/samples/client/petstore/R-httr2/R/zebra.R @@ -28,14 +28,18 @@ Zebra <- R6::R6Class( #' @export initialize = function(`className`, `type` = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!is.null(`type`)) { if (!(`type` %in% c("plains", "mountain", "grevys"))) { stop(paste("Error! \"", `type`, "\" cannot be assigned to `type`. Must be \"plains\", \"mountain\", \"grevys\".", sep = "")) } - stopifnot(is.character(`type`), length(`type`) == 1) + if (!(is.character(`type`) && length(`type`) == 1)) { + stop(paste("Error! Invalid data for `type`. Must be a string:", `type`)) + } self$`type` <- `type` } }, @@ -136,7 +140,9 @@ Zebra <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Zebra: the required field `className` is missing.")) } 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 e485c15e4ca7..220d89ee5036 100644 --- a/samples/client/petstore/R/R/allof_tag_api_response.R +++ b/samples/client/petstore/R/R/allof_tag_api_response.R @@ -42,23 +42,33 @@ AllofTagApiResponse <- R6::R6Class( #' @export initialize = function(`id` = NULL, `name` = NULL, `code` = NULL, `type` = NULL, `message` = NULL, additional_properties = NULL, ...) { if (!is.null(`id`)) { - stopifnot(is.numeric(`id`), length(`id`) == 1) + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } self$`id` <- `id` } if (!is.null(`name`)) { - stopifnot(is.character(`name`), length(`name`) == 1) + if (!(is.character(`name`) && length(`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", `name`)) + } self$`name` <- `name` } if (!is.null(`code`)) { - stopifnot(is.numeric(`code`), length(`code`) == 1) + if (!(is.numeric(`code`) && length(`code`) == 1)) { + stop(paste("Error! Invalid data for `code`. Must be an integer:", `code`)) + } self$`code` <- `code` } if (!is.null(`type`)) { - stopifnot(is.character(`type`), length(`type`) == 1) + if (!(is.character(`type`) && length(`type`) == 1)) { + stop(paste("Error! Invalid data for `type`. Must be a string:", `type`)) + } self$`type` <- `type` } if (!is.null(`message`)) { - stopifnot(is.character(`message`), length(`message`) == 1) + if (!(is.character(`message`) && length(`message`) == 1)) { + stop(paste("Error! Invalid data for `message`. Must be a string:", `message`)) + } self$`message` <- `message` } if (!is.null(additional_properties)) { diff --git a/samples/client/petstore/R/R/animal.R b/samples/client/petstore/R/R/animal.R index 632b160087dd..b506bced42f9 100644 --- a/samples/client/petstore/R/R/animal.R +++ b/samples/client/petstore/R/R/animal.R @@ -35,11 +35,15 @@ Animal <- R6::R6Class( #' @export initialize = function(`className`, `color` = "red", additional_properties = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!is.null(`color`)) { - stopifnot(is.character(`color`), length(`color`) == 1) + if (!(is.character(`color`) && length(`color`) == 1)) { + stop(paste("Error! Invalid data for `color`. Must be a string:", `color`)) + } self$`color` <- `color` } if (!is.null(additional_properties)) { @@ -162,7 +166,9 @@ Animal <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Animal: the required field `className` is missing.")) } diff --git a/samples/client/petstore/R/R/basque_pig.R b/samples/client/petstore/R/R/basque_pig.R index 2335bbe37c0b..ac83042c8cfd 100644 --- a/samples/client/petstore/R/R/basque_pig.R +++ b/samples/client/petstore/R/R/basque_pig.R @@ -33,11 +33,15 @@ BasquePig <- R6::R6Class( #' @export initialize = function(`className`, `color`, additional_properties = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!missing(`color`)) { - stopifnot(is.character(`color`), length(`color`) == 1) + if (!(is.character(`color`) && length(`color`) == 1)) { + stop(paste("Error! Invalid data for `color`. Must be a string:", `color`)) + } self$`color` <- `color` } if (!is.null(additional_properties)) { @@ -160,13 +164,17 @@ BasquePig <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for BasquePig: the required field `className` is missing.")) } # check the required field `color` if (!is.null(input_json$`color`)) { - stopifnot(is.character(input_json$`color`), length(input_json$`color`) == 1) + if (!(is.character(input_json$`color`) && length(input_json$`color`) == 1)) { + stop(paste("Error! Invalid data for `color`. Must be a string:", input_json$`color`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for BasquePig: the required field `color` is missing.")) } diff --git a/samples/client/petstore/R/R/cat.R b/samples/client/petstore/R/R/cat.R index 60d417950b1b..f74e2d887ddd 100644 --- a/samples/client/petstore/R/R/cat.R +++ b/samples/client/petstore/R/R/cat.R @@ -37,15 +37,21 @@ Cat <- R6::R6Class( #' @export initialize = function(`className`, `color` = "red", `declawed` = NULL, additional_properties = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!is.null(`color`)) { - stopifnot(is.character(`color`), length(`color`) == 1) + if (!(is.character(`color`) && length(`color`) == 1)) { + stop(paste("Error! Invalid data for `color`. Must be a string:", `color`)) + } self$`color` <- `color` } if (!is.null(`declawed`)) { - stopifnot(is.logical(`declawed`), length(`declawed`) == 1) + if (!(is.logical(`declawed`) && length(`declawed`) == 1)) { + stop(paste("Error! Invalid data for `declawed`. Must be a boolean:", `declawed`)) + } self$`declawed` <- `declawed` } if (!is.null(additional_properties)) { @@ -184,7 +190,9 @@ Cat <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Cat: the required field `className` is missing.")) } diff --git a/samples/client/petstore/R/R/cat_all_of.R b/samples/client/petstore/R/R/cat_all_of.R index c3969fc0550e..197e1a46e3a5 100644 --- a/samples/client/petstore/R/R/cat_all_of.R +++ b/samples/client/petstore/R/R/cat_all_of.R @@ -30,7 +30,9 @@ CatAllOf <- R6::R6Class( #' @export initialize = function(`declawed` = NULL, additional_properties = NULL, ...) { if (!is.null(`declawed`)) { - stopifnot(is.logical(`declawed`), length(`declawed`) == 1) + if (!(is.logical(`declawed`) && length(`declawed`) == 1)) { + stop(paste("Error! Invalid data for `declawed`. Must be a boolean:", `declawed`)) + } self$`declawed` <- `declawed` } if (!is.null(additional_properties)) { diff --git a/samples/client/petstore/R/R/category.R b/samples/client/petstore/R/R/category.R index 2de263a56822..2646d01bd723 100644 --- a/samples/client/petstore/R/R/category.R +++ b/samples/client/petstore/R/R/category.R @@ -33,11 +33,15 @@ Category <- R6::R6Class( #' @export initialize = function(`id` = NULL, `name` = NULL, additional_properties = NULL, ...) { if (!is.null(`id`)) { - stopifnot(is.numeric(`id`), length(`id`) == 1) + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } self$`id` <- `id` } if (!is.null(`name`)) { - stopifnot(is.character(`name`), length(`name`) == 1) + if (!(is.character(`name`) && length(`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", `name`)) + } self$`name` <- `name` } if (!is.null(additional_properties)) { diff --git a/samples/client/petstore/R/R/danish_pig.R b/samples/client/petstore/R/R/danish_pig.R index 737bfad4b971..06cf5096a889 100644 --- a/samples/client/petstore/R/R/danish_pig.R +++ b/samples/client/petstore/R/R/danish_pig.R @@ -33,11 +33,15 @@ DanishPig <- R6::R6Class( #' @export initialize = function(`className`, `size`, additional_properties = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!missing(`size`)) { - stopifnot(is.numeric(`size`), length(`size`) == 1) + if (!(is.numeric(`size`) && length(`size`) == 1)) { + stop(paste("Error! Invalid data for `size`. Must be an integer:", `size`)) + } self$`size` <- `size` } if (!is.null(additional_properties)) { @@ -160,13 +164,17 @@ DanishPig <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for DanishPig: the required field `className` is missing.")) } # check the required field `size` if (!is.null(input_json$`size`)) { - stopifnot(is.numeric(input_json$`size`), length(input_json$`size`) == 1) + if (!(is.numeric(input_json$`size`) && length(input_json$`size`) == 1)) { + stop(paste("Error! Invalid data for `size`. Must be an integer:", input_json$`size`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for DanishPig: the required field `size` is missing.")) } diff --git a/samples/client/petstore/R/R/date.R b/samples/client/petstore/R/R/date.R index a26b7977d4ff..79945bc8cfcf 100644 --- a/samples/client/petstore/R/R/date.R +++ b/samples/client/petstore/R/R/date.R @@ -36,19 +36,25 @@ Date <- R6::R6Class( #' @export initialize = function(`className`, `url_property`, `percent_description` = NULL, additional_properties = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!missing(`url_property`)) { - stopifnot(is.character(`url_property`), length(`url_property`) == 1) + if (!(is.character(`url_property`) && length(`url_property`) == 1)) { + stop(paste("Error! Invalid data for `url_property`. Must be a string:", `url_property`)) + } # to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r if (!stringr::str_detect(`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) { - stop(paste("Error! Invalid URL:", `url_property`)) + stop(paste("Error! Invalid data for `url_property`. Must be a URL:", `url_property`)) } self$`url_property` <- `url_property` } if (!is.null(`percent_description`)) { - stopifnot(is.character(`percent_description`), length(`percent_description`) == 1) + if (!(is.character(`percent_description`) && length(`percent_description`) == 1)) { + stop(paste("Error! Invalid data for `percent_description`. Must be a string:", `percent_description`)) + } self$`percent_description` <- `percent_description` } if (!is.null(additional_properties)) { @@ -103,7 +109,7 @@ Date <- R6::R6Class( if (!is.null(this_object$`url_property`)) { # to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r if (!stringr::str_detect(this_object$`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) { - stop(paste("Error! Invalid URL:", this_object$`url_property`)) + stop(paste("Error! Invalid data for `url_property`. Must be a URL:", this_object$`url_property`)) } self$`url_property` <- this_object$`url_property` } @@ -172,7 +178,7 @@ Date <- R6::R6Class( self$`percent_description` <- this_object$`percent_description` # to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r if (!stringr::str_detect(this_object$`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) { - stop(paste("Error! Invalid URL:", this_object$`url_property`)) + stop(paste("Error! Invalid data for `url_property`. Must be a URL:", this_object$`url_property`)) } self$`url_property` <- this_object$`url_property` # process additional properties/fields in the payload @@ -195,16 +201,20 @@ Date <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Date: the required field `className` is missing.")) } # check the required field `url_property` if (!is.null(input_json$`url_property`)) { - stopifnot(is.character(input_json$`url_property`), length(input_json$`url_property`) == 1) + if (!(is.character(input_json$`url_property`) && length(input_json$`url_property`) == 1)) { + stop(paste("Error! Invalid data for `url_property`. Must be a string:", input_json$`url_property`)) + } # to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r if (!stringr::str_detect(input_json$`url_property`, "(https?|ftp)://[^ /$.?#].[^\\s]*")) { - stop(paste("Error! Invalid URL:", input_json$`url_property`)) + stop(paste("Error! Invalid data for `url_property`. Must be a URL:", input_json$`url_property`)) } } else { stop(paste("The JSON input `", input, "` is invalid for Date: the required field `url_property` is missing.")) diff --git a/samples/client/petstore/R/R/dog.R b/samples/client/petstore/R/R/dog.R index 67fb8a315e23..a814c57d5869 100644 --- a/samples/client/petstore/R/R/dog.R +++ b/samples/client/petstore/R/R/dog.R @@ -37,15 +37,21 @@ Dog <- R6::R6Class( #' @export initialize = function(`className`, `color` = "red", `breed` = NULL, additional_properties = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!is.null(`color`)) { - stopifnot(is.character(`color`), length(`color`) == 1) + if (!(is.character(`color`) && length(`color`) == 1)) { + stop(paste("Error! Invalid data for `color`. Must be a string:", `color`)) + } self$`color` <- `color` } if (!is.null(`breed`)) { - stopifnot(is.character(`breed`), length(`breed`) == 1) + if (!(is.character(`breed`) && length(`breed`) == 1)) { + stop(paste("Error! Invalid data for `breed`. Must be a string:", `breed`)) + } self$`breed` <- `breed` } if (!is.null(additional_properties)) { @@ -184,7 +190,9 @@ Dog <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Dog: the required field `className` is missing.")) } diff --git a/samples/client/petstore/R/R/dog_all_of.R b/samples/client/petstore/R/R/dog_all_of.R index ea44d583d744..17608478eedf 100644 --- a/samples/client/petstore/R/R/dog_all_of.R +++ b/samples/client/petstore/R/R/dog_all_of.R @@ -30,7 +30,9 @@ DogAllOf <- R6::R6Class( #' @export initialize = function(`breed` = NULL, additional_properties = NULL, ...) { if (!is.null(`breed`)) { - stopifnot(is.character(`breed`), length(`breed`) == 1) + if (!(is.character(`breed`) && length(`breed`) == 1)) { + stop(paste("Error! Invalid data for `breed`. Must be a string:", `breed`)) + } self$`breed` <- `breed` } if (!is.null(additional_properties)) { diff --git a/samples/client/petstore/R/R/format_test.R b/samples/client/petstore/R/R/format_test.R index 872553d583c4..4bd74e3a7275 100644 --- a/samples/client/petstore/R/R/format_test.R +++ b/samples/client/petstore/R/R/format_test.R @@ -78,37 +78,51 @@ FormatTest <- R6::R6Class( self$`byte` <- `byte` } if (!missing(`date`)) { - if (!is.character(`date`)) { - stop(paste("Error! Invalid Date. Must be a string:", `date`)) + if (!(is.character(`date`) && length(`date`) == 1)) { + stop(paste("Error! Invalid data for `date`. Must be a string:", `date`)) } self$`date` <- `date` } if (!missing(`password`)) { - stopifnot(is.character(`password`), length(`password`) == 1) + if (!(is.character(`password`) && length(`password`) == 1)) { + stop(paste("Error! Invalid data for `password`. Must be a string:", `password`)) + } self$`password` <- `password` } if (!is.null(`integer`)) { - stopifnot(is.numeric(`integer`), length(`integer`) == 1) + if (!(is.numeric(`integer`) && length(`integer`) == 1)) { + stop(paste("Error! Invalid data for `integer`. Must be an integer:", `integer`)) + } self$`integer` <- `integer` } if (!is.null(`int32`)) { - stopifnot(is.numeric(`int32`), length(`int32`) == 1) + if (!(is.numeric(`int32`) && length(`int32`) == 1)) { + stop(paste("Error! Invalid data for `int32`. Must be an integer:", `int32`)) + } self$`int32` <- `int32` } if (!is.null(`int64`)) { - stopifnot(is.numeric(`int64`), length(`int64`) == 1) + if (!(is.numeric(`int64`) && length(`int64`) == 1)) { + stop(paste("Error! Invalid data for `int64`. Must be an integer:", `int64`)) + } self$`int64` <- `int64` } if (!is.null(`float`)) { - stopifnot(is.numeric(`float`), length(`float`) == 1) + if (!(is.numeric(`float`) && length(`float`) == 1)) { + stop(paste("Error! Invalid data for `float`. Must be a number:", `float`)) + } self$`float` <- `float` } if (!is.null(`double`)) { - stopifnot(is.numeric(`double`), length(`double`) == 1) + if (!(is.numeric(`double`) && length(`double`) == 1)) { + stop(paste("Error! Invalid data for `double`. Must be a number:", `double`)) + } self$`double` <- `double` } if (!is.null(`string`)) { - stopifnot(is.character(`string`), length(`string`) == 1) + if (!(is.character(`string`) && length(`string`) == 1)) { + stop(paste("Error! Invalid data for `string`. Must be a string:", `string`)) + } self$`string` <- `string` } if (!is.null(`binary`)) { @@ -116,20 +130,26 @@ FormatTest <- R6::R6Class( } if (!is.null(`dateTime`)) { if (!is.character(`dateTime`)) { - stop(paste("Error! Invalid DateTime. Must be a string:", `dateTime`)) + stop(paste("Error! Invalid data for `dateTime`. Must be a string:", `dateTime`)) } self$`dateTime` <- `dateTime` } if (!is.null(`uuid`)) { - stopifnot(is.character(`uuid`), length(`uuid`) == 1) + if (!(is.character(`uuid`) && length(`uuid`) == 1)) { + stop(paste("Error! Invalid data for `uuid`. Must be a string:", `uuid`)) + } self$`uuid` <- `uuid` } if (!is.null(`pattern_with_digits`)) { - stopifnot(is.character(`pattern_with_digits`), length(`pattern_with_digits`) == 1) + if (!(is.character(`pattern_with_digits`) && length(`pattern_with_digits`) == 1)) { + stop(paste("Error! Invalid data for `pattern_with_digits`. Must be a string:", `pattern_with_digits`)) + } self$`pattern_with_digits` <- `pattern_with_digits` } if (!is.null(`pattern_with_digits_and_delimiter`)) { - stopifnot(is.character(`pattern_with_digits_and_delimiter`), length(`pattern_with_digits_and_delimiter`) == 1) + if (!(is.character(`pattern_with_digits_and_delimiter`) && length(`pattern_with_digits_and_delimiter`) == 1)) { + stop(paste("Error! Invalid data for `pattern_with_digits_and_delimiter`. Must be a string:", `pattern_with_digits_and_delimiter`)) + } self$`pattern_with_digits_and_delimiter` <- `pattern_with_digits_and_delimiter` } if (!is.null(additional_properties)) { @@ -470,13 +490,17 @@ FormatTest <- R6::R6Class( } # check the required field `date` if (!is.null(input_json$`date`)) { - stopifnot(is.character(input_json$`date`), length(input_json$`date`) == 1) + if (!(is.character(input_json$`date`) && length(input_json$`date`) == 1)) { + stop(paste("Error! Invalid data for `date`. Must be a string:", input_json$`date`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `date` is missing.")) } # check the required field `password` if (!is.null(input_json$`password`)) { - stopifnot(is.character(input_json$`password`), length(input_json$`password`) == 1) + if (!(is.character(input_json$`password`) && length(input_json$`password`) == 1)) { + stop(paste("Error! Invalid data for `password`. Must be a string:", input_json$`password`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `password` is missing.")) } diff --git a/samples/client/petstore/R/R/model_api_response.R b/samples/client/petstore/R/R/model_api_response.R index 03059bb52259..b0e4bbba7e97 100644 --- a/samples/client/petstore/R/R/model_api_response.R +++ b/samples/client/petstore/R/R/model_api_response.R @@ -36,15 +36,21 @@ ModelApiResponse <- R6::R6Class( #' @export initialize = function(`code` = NULL, `type` = NULL, `message` = NULL, additional_properties = NULL, ...) { if (!is.null(`code`)) { - stopifnot(is.numeric(`code`), length(`code`) == 1) + if (!(is.numeric(`code`) && length(`code`) == 1)) { + stop(paste("Error! Invalid data for `code`. Must be an integer:", `code`)) + } self$`code` <- `code` } if (!is.null(`type`)) { - stopifnot(is.character(`type`), length(`type`) == 1) + if (!(is.character(`type`) && length(`type`) == 1)) { + stop(paste("Error! Invalid data for `type`. Must be a string:", `type`)) + } self$`type` <- `type` } if (!is.null(`message`)) { - stopifnot(is.character(`message`), length(`message`) == 1) + if (!(is.character(`message`) && length(`message`) == 1)) { + stop(paste("Error! Invalid data for `message`. Must be a string:", `message`)) + } self$`message` <- `message` } if (!is.null(additional_properties)) { diff --git a/samples/client/petstore/R/R/nested_one_of.R b/samples/client/petstore/R/R/nested_one_of.R index 68b0db6b3712..73f4e938cbd3 100644 --- a/samples/client/petstore/R/R/nested_one_of.R +++ b/samples/client/petstore/R/R/nested_one_of.R @@ -33,7 +33,9 @@ NestedOneOf <- R6::R6Class( #' @export initialize = function(`size` = NULL, `nested_pig` = NULL, additional_properties = NULL, ...) { if (!is.null(`size`)) { - stopifnot(is.numeric(`size`), length(`size`) == 1) + if (!(is.numeric(`size`) && length(`size`) == 1)) { + stop(paste("Error! Invalid data for `size`. Must be an integer:", `size`)) + } self$`size` <- `size` } if (!is.null(`nested_pig`)) { diff --git a/samples/client/petstore/R/R/order.R b/samples/client/petstore/R/R/order.R index 74f319e45dbc..266468962695 100644 --- a/samples/client/petstore/R/R/order.R +++ b/samples/client/petstore/R/R/order.R @@ -45,20 +45,26 @@ Order <- R6::R6Class( #' @export initialize = function(`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) + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } self$`id` <- `id` } if (!is.null(`petId`)) { - stopifnot(is.numeric(`petId`), length(`petId`) == 1) + if (!(is.numeric(`petId`) && length(`petId`) == 1)) { + stop(paste("Error! Invalid data for `petId`. Must be an integer:", `petId`)) + } self$`petId` <- `petId` } if (!is.null(`quantity`)) { - stopifnot(is.numeric(`quantity`), length(`quantity`) == 1) + if (!(is.numeric(`quantity`) && length(`quantity`) == 1)) { + stop(paste("Error! Invalid data for `quantity`. Must be an integer:", `quantity`)) + } self$`quantity` <- `quantity` } if (!is.null(`shipDate`)) { if (!is.character(`shipDate`)) { - stop(paste("Error! Invalid DateTime. Must be a string:", `shipDate`)) + stop(paste("Error! Invalid data for `shipDate`. Must be a string:", `shipDate`)) } self$`shipDate` <- `shipDate` } @@ -66,11 +72,15 @@ Order <- R6::R6Class( if (!(`status` %in% c("placed", "approved", "delivered"))) { stop(paste("Error! \"", `status`, "\" cannot be assigned to `status`. Must be \"placed\", \"approved\", \"delivered\".", sep = "")) } - stopifnot(is.character(`status`), length(`status`) == 1) + if (!(is.character(`status`) && length(`status`) == 1)) { + stop(paste("Error! Invalid data for `status`. Must be a string:", `status`)) + } self$`status` <- `status` } if (!is.null(`complete`)) { - stopifnot(is.logical(`complete`), length(`complete`) == 1) + if (!(is.logical(`complete`) && length(`complete`) == 1)) { + stop(paste("Error! Invalid data for `complete`. Must be a boolean:", `complete`)) + } self$`complete` <- `complete` } if (!is.null(additional_properties)) { diff --git a/samples/client/petstore/R/R/pet.R b/samples/client/petstore/R/R/pet.R index 63318448c0c4..8be5a0583359 100644 --- a/samples/client/petstore/R/R/pet.R +++ b/samples/client/petstore/R/R/pet.R @@ -45,7 +45,9 @@ Pet <- R6::R6Class( #' @export initialize = function(`name`, `photoUrls`, `id` = NULL, `category` = NULL, `tags` = NULL, `status` = NULL, additional_properties = NULL, ...) { if (!missing(`name`)) { - stopifnot(is.character(`name`), length(`name`) == 1) + if (!(is.character(`name`) && length(`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", `name`)) + } self$`name` <- `name` } if (!missing(`photoUrls`)) { @@ -54,7 +56,9 @@ Pet <- R6::R6Class( self$`photoUrls` <- `photoUrls` } if (!is.null(`id`)) { - stopifnot(is.numeric(`id`), length(`id`) == 1) + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } self$`id` <- `id` } if (!is.null(`category`)) { @@ -70,7 +74,9 @@ Pet <- R6::R6Class( if (!(`status` %in% c("available", "pending", "sold"))) { stop(paste("Error! \"", `status`, "\" cannot be assigned to `status`. Must be \"available\", \"pending\", \"sold\".", sep = "")) } - stopifnot(is.character(`status`), length(`status`) == 1) + if (!(is.character(`status`) && length(`status`) == 1)) { + stop(paste("Error! Invalid data for `status`. Must be a string:", `status`)) + } self$`status` <- `status` } if (!is.null(additional_properties)) { @@ -265,7 +271,9 @@ Pet <- R6::R6Class( input_json <- jsonlite::fromJSON(input) # check the required field `name` if (!is.null(input_json$`name`)) { - stopifnot(is.character(input_json$`name`), length(input_json$`name`) == 1) + if (!(is.character(input_json$`name`) && length(input_json$`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", input_json$`name`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Pet: the required field `name` is missing.")) } diff --git a/samples/client/petstore/R/R/special.R b/samples/client/petstore/R/R/special.R index 33f06cc6a672..39664bea75ce 100644 --- a/samples/client/petstore/R/R/special.R +++ b/samples/client/petstore/R/R/special.R @@ -56,27 +56,39 @@ Special <- R6::R6Class( self$`set_test` <- `set_test` } if (!is.null(`item_self`)) { - stopifnot(is.numeric(`item_self`), length(`item_self`) == 1) + if (!(is.numeric(`item_self`) && length(`item_self`) == 1)) { + stop(paste("Error! Invalid data for `item_self`. Must be an integer:", `item_self`)) + } self$`item_self` <- `item_self` } if (!is.null(`item_private`)) { - stopifnot(is.character(`item_private`), length(`item_private`) == 1) + if (!(is.character(`item_private`) && length(`item_private`) == 1)) { + stop(paste("Error! Invalid data for `item_private`. Must be a string:", `item_private`)) + } self$`item_private` <- `item_private` } if (!is.null(`item_super`)) { - stopifnot(is.character(`item_super`), length(`item_super`) == 1) + if (!(is.character(`item_super`) && length(`item_super`) == 1)) { + stop(paste("Error! Invalid data for `item_super`. Must be a string:", `item_super`)) + } self$`item_super` <- `item_super` } if (!is.null(`123_number`)) { - stopifnot(is.character(`123_number`), length(`123_number`) == 1) + if (!(is.character(`123_number`) && length(`123_number`) == 1)) { + stop(paste("Error! Invalid data for `123_number`. Must be a string:", `123_number`)) + } self$`123_number` <- `123_number` } if (!is.null(`array[test]`)) { - stopifnot(is.character(`array[test]`), length(`array[test]`) == 1) + if (!(is.character(`array[test]`) && length(`array[test]`) == 1)) { + stop(paste("Error! Invalid data for `array[test]`. Must be a string:", `array[test]`)) + } self$`array[test]` <- `array[test]` } if (!is.null(`empty_string`)) { - stopifnot(is.character(`empty_string`), length(`empty_string`) == 1) + if (!(is.character(`empty_string`) && length(`empty_string`) == 1)) { + stop(paste("Error! Invalid data for `empty_string`. Must be a string:", `empty_string`)) + } self$`empty_string` <- `empty_string` } if (!is.null(additional_properties)) { diff --git a/samples/client/petstore/R/R/tag.R b/samples/client/petstore/R/R/tag.R index bd4aac10e2f6..be068d1474c5 100644 --- a/samples/client/petstore/R/R/tag.R +++ b/samples/client/petstore/R/R/tag.R @@ -33,11 +33,15 @@ Tag <- R6::R6Class( #' @export initialize = function(`id` = NULL, `name` = NULL, additional_properties = NULL, ...) { if (!is.null(`id`)) { - stopifnot(is.numeric(`id`), length(`id`) == 1) + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } self$`id` <- `id` } if (!is.null(`name`)) { - stopifnot(is.character(`name`), length(`name`) == 1) + if (!(is.character(`name`) && length(`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", `name`)) + } self$`name` <- `name` } if (!is.null(additional_properties)) { diff --git a/samples/client/petstore/R/R/user.R b/samples/client/petstore/R/R/user.R index 153aacb3ea52..43b51ffa41c2 100644 --- a/samples/client/petstore/R/R/user.R +++ b/samples/client/petstore/R/R/user.R @@ -51,35 +51,51 @@ User <- R6::R6Class( #' @export initialize = function(`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) + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } self$`id` <- `id` } if (!is.null(`username`)) { - stopifnot(is.character(`username`), length(`username`) == 1) + if (!(is.character(`username`) && length(`username`) == 1)) { + stop(paste("Error! Invalid data for `username`. Must be a string:", `username`)) + } self$`username` <- `username` } if (!is.null(`firstName`)) { - stopifnot(is.character(`firstName`), length(`firstName`) == 1) + if (!(is.character(`firstName`) && length(`firstName`) == 1)) { + stop(paste("Error! Invalid data for `firstName`. Must be a string:", `firstName`)) + } self$`firstName` <- `firstName` } if (!is.null(`lastName`)) { - stopifnot(is.character(`lastName`), length(`lastName`) == 1) + if (!(is.character(`lastName`) && length(`lastName`) == 1)) { + stop(paste("Error! Invalid data for `lastName`. Must be a string:", `lastName`)) + } self$`lastName` <- `lastName` } if (!is.null(`email`)) { - stopifnot(is.character(`email`), length(`email`) == 1) + if (!(is.character(`email`) && length(`email`) == 1)) { + stop(paste("Error! Invalid data for `email`. Must be a string:", `email`)) + } self$`email` <- `email` } if (!is.null(`password`)) { - stopifnot(is.character(`password`), length(`password`) == 1) + if (!(is.character(`password`) && length(`password`) == 1)) { + stop(paste("Error! Invalid data for `password`. Must be a string:", `password`)) + } self$`password` <- `password` } if (!is.null(`phone`)) { - stopifnot(is.character(`phone`), length(`phone`) == 1) + if (!(is.character(`phone`) && length(`phone`) == 1)) { + stop(paste("Error! Invalid data for `phone`. Must be a string:", `phone`)) + } self$`phone` <- `phone` } if (!is.null(`userStatus`)) { - stopifnot(is.numeric(`userStatus`), length(`userStatus`) == 1) + if (!(is.numeric(`userStatus`) && length(`userStatus`) == 1)) { + stop(paste("Error! Invalid data for `userStatus`. Must be an integer:", `userStatus`)) + } self$`userStatus` <- `userStatus` } if (!is.null(additional_properties)) { diff --git a/samples/client/petstore/R/R/whale.R b/samples/client/petstore/R/R/whale.R index 936b3a2573ed..dc70b1dd33e5 100644 --- a/samples/client/petstore/R/R/whale.R +++ b/samples/client/petstore/R/R/whale.R @@ -36,15 +36,21 @@ Whale <- R6::R6Class( #' @export initialize = function(`className`, `hasBaleen` = NULL, `hasTeeth` = NULL, additional_properties = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!is.null(`hasBaleen`)) { - stopifnot(is.logical(`hasBaleen`), length(`hasBaleen`) == 1) + if (!(is.logical(`hasBaleen`) && length(`hasBaleen`) == 1)) { + stop(paste("Error! Invalid data for `hasBaleen`. Must be a boolean:", `hasBaleen`)) + } self$`hasBaleen` <- `hasBaleen` } if (!is.null(`hasTeeth`)) { - stopifnot(is.logical(`hasTeeth`), length(`hasTeeth`) == 1) + if (!(is.logical(`hasTeeth`) && length(`hasTeeth`) == 1)) { + stop(paste("Error! Invalid data for `hasTeeth`. Must be a boolean:", `hasTeeth`)) + } self$`hasTeeth` <- `hasTeeth` } if (!is.null(additional_properties)) { @@ -183,7 +189,9 @@ Whale <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Whale: the required field `className` is missing.")) } diff --git a/samples/client/petstore/R/R/zebra.R b/samples/client/petstore/R/R/zebra.R index 5c090e84cbb9..c8d06d23d6a5 100644 --- a/samples/client/petstore/R/R/zebra.R +++ b/samples/client/petstore/R/R/zebra.R @@ -33,14 +33,18 @@ Zebra <- R6::R6Class( #' @export initialize = function(`className`, `type` = NULL, additional_properties = NULL, ...) { if (!missing(`className`)) { - stopifnot(is.character(`className`), length(`className`) == 1) + if (!(is.character(`className`) && length(`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", `className`)) + } self$`className` <- `className` } if (!is.null(`type`)) { if (!(`type` %in% c("plains", "mountain", "grevys"))) { stop(paste("Error! \"", `type`, "\" cannot be assigned to `type`. Must be \"plains\", \"mountain\", \"grevys\".", sep = "")) } - stopifnot(is.character(`type`), length(`type`) == 1) + if (!(is.character(`type`) && length(`type`) == 1)) { + stop(paste("Error! Invalid data for `type`. Must be a string:", `type`)) + } self$`type` <- `type` } if (!is.null(additional_properties)) { @@ -169,7 +173,9 @@ Zebra <- R6::R6Class( 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) + if (!(is.character(input_json$`className`) && length(input_json$`className`) == 1)) { + stop(paste("Error! Invalid data for `className`. Must be a string:", input_json$`className`)) + } } else { stop(paste("The JSON input `", input, "` is invalid for Zebra: the required field `className` is missing.")) }