Better handling of date, datetime in R client (#13706)

* better handling of date, datetime in R client

* use string instead of as.Date
This commit is contained in:
William Cheng 2022-10-17 00:41:37 +08:00 committed by GitHub
parent e02ebd822a
commit fae9a798a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 2554 additions and 10 deletions

View File

@ -829,15 +829,19 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
public String toDefaultValue(Schema p) {
if (ModelUtils.isBooleanSchema(p)) {
if (p.getDefault() != null) {
if (Boolean.valueOf(p.getDefault().toString()) == false)
if (!Boolean.valueOf(p.getDefault().toString()))
return "FALSE";
else
return "TRUE";
}
} else if (ModelUtils.isDateSchema(p)) {
// TODO
if (p.getDefault() != null) {
return "\"" + ((String.valueOf(p.getDefault()))).replaceAll("\"", "\\\"") + "\"";
}
} else if (ModelUtils.isDateTimeSchema(p)) {
// TODO
if (p.getDefault() != null) {
return "\"" + ((String.valueOf(p.getDefault()))).replaceAll("\"", "\\\"") + "\"";
}
} else if (ModelUtils.isNumberSchema(p)) {
if (p.getDefault() != null) {
return p.getDefault().toString();

View File

@ -78,10 +78,14 @@
stopifnot(is.logical(`{{name}}`), length(`{{name}}`) == 1)
{{/isBoolean}}
{{#isDate}}
stopifnot(is.character(`{{name}}`), length(`{{name}}`) == 1)
if (!is.character(`{{name}}`)) {
stop(paste("Error! Invalid Date. Must be a string:", `{{name}}`))
}
{{/isDate}}
{{#isDateTime}}
stopifnot(is.character(`{{name}}`), length(`{{name}}`) == 1)
if (!is.character(`{{name}}`)) {
stop(paste("Error! Invalid DateTime. Must be a string:", `{{name}}`))
}
{{/isDateTime}}
{{#isUri}}
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r
@ -134,10 +138,14 @@
stopifnot(is.logical(`{{name}}`), length(`{{name}}`) == 1)
{{/isBoolean}}
{{#isDate}}
stopifnot(is.character(`{{name}}`), length(`{{name}}`) == 1)
if (!is.character(`{{name}}`)) {
stop(paste("Error! Invalid Date. Must be a string:", `{{name}}`))
}
{{/isDate}}
{{#isDateTime}}
stopifnot(is.character(`{{name}}`), length(`{{name}}`) == 1)
if (!is.character(`{{name}}`)) {
stop(paste("Error! Invalid DateTime. Must be a string:", `{{name}}`))
}
{{/isDateTime}}
{{#isUri}}
# to validate URL. ref: https://stackoverflow.com/questions/73952024/url-validation-in-r

View File

@ -1121,3 +1121,71 @@ components:
required:
- className
- url_property
format_test:
type: object
required:
- number
- byte
- date
- password
properties:
integer:
type: integer
maximum: 100
minimum: 10
int32:
type: integer
format: int32
maximum: 200
minimum: 20
int64:
type: integer
format: int64
number:
maximum: 543.2
minimum: 32.1
type: number
float:
type: number
format: float
maximum: 987.6
minimum: 54.3
double:
type: number
format: double
maximum: 123.4
minimum: 67.8
string:
type: string
pattern: '/[a-z]/i'
byte:
type: string
format: byte
binary:
type: string
format: binary
date:
type: string
format: date
default: 2019-07-19
dateTime:
type: string
format: date-time
default: 2015-10-28T14:38:02Z
uuid:
type: string
format: uuid
example: 72f98069-206d-4f12-9f12-3d1e525a8e84
password:
type: string
format: password
maxLength: 64
minLength: 10
pattern_with_digits:
description: A string that is a 10 digit number. Can have leading zeros.
type: string
pattern: '^\d{10}$'
pattern_with_digits_and_delimiter:
description: A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
type: string
pattern: '/^image_\d{1,3}$/i'

View File

@ -21,6 +21,7 @@ R/date.R
R/dog.R
R/dog_all_of.R
R/fake_api.R
R/format_test.R
R/mammal.R
R/model_api_response.R
R/nested_one_of.R
@ -52,6 +53,7 @@ docs/Date.md
docs/Dog.md
docs/DogAllOf.md
docs/FakeApi.md
docs/FormatTest.md
docs/Mammal.md
docs/ModelApiResponse.md
docs/NestedOneOf.md

View File

@ -28,6 +28,7 @@ export(DanishPig)
export(Date)
export(Dog)
export(DogAllOf)
export(FormatTest)
export(Mammal)
export(ModelApiResponse)
export(NestedOneOf)

View File

@ -0,0 +1,687 @@
#' Create a new FormatTest
#'
#' @description
#' FormatTest Class
#'
#' @docType class
#' @title FormatTest
#' @description FormatTest Class
#' @format An \code{R6Class} generator object
#' @field integer integer [optional]
#' @field int32 integer [optional]
#' @field int64 integer [optional]
#' @field number numeric
#' @field float numeric [optional]
#' @field double numeric [optional]
#' @field string character [optional]
#' @field byte character
#' @field binary data.frame [optional]
#' @field date character
#' @field dateTime character [optional]
#' @field uuid character [optional]
#' @field password character
#' @field pattern_with_digits A string that is a 10 digit number. Can have leading zeros. character [optional]
#' @field pattern_with_digits_and_delimiter A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. character [optional]
#' @field _field_list a list of fields list(character)
#' @field additional_properties additional properties list(character) [optional]
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
FormatTest <- R6::R6Class(
"FormatTest",
public = list(
`integer` = NULL,
`int32` = NULL,
`int64` = NULL,
`number` = NULL,
`float` = NULL,
`double` = NULL,
`string` = NULL,
`byte` = NULL,
`binary` = NULL,
`date` = NULL,
`dateTime` = NULL,
`uuid` = NULL,
`password` = NULL,
`pattern_with_digits` = NULL,
`pattern_with_digits_and_delimiter` = NULL,
`_field_list` = c("integer", "int32", "int64", "number", "float", "double", "string", "byte", "binary", "date", "dateTime", "uuid", "password", "pattern_with_digits", "pattern_with_digits_and_delimiter"),
`additional_properties` = list(),
#' Initialize a new FormatTest class.
#'
#' @description
#' Initialize a new FormatTest class.
#'
#' @param number number
#' @param byte byte
#' @param date date
#' @param password password
#' @param integer integer
#' @param int32 int32
#' @param int64 int64
#' @param float float
#' @param double double
#' @param string string
#' @param binary binary
#' @param dateTime dateTime. Default to "2015-10-28T14:38:02Z".
#' @param uuid uuid
#' @param pattern_with_digits A string that is a 10 digit number. Can have leading zeros.
#' @param pattern_with_digits_and_delimiter A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
#' @param additional_properties additonal properties (optional)
#' @param ... Other optional arguments.
#' @export
initialize = function(`number`, `byte`, `date`, `password`, `integer` = NULL, `int32` = NULL, `int64` = NULL, `float` = NULL, `double` = NULL, `string` = NULL, `binary` = NULL, `dateTime` = "2015-10-28T14:38:02Z", `uuid` = NULL, `pattern_with_digits` = NULL, `pattern_with_digits_and_delimiter` = NULL, additional_properties = NULL, ...) {
if (!missing(`number`)) {
self$`number` <- `number`
}
if (!missing(`byte`)) {
self$`byte` <- `byte`
}
if (!missing(`date`)) {
if (!is.character(`date`)) {
stop(paste("Error! Invalid Date. Must be a string:", `date`))
}
self$`date` <- `date`
}
if (!missing(`password`)) {
stopifnot(is.character(`password`), length(`password`) == 1)
self$`password` <- `password`
}
if (!is.null(`integer`)) {
stopifnot(is.numeric(`integer`), length(`integer`) == 1)
self$`integer` <- `integer`
}
if (!is.null(`int32`)) {
stopifnot(is.numeric(`int32`), length(`int32`) == 1)
self$`int32` <- `int32`
}
if (!is.null(`int64`)) {
stopifnot(is.numeric(`int64`), length(`int64`) == 1)
self$`int64` <- `int64`
}
if (!is.null(`float`)) {
stopifnot(is.numeric(`float`), length(`float`) == 1)
self$`float` <- `float`
}
if (!is.null(`double`)) {
stopifnot(is.numeric(`double`), length(`double`) == 1)
self$`double` <- `double`
}
if (!is.null(`string`)) {
stopifnot(is.character(`string`), length(`string`) == 1)
self$`string` <- `string`
}
if (!is.null(`binary`)) {
self$`binary` <- `binary`
}
if (!is.null(`dateTime`)) {
if (!is.character(`dateTime`)) {
stop(paste("Error! Invalid DateTime. Must be a string:", `dateTime`))
}
self$`dateTime` <- `dateTime`
}
if (!is.null(`uuid`)) {
stopifnot(is.character(`uuid`), length(`uuid`) == 1)
self$`uuid` <- `uuid`
}
if (!is.null(`pattern_with_digits`)) {
stopifnot(is.character(`pattern_with_digits`), length(`pattern_with_digits`) == 1)
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)
self$`pattern_with_digits_and_delimiter` <- `pattern_with_digits_and_delimiter`
}
if (!is.null(additional_properties)) {
for (key in names(additional_properties)) {
self$additional_properties[[key]] <- additional_properties[[key]]
}
}
},
#' To JSON string
#'
#' @description
#' To JSON String
#'
#' @return FormatTest in JSON format
#' @export
toJSON = function() {
FormatTestObject <- list()
if (!is.null(self$`integer`)) {
FormatTestObject[["integer"]] <-
self$`integer`
}
if (!is.null(self$`int32`)) {
FormatTestObject[["int32"]] <-
self$`int32`
}
if (!is.null(self$`int64`)) {
FormatTestObject[["int64"]] <-
self$`int64`
}
if (!is.null(self$`number`)) {
FormatTestObject[["number"]] <-
self$`number`
}
if (!is.null(self$`float`)) {
FormatTestObject[["float"]] <-
self$`float`
}
if (!is.null(self$`double`)) {
FormatTestObject[["double"]] <-
self$`double`
}
if (!is.null(self$`string`)) {
FormatTestObject[["string"]] <-
self$`string`
}
if (!is.null(self$`byte`)) {
FormatTestObject[["byte"]] <-
self$`byte`
}
if (!is.null(self$`binary`)) {
FormatTestObject[["binary"]] <-
self$`binary`
}
if (!is.null(self$`date`)) {
FormatTestObject[["date"]] <-
self$`date`
}
if (!is.null(self$`dateTime`)) {
FormatTestObject[["dateTime"]] <-
self$`dateTime`
}
if (!is.null(self$`uuid`)) {
FormatTestObject[["uuid"]] <-
self$`uuid`
}
if (!is.null(self$`password`)) {
FormatTestObject[["password"]] <-
self$`password`
}
if (!is.null(self$`pattern_with_digits`)) {
FormatTestObject[["pattern_with_digits"]] <-
self$`pattern_with_digits`
}
if (!is.null(self$`pattern_with_digits_and_delimiter`)) {
FormatTestObject[["pattern_with_digits_and_delimiter"]] <-
self$`pattern_with_digits_and_delimiter`
}
for (key in names(self$additional_properties)) {
FormatTestObject[[key]] <- self$additional_properties[[key]]
}
FormatTestObject
},
#' Deserialize JSON string into an instance of FormatTest
#'
#' @description
#' Deserialize JSON string into an instance of FormatTest
#'
#' @param input_json the JSON input
#' @return the instance of FormatTest
#' @export
fromJSON = function(input_json) {
this_object <- jsonlite::fromJSON(input_json)
if (!is.null(this_object$`integer`)) {
self$`integer` <- this_object$`integer`
}
if (!is.null(this_object$`int32`)) {
self$`int32` <- this_object$`int32`
}
if (!is.null(this_object$`int64`)) {
self$`int64` <- this_object$`int64`
}
if (!is.null(this_object$`number`)) {
self$`number` <- this_object$`number`
}
if (!is.null(this_object$`float`)) {
self$`float` <- this_object$`float`
}
if (!is.null(this_object$`double`)) {
self$`double` <- this_object$`double`
}
if (!is.null(this_object$`string`)) {
self$`string` <- this_object$`string`
}
if (!is.null(this_object$`byte`)) {
self$`byte` <- this_object$`byte`
}
if (!is.null(this_object$`binary`)) {
self$`binary` <- this_object$`binary`
}
if (!is.null(this_object$`date`)) {
self$`date` <- this_object$`date`
}
if (!is.null(this_object$`dateTime`)) {
self$`dateTime` <- this_object$`dateTime`
}
if (!is.null(this_object$`uuid`)) {
self$`uuid` <- this_object$`uuid`
}
if (!is.null(this_object$`password`)) {
self$`password` <- this_object$`password`
}
if (!is.null(this_object$`pattern_with_digits`)) {
self$`pattern_with_digits` <- this_object$`pattern_with_digits`
}
if (!is.null(this_object$`pattern_with_digits_and_delimiter`)) {
self$`pattern_with_digits_and_delimiter` <- this_object$`pattern_with_digits_and_delimiter`
}
# process additional properties/fields in the payload
for (key in names(this_object)) {
if (!(key %in% self$`_field_list`)) { # json key not in list of fields
self$additional_properties[[key]] <- this_object[[key]]
}
}
self
},
#' To JSON string
#'
#' @description
#' To JSON String
#'
#' @return FormatTest in JSON format
#' @export
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`integer`)) {
sprintf(
'"integer":
%d
',
self$`integer`
)
},
if (!is.null(self$`int32`)) {
sprintf(
'"int32":
%d
',
self$`int32`
)
},
if (!is.null(self$`int64`)) {
sprintf(
'"int64":
%d
',
self$`int64`
)
},
if (!is.null(self$`number`)) {
sprintf(
'"number":
%d
',
self$`number`
)
},
if (!is.null(self$`float`)) {
sprintf(
'"float":
%d
',
self$`float`
)
},
if (!is.null(self$`double`)) {
sprintf(
'"double":
%d
',
self$`double`
)
},
if (!is.null(self$`string`)) {
sprintf(
'"string":
"%s"
',
self$`string`
)
},
if (!is.null(self$`byte`)) {
sprintf(
'"byte":
"%s"
',
self$`byte`
)
},
if (!is.null(self$`binary`)) {
sprintf(
'"binary":
"%s"
',
self$`binary`
)
},
if (!is.null(self$`date`)) {
sprintf(
'"date":
"%s"
',
self$`date`
)
},
if (!is.null(self$`dateTime`)) {
sprintf(
'"dateTime":
"%s"
',
self$`dateTime`
)
},
if (!is.null(self$`uuid`)) {
sprintf(
'"uuid":
"%s"
',
self$`uuid`
)
},
if (!is.null(self$`password`)) {
sprintf(
'"password":
"%s"
',
self$`password`
)
},
if (!is.null(self$`pattern_with_digits`)) {
sprintf(
'"pattern_with_digits":
"%s"
',
self$`pattern_with_digits`
)
},
if (!is.null(self$`pattern_with_digits_and_delimiter`)) {
sprintf(
'"pattern_with_digits_and_delimiter":
"%s"
',
self$`pattern_with_digits_and_delimiter`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]]
}
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA)))
},
#' Deserialize JSON string into an instance of FormatTest
#'
#' @description
#' Deserialize JSON string into an instance of FormatTest
#'
#' @param input_json the JSON input
#' @return the instance of FormatTest
#' @export
fromJSONString = function(input_json) {
this_object <- jsonlite::fromJSON(input_json)
self$`integer` <- this_object$`integer`
self$`int32` <- this_object$`int32`
self$`int64` <- this_object$`int64`
self$`number` <- this_object$`number`
self$`float` <- this_object$`float`
self$`double` <- this_object$`double`
self$`string` <- this_object$`string`
self$`byte` <- this_object$`byte`
self$`binary` <- this_object$`binary`
self$`date` <- this_object$`date`
self$`dateTime` <- this_object$`dateTime`
self$`uuid` <- this_object$`uuid`
self$`password` <- this_object$`password`
self$`pattern_with_digits` <- this_object$`pattern_with_digits`
self$`pattern_with_digits_and_delimiter` <- this_object$`pattern_with_digits_and_delimiter`
# process additional properties/fields in the payload
for (key in names(this_object)) {
if (!(key %in% self$`_field_list`)) { # json key not in list of fields
self$additional_properties[[key]] <- this_object[[key]]
}
}
self
},
#' Validate JSON input with respect to FormatTest
#'
#' @description
#' Validate JSON input with respect to FormatTest and throw an exception if invalid
#'
#' @param input the JSON input
#' @export
validateJSON = function(input) {
input_json <- jsonlite::fromJSON(input)
# check the required field `number`
if (!is.null(input_json$`number`)) {
} else {
stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `number` is missing."))
}
# check the required field `byte`
if (!is.null(input_json$`byte`)) {
} else {
stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `byte` is missing."))
}
# check the required field `date`
if (!is.null(input_json$`date`)) {
stopifnot(is.character(input_json$`date`), length(input_json$`date`) == 1)
} 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)
} else {
stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `password` is missing."))
}
},
#' To string (JSON format)
#'
#' @description
#' To string (JSON format)
#'
#' @return String representation of FormatTest
#' @export
toString = function() {
self$toJSONString()
},
#' Return true if the values in all fields are valid.
#'
#' @description
#' Return true if the values in all fields are valid.
#'
#' @return true if the values in all fields are valid.
#' @export
isValid = function() {
if (self$`integer` > 100) {
return(FALSE)
}
if (self$`integer` < 10) {
return(FALSE)
}
if (self$`int32` > 200) {
return(FALSE)
}
if (self$`int32` < 20) {
return(FALSE)
}
# check if the required `number` is null
if (is.null(self$`number`)) {
return(FALSE)
}
if (self$`number` > 543.2) {
return(FALSE)
}
if (self$`number` < 32.1) {
return(FALSE)
}
if (self$`float` > 987.6) {
return(FALSE)
}
if (self$`float` < 54.3) {
return(FALSE)
}
if (self$`double` > 123.4) {
return(FALSE)
}
if (self$`double` < 67.8) {
return(FALSE)
}
if (!str_detect(self$`string`, "[a-z]/i")) {
return(FALSE)
}
# check if the required `byte` is null
if (is.null(self$`byte`)) {
return(FALSE)
}
# check if the required `date` is null
if (is.null(self$`date`)) {
return(FALSE)
}
# check if the required `password` is null
if (is.null(self$`password`)) {
return(FALSE)
}
if (nchar(self$`password`) > 64) {
return(FALSE)
}
if (nchar(self$`password`) < 10) {
return(FALSE)
}
if (!str_detect(self$`pattern_with_digits`, "^\\d{10}$")) {
return(FALSE)
}
if (!str_detect(self$`pattern_with_digits_and_delimiter`, "^image_\\d{1,3}$/i")) {
return(FALSE)
}
TRUE
},
#' Return a list of invalid fields (if any).
#'
#' @description
#' Return a list of invalid fields (if any).
#'
#' @return A list of invalid fields (if any).
#' @export
getInvalidFields = function() {
invalid_fields <- list()
if (self$`integer` > 100) {
invalid_fields["integer"] <- "Invalid value for `integer`, must be smaller than or equal to 100."
}
if (self$`integer` < 10) {
invalid_fields["integer"] <- "Invalid value for `integer`, must be bigger than or equal to 10."
}
if (self$`int32` > 200) {
invalid_fields["int32"] <- "Invalid value for `int32`, must be smaller than or equal to 200."
}
if (self$`int32` < 20) {
invalid_fields["int32"] <- "Invalid value for `int32`, must be bigger than or equal to 20."
}
# check if the required `number` is null
if (is.null(self$`number`)) {
invalid_fields["number"] <- "Non-nullable required field `number` cannot be null."
}
if (self$`number` > 543.2) {
invalid_fields["number"] <- "Invalid value for `number`, must be smaller than or equal to 543.2."
}
if (self$`number` < 32.1) {
invalid_fields["number"] <- "Invalid value for `number`, must be bigger than or equal to 32.1."
}
if (self$`float` > 987.6) {
invalid_fields["float"] <- "Invalid value for `float`, must be smaller than or equal to 987.6."
}
if (self$`float` < 54.3) {
invalid_fields["float"] <- "Invalid value for `float`, must be bigger than or equal to 54.3."
}
if (self$`double` > 123.4) {
invalid_fields["double"] <- "Invalid value for `double`, must be smaller than or equal to 123.4."
}
if (self$`double` < 67.8) {
invalid_fields["double"] <- "Invalid value for `double`, must be bigger than or equal to 67.8."
}
if (!str_detect(self$`string`, "[a-z]/i")) {
invalid_fields["string"] <- "Invalid value for `string`, must conform to the pattern [a-z]/i."
}
# check if the required `byte` is null
if (is.null(self$`byte`)) {
invalid_fields["byte"] <- "Non-nullable required field `byte` cannot be null."
}
# check if the required `date` is null
if (is.null(self$`date`)) {
invalid_fields["date"] <- "Non-nullable required field `date` cannot be null."
}
# check if the required `password` is null
if (is.null(self$`password`)) {
invalid_fields["password"] <- "Non-nullable required field `password` cannot be null."
}
if (nchar(self$`password`) > 64) {
invalid_fields["password"] <- "Invalid length for `password`, must be smaller than or equal to 64."
}
if (nchar(self$`password`) < 10) {
invalid_fields["password"] <- "Invalid length for `password`, must be bigger than or equal to 10."
}
if (!str_detect(self$`pattern_with_digits`, "^\\d{10}$")) {
invalid_fields["pattern_with_digits"] <- "Invalid value for `pattern_with_digits`, must conform to the pattern ^\\d{10}$."
}
if (!str_detect(self$`pattern_with_digits_and_delimiter`, "^image_\\d{1,3}$/i")) {
invalid_fields["pattern_with_digits_and_delimiter"] <- "Invalid value for `pattern_with_digits_and_delimiter`, must conform to the pattern ^image_\\d{1,3}$/i."
}
invalid_fields
},
#' Print the object
#'
#' @description
#' Print the object
#'
#' @export
print = function() {
print(jsonlite::prettify(self$toJSONString()))
invisible(self)
}
),
# Lock the class to prevent modifications to the method or field
lock_class = TRUE
)
## Uncomment below to unlock the class to allow modifications of the method or field
# FormatTest$unlock()
#
## Below is an example to define the print fnuction
# FormatTest$set("public", "print", function(...) {
# print(jsonlite::prettify(self$toJSONString()))
# invisible(self)
# })
## Uncomment below to lock the class to prevent modifications to the method or field
# FormatTest$lock()

View File

@ -57,7 +57,9 @@ Order <- R6::R6Class(
self$`quantity` <- `quantity`
}
if (!is.null(`shipDate`)) {
stopifnot(is.character(`shipDate`), length(`shipDate`) == 1)
if (!is.character(`shipDate`)) {
stop(paste("Error! Invalid DateTime. Must be a string:", `shipDate`))
}
self$`shipDate` <- `shipDate`
}
if (!is.null(`status`)) {

View File

@ -115,6 +115,7 @@ Class | Method | HTTP request | Description
- [Date](docs/Date.md)
- [Dog](docs/Dog.md)
- [DogAllOf](docs/DogAllOf.md)
- [FormatTest](docs/FormatTest.md)
- [Mammal](docs/Mammal.md)
- [ModelApiResponse](docs/ModelApiResponse.md)
- [NestedOneOf](docs/NestedOneOf.md)

View File

@ -0,0 +1,23 @@
# petstore::FormatTest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**integer** | **integer** | | [optional] [Max: 100] [Min: 10]
**int32** | **integer** | | [optional] [Max: 200] [Min: 20]
**int64** | **integer** | | [optional]
**number** | **numeric** | | [Max: 543.2] [Min: 32.1]
**float** | **numeric** | | [optional] [Max: 987.6] [Min: 54.3]
**double** | **numeric** | | [optional] [Max: 123.4] [Min: 67.8]
**string** | **character** | | [optional] [Pattern: [a-z]/i]
**byte** | **character** | |
**binary** | **data.frame** | | [optional]
**date** | **character** | | [default to &quot;Fri Jul 19 00:00:00 UTC 2019&quot;]
**dateTime** | **character** | | [optional] [default to &quot;2015-10-28T14:38:02Z&quot;]
**uuid** | **character** | | [optional]
**password** | **character** | | [Max. length: 64] [Min. length: 10]
**pattern_with_digits** | **character** | A string that is a 10 digit number. Can have leading zeros. | [optional] [Pattern: ^\\d{10}$]
**pattern_with_digits_and_delimiter** | **character** | A string starting with &#39;image_&#39; (case insensitive) and one to three digits following i.e. Image_01. | [optional] [Pattern: ^image_\\d{1,3}$/i]

View File

@ -0,0 +1,113 @@
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
context("Test FormatTest")
model_instance <- FormatTest$new()
test_that("integer", {
# tests for the property `integer` (integer)
# uncomment below to test the property
#expect_equal(model.instance$`integer`, "EXPECTED_RESULT")
})
test_that("int32", {
# tests for the property `int32` (integer)
# uncomment below to test the property
#expect_equal(model.instance$`int32`, "EXPECTED_RESULT")
})
test_that("int64", {
# tests for the property `int64` (integer)
# uncomment below to test the property
#expect_equal(model.instance$`int64`, "EXPECTED_RESULT")
})
test_that("number", {
# tests for the property `number` (numeric)
# uncomment below to test the property
#expect_equal(model.instance$`number`, "EXPECTED_RESULT")
})
test_that("float", {
# tests for the property `float` (numeric)
# uncomment below to test the property
#expect_equal(model.instance$`float`, "EXPECTED_RESULT")
})
test_that("double", {
# tests for the property `double` (numeric)
# uncomment below to test the property
#expect_equal(model.instance$`double`, "EXPECTED_RESULT")
})
test_that("string", {
# tests for the property `string` (character)
# uncomment below to test the property
#expect_equal(model.instance$`string`, "EXPECTED_RESULT")
})
test_that("byte", {
# tests for the property `byte` (character)
# uncomment below to test the property
#expect_equal(model.instance$`byte`, "EXPECTED_RESULT")
})
test_that("binary", {
# tests for the property `binary` (data.frame)
# uncomment below to test the property
#expect_equal(model.instance$`binary`, "EXPECTED_RESULT")
})
test_that("date", {
# tests for the property `date` (character)
# uncomment below to test the property
#expect_equal(model.instance$`date`, "EXPECTED_RESULT")
})
test_that("dateTime", {
# tests for the property `dateTime` (character)
# uncomment below to test the property
#expect_equal(model.instance$`dateTime`, "EXPECTED_RESULT")
})
test_that("uuid", {
# tests for the property `uuid` (character)
# uncomment below to test the property
#expect_equal(model.instance$`uuid`, "EXPECTED_RESULT")
})
test_that("password", {
# tests for the property `password` (character)
# uncomment below to test the property
#expect_equal(model.instance$`password`, "EXPECTED_RESULT")
})
test_that("pattern_with_digits", {
# tests for the property `pattern_with_digits` (character)
# A string that is a 10 digit number. Can have leading zeros.
# uncomment below to test the property
#expect_equal(model.instance$`pattern_with_digits`, "EXPECTED_RESULT")
})
test_that("pattern_with_digits_and_delimiter", {
# tests for the property `pattern_with_digits_and_delimiter` (character)
# A string starting with &#39;image_&#39; (case insensitive) and one to three digits following i.e. Image_01.
# uncomment below to test the property
#expect_equal(model.instance$`pattern_with_digits_and_delimiter`, "EXPECTED_RESULT")
})

View File

@ -613,3 +613,13 @@ test_that("Tests URL validation", {
d <- Date$new()
expect_error(d$fromJSONString(invalid_json), 'Error! Invalid URL: invalid_url') # should throw exception
})
test_that("Order and datetime test", {
# test tag
t <- Order$new(id = 393, petId = 12930, quantity = 12, shipDate = "2019-09-29T19:39:29Z", status = "approved")
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")
})

View File

@ -21,6 +21,7 @@ R/date.R
R/dog.R
R/dog_all_of.R
R/fake_api.R
R/format_test.R
R/mammal.R
R/model_api_response.R
R/nested_one_of.R
@ -51,6 +52,7 @@ docs/Date.md
docs/Dog.md
docs/DogAllOf.md
docs/FakeApi.md
docs/FormatTest.md
docs/Mammal.md
docs/ModelApiResponse.md
docs/NestedOneOf.md

View File

@ -26,6 +26,7 @@ export(DanishPig)
export(Date)
export(Dog)
export(DogAllOf)
export(FormatTest)
export(Mammal)
export(ModelApiResponse)
export(NestedOneOf)

View File

@ -0,0 +1,654 @@
#' Create a new FormatTest
#'
#' @description
#' FormatTest Class
#'
#' @docType class
#' @title FormatTest
#' @description FormatTest Class
#' @format An \code{R6Class} generator object
#' @field integer integer [optional]
#' @field int32 integer [optional]
#' @field int64 integer [optional]
#' @field number numeric
#' @field float numeric [optional]
#' @field double numeric [optional]
#' @field string character [optional]
#' @field byte character
#' @field binary data.frame [optional]
#' @field date character
#' @field dateTime character [optional]
#' @field uuid character [optional]
#' @field password character
#' @field pattern_with_digits A string that is a 10 digit number. Can have leading zeros. character [optional]
#' @field pattern_with_digits_and_delimiter A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. character [optional]
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
FormatTest <- R6::R6Class(
"FormatTest",
public = list(
`integer` = NULL,
`int32` = NULL,
`int64` = NULL,
`number` = NULL,
`float` = NULL,
`double` = NULL,
`string` = NULL,
`byte` = NULL,
`binary` = NULL,
`date` = NULL,
`dateTime` = NULL,
`uuid` = NULL,
`password` = NULL,
`pattern_with_digits` = NULL,
`pattern_with_digits_and_delimiter` = NULL,
#' Initialize a new FormatTest class.
#'
#' @description
#' Initialize a new FormatTest class.
#'
#' @param number number
#' @param byte byte
#' @param date date
#' @param password password
#' @param integer integer
#' @param int32 int32
#' @param int64 int64
#' @param float float
#' @param double double
#' @param string string
#' @param binary binary
#' @param dateTime dateTime. Default to "2015-10-28T14:38:02Z".
#' @param uuid uuid
#' @param pattern_with_digits A string that is a 10 digit number. Can have leading zeros.
#' @param pattern_with_digits_and_delimiter A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
#' @param ... Other optional arguments.
#' @export
initialize = function(`number`, `byte`, `date`, `password`, `integer` = NULL, `int32` = NULL, `int64` = NULL, `float` = NULL, `double` = NULL, `string` = NULL, `binary` = NULL, `dateTime` = "2015-10-28T14:38:02Z", `uuid` = NULL, `pattern_with_digits` = NULL, `pattern_with_digits_and_delimiter` = NULL, ...) {
if (!missing(`number`)) {
self$`number` <- `number`
}
if (!missing(`byte`)) {
self$`byte` <- `byte`
}
if (!missing(`date`)) {
if (!is.character(`date`)) {
stop(paste("Error! Invalid Date. Must be a string:", `date`))
}
self$`date` <- `date`
}
if (!missing(`password`)) {
stopifnot(is.character(`password`), length(`password`) == 1)
self$`password` <- `password`
}
if (!is.null(`integer`)) {
stopifnot(is.numeric(`integer`), length(`integer`) == 1)
self$`integer` <- `integer`
}
if (!is.null(`int32`)) {
stopifnot(is.numeric(`int32`), length(`int32`) == 1)
self$`int32` <- `int32`
}
if (!is.null(`int64`)) {
stopifnot(is.numeric(`int64`), length(`int64`) == 1)
self$`int64` <- `int64`
}
if (!is.null(`float`)) {
stopifnot(is.numeric(`float`), length(`float`) == 1)
self$`float` <- `float`
}
if (!is.null(`double`)) {
stopifnot(is.numeric(`double`), length(`double`) == 1)
self$`double` <- `double`
}
if (!is.null(`string`)) {
stopifnot(is.character(`string`), length(`string`) == 1)
self$`string` <- `string`
}
if (!is.null(`binary`)) {
self$`binary` <- `binary`
}
if (!is.null(`dateTime`)) {
if (!is.character(`dateTime`)) {
stop(paste("Error! Invalid DateTime. Must be a string:", `dateTime`))
}
self$`dateTime` <- `dateTime`
}
if (!is.null(`uuid`)) {
stopifnot(is.character(`uuid`), length(`uuid`) == 1)
self$`uuid` <- `uuid`
}
if (!is.null(`pattern_with_digits`)) {
stopifnot(is.character(`pattern_with_digits`), length(`pattern_with_digits`) == 1)
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)
self$`pattern_with_digits_and_delimiter` <- `pattern_with_digits_and_delimiter`
}
},
#' To JSON string
#'
#' @description
#' To JSON String
#'
#' @return FormatTest in JSON format
#' @export
toJSON = function() {
FormatTestObject <- list()
if (!is.null(self$`integer`)) {
FormatTestObject[["integer"]] <-
self$`integer`
}
if (!is.null(self$`int32`)) {
FormatTestObject[["int32"]] <-
self$`int32`
}
if (!is.null(self$`int64`)) {
FormatTestObject[["int64"]] <-
self$`int64`
}
if (!is.null(self$`number`)) {
FormatTestObject[["number"]] <-
self$`number`
}
if (!is.null(self$`float`)) {
FormatTestObject[["float"]] <-
self$`float`
}
if (!is.null(self$`double`)) {
FormatTestObject[["double"]] <-
self$`double`
}
if (!is.null(self$`string`)) {
FormatTestObject[["string"]] <-
self$`string`
}
if (!is.null(self$`byte`)) {
FormatTestObject[["byte"]] <-
self$`byte`
}
if (!is.null(self$`binary`)) {
FormatTestObject[["binary"]] <-
self$`binary`
}
if (!is.null(self$`date`)) {
FormatTestObject[["date"]] <-
self$`date`
}
if (!is.null(self$`dateTime`)) {
FormatTestObject[["dateTime"]] <-
self$`dateTime`
}
if (!is.null(self$`uuid`)) {
FormatTestObject[["uuid"]] <-
self$`uuid`
}
if (!is.null(self$`password`)) {
FormatTestObject[["password"]] <-
self$`password`
}
if (!is.null(self$`pattern_with_digits`)) {
FormatTestObject[["pattern_with_digits"]] <-
self$`pattern_with_digits`
}
if (!is.null(self$`pattern_with_digits_and_delimiter`)) {
FormatTestObject[["pattern_with_digits_and_delimiter"]] <-
self$`pattern_with_digits_and_delimiter`
}
FormatTestObject
},
#' Deserialize JSON string into an instance of FormatTest
#'
#' @description
#' Deserialize JSON string into an instance of FormatTest
#'
#' @param input_json the JSON input
#' @return the instance of FormatTest
#' @export
fromJSON = function(input_json) {
this_object <- jsonlite::fromJSON(input_json)
if (!is.null(this_object$`integer`)) {
self$`integer` <- this_object$`integer`
}
if (!is.null(this_object$`int32`)) {
self$`int32` <- this_object$`int32`
}
if (!is.null(this_object$`int64`)) {
self$`int64` <- this_object$`int64`
}
if (!is.null(this_object$`number`)) {
self$`number` <- this_object$`number`
}
if (!is.null(this_object$`float`)) {
self$`float` <- this_object$`float`
}
if (!is.null(this_object$`double`)) {
self$`double` <- this_object$`double`
}
if (!is.null(this_object$`string`)) {
self$`string` <- this_object$`string`
}
if (!is.null(this_object$`byte`)) {
self$`byte` <- this_object$`byte`
}
if (!is.null(this_object$`binary`)) {
self$`binary` <- this_object$`binary`
}
if (!is.null(this_object$`date`)) {
self$`date` <- this_object$`date`
}
if (!is.null(this_object$`dateTime`)) {
self$`dateTime` <- this_object$`dateTime`
}
if (!is.null(this_object$`uuid`)) {
self$`uuid` <- this_object$`uuid`
}
if (!is.null(this_object$`password`)) {
self$`password` <- this_object$`password`
}
if (!is.null(this_object$`pattern_with_digits`)) {
self$`pattern_with_digits` <- this_object$`pattern_with_digits`
}
if (!is.null(this_object$`pattern_with_digits_and_delimiter`)) {
self$`pattern_with_digits_and_delimiter` <- this_object$`pattern_with_digits_and_delimiter`
}
self
},
#' To JSON string
#'
#' @description
#' To JSON String
#'
#' @return FormatTest in JSON format
#' @export
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`integer`)) {
sprintf(
'"integer":
%d
',
self$`integer`
)
},
if (!is.null(self$`int32`)) {
sprintf(
'"int32":
%d
',
self$`int32`
)
},
if (!is.null(self$`int64`)) {
sprintf(
'"int64":
%d
',
self$`int64`
)
},
if (!is.null(self$`number`)) {
sprintf(
'"number":
%d
',
self$`number`
)
},
if (!is.null(self$`float`)) {
sprintf(
'"float":
%d
',
self$`float`
)
},
if (!is.null(self$`double`)) {
sprintf(
'"double":
%d
',
self$`double`
)
},
if (!is.null(self$`string`)) {
sprintf(
'"string":
"%s"
',
self$`string`
)
},
if (!is.null(self$`byte`)) {
sprintf(
'"byte":
"%s"
',
self$`byte`
)
},
if (!is.null(self$`binary`)) {
sprintf(
'"binary":
"%s"
',
self$`binary`
)
},
if (!is.null(self$`date`)) {
sprintf(
'"date":
"%s"
',
self$`date`
)
},
if (!is.null(self$`dateTime`)) {
sprintf(
'"dateTime":
"%s"
',
self$`dateTime`
)
},
if (!is.null(self$`uuid`)) {
sprintf(
'"uuid":
"%s"
',
self$`uuid`
)
},
if (!is.null(self$`password`)) {
sprintf(
'"password":
"%s"
',
self$`password`
)
},
if (!is.null(self$`pattern_with_digits`)) {
sprintf(
'"pattern_with_digits":
"%s"
',
self$`pattern_with_digits`
)
},
if (!is.null(self$`pattern_with_digits_and_delimiter`)) {
sprintf(
'"pattern_with_digits_and_delimiter":
"%s"
',
self$`pattern_with_digits_and_delimiter`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of FormatTest
#'
#' @description
#' Deserialize JSON string into an instance of FormatTest
#'
#' @param input_json the JSON input
#' @return the instance of FormatTest
#' @export
fromJSONString = function(input_json) {
this_object <- jsonlite::fromJSON(input_json)
self$`integer` <- this_object$`integer`
self$`int32` <- this_object$`int32`
self$`int64` <- this_object$`int64`
self$`number` <- this_object$`number`
self$`float` <- this_object$`float`
self$`double` <- this_object$`double`
self$`string` <- this_object$`string`
self$`byte` <- this_object$`byte`
self$`binary` <- this_object$`binary`
self$`date` <- this_object$`date`
self$`dateTime` <- this_object$`dateTime`
self$`uuid` <- this_object$`uuid`
self$`password` <- this_object$`password`
self$`pattern_with_digits` <- this_object$`pattern_with_digits`
self$`pattern_with_digits_and_delimiter` <- this_object$`pattern_with_digits_and_delimiter`
self
},
#' Validate JSON input with respect to FormatTest
#'
#' @description
#' Validate JSON input with respect to FormatTest and throw an exception if invalid
#'
#' @param input the JSON input
#' @export
validateJSON = function(input) {
input_json <- jsonlite::fromJSON(input)
# check the required field `number`
if (!is.null(input_json$`number`)) {
} else {
stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `number` is missing."))
}
# check the required field `byte`
if (!is.null(input_json$`byte`)) {
} else {
stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `byte` is missing."))
}
# check the required field `date`
if (!is.null(input_json$`date`)) {
stopifnot(is.character(input_json$`date`), length(input_json$`date`) == 1)
} 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)
} else {
stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `password` is missing."))
}
},
#' To string (JSON format)
#'
#' @description
#' To string (JSON format)
#'
#' @return String representation of FormatTest
#' @export
toString = function() {
self$toJSONString()
},
#' Return true if the values in all fields are valid.
#'
#' @description
#' Return true if the values in all fields are valid.
#'
#' @return true if the values in all fields are valid.
#' @export
isValid = function() {
if (self$`integer` > 100) {
return(FALSE)
}
if (self$`integer` < 10) {
return(FALSE)
}
if (self$`int32` > 200) {
return(FALSE)
}
if (self$`int32` < 20) {
return(FALSE)
}
# check if the required `number` is null
if (is.null(self$`number`)) {
return(FALSE)
}
if (self$`number` > 543.2) {
return(FALSE)
}
if (self$`number` < 32.1) {
return(FALSE)
}
if (self$`float` > 987.6) {
return(FALSE)
}
if (self$`float` < 54.3) {
return(FALSE)
}
if (self$`double` > 123.4) {
return(FALSE)
}
if (self$`double` < 67.8) {
return(FALSE)
}
if (!str_detect(self$`string`, "[a-z]/i")) {
return(FALSE)
}
# check if the required `byte` is null
if (is.null(self$`byte`)) {
return(FALSE)
}
# check if the required `date` is null
if (is.null(self$`date`)) {
return(FALSE)
}
# check if the required `password` is null
if (is.null(self$`password`)) {
return(FALSE)
}
if (nchar(self$`password`) > 64) {
return(FALSE)
}
if (nchar(self$`password`) < 10) {
return(FALSE)
}
if (!str_detect(self$`pattern_with_digits`, "^\\d{10}$")) {
return(FALSE)
}
if (!str_detect(self$`pattern_with_digits_and_delimiter`, "^image_\\d{1,3}$/i")) {
return(FALSE)
}
TRUE
},
#' Return a list of invalid fields (if any).
#'
#' @description
#' Return a list of invalid fields (if any).
#'
#' @return A list of invalid fields (if any).
#' @export
getInvalidFields = function() {
invalid_fields <- list()
if (self$`integer` > 100) {
invalid_fields["integer"] <- "Invalid value for `integer`, must be smaller than or equal to 100."
}
if (self$`integer` < 10) {
invalid_fields["integer"] <- "Invalid value for `integer`, must be bigger than or equal to 10."
}
if (self$`int32` > 200) {
invalid_fields["int32"] <- "Invalid value for `int32`, must be smaller than or equal to 200."
}
if (self$`int32` < 20) {
invalid_fields["int32"] <- "Invalid value for `int32`, must be bigger than or equal to 20."
}
# check if the required `number` is null
if (is.null(self$`number`)) {
invalid_fields["number"] <- "Non-nullable required field `number` cannot be null."
}
if (self$`number` > 543.2) {
invalid_fields["number"] <- "Invalid value for `number`, must be smaller than or equal to 543.2."
}
if (self$`number` < 32.1) {
invalid_fields["number"] <- "Invalid value for `number`, must be bigger than or equal to 32.1."
}
if (self$`float` > 987.6) {
invalid_fields["float"] <- "Invalid value for `float`, must be smaller than or equal to 987.6."
}
if (self$`float` < 54.3) {
invalid_fields["float"] <- "Invalid value for `float`, must be bigger than or equal to 54.3."
}
if (self$`double` > 123.4) {
invalid_fields["double"] <- "Invalid value for `double`, must be smaller than or equal to 123.4."
}
if (self$`double` < 67.8) {
invalid_fields["double"] <- "Invalid value for `double`, must be bigger than or equal to 67.8."
}
if (!str_detect(self$`string`, "[a-z]/i")) {
invalid_fields["string"] <- "Invalid value for `string`, must conform to the pattern [a-z]/i."
}
# check if the required `byte` is null
if (is.null(self$`byte`)) {
invalid_fields["byte"] <- "Non-nullable required field `byte` cannot be null."
}
# check if the required `date` is null
if (is.null(self$`date`)) {
invalid_fields["date"] <- "Non-nullable required field `date` cannot be null."
}
# check if the required `password` is null
if (is.null(self$`password`)) {
invalid_fields["password"] <- "Non-nullable required field `password` cannot be null."
}
if (nchar(self$`password`) > 64) {
invalid_fields["password"] <- "Invalid length for `password`, must be smaller than or equal to 64."
}
if (nchar(self$`password`) < 10) {
invalid_fields["password"] <- "Invalid length for `password`, must be bigger than or equal to 10."
}
if (!str_detect(self$`pattern_with_digits`, "^\\d{10}$")) {
invalid_fields["pattern_with_digits"] <- "Invalid value for `pattern_with_digits`, must conform to the pattern ^\\d{10}$."
}
if (!str_detect(self$`pattern_with_digits_and_delimiter`, "^image_\\d{1,3}$/i")) {
invalid_fields["pattern_with_digits_and_delimiter"] <- "Invalid value for `pattern_with_digits_and_delimiter`, must conform to the pattern ^image_\\d{1,3}$/i."
}
invalid_fields
},
#' Print the object
#'
#' @description
#' Print the object
#'
#' @export
print = function() {
print(jsonlite::prettify(self$toJSONString()))
invisible(self)
}
),
# Lock the class to prevent modifications to the method or field
lock_class = TRUE
)
## Uncomment below to unlock the class to allow modifications of the method or field
# FormatTest$unlock()
#
## Below is an example to define the print fnuction
# FormatTest$set("public", "print", function(...) {
# print(jsonlite::prettify(self$toJSONString()))
# invisible(self)
# })
## Uncomment below to lock the class to prevent modifications to the method or field
# FormatTest$lock()

View File

@ -52,7 +52,9 @@ Order <- R6::R6Class(
self$`quantity` <- `quantity`
}
if (!is.null(`shipDate`)) {
stopifnot(is.character(`shipDate`), length(`shipDate`) == 1)
if (!is.character(`shipDate`)) {
stop(paste("Error! Invalid DateTime. Must be a string:", `shipDate`))
}
self$`shipDate` <- `shipDate`
}
if (!is.null(`status`)) {

View File

@ -115,6 +115,7 @@ Class | Method | HTTP request | Description
- [Date](docs/Date.md)
- [Dog](docs/Dog.md)
- [DogAllOf](docs/DogAllOf.md)
- [FormatTest](docs/FormatTest.md)
- [Mammal](docs/Mammal.md)
- [ModelApiResponse](docs/ModelApiResponse.md)
- [NestedOneOf](docs/NestedOneOf.md)

View File

@ -0,0 +1,23 @@
# petstore::FormatTest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**integer** | **integer** | | [optional] [Max: 100] [Min: 10]
**int32** | **integer** | | [optional] [Max: 200] [Min: 20]
**int64** | **integer** | | [optional]
**number** | **numeric** | | [Max: 543.2] [Min: 32.1]
**float** | **numeric** | | [optional] [Max: 987.6] [Min: 54.3]
**double** | **numeric** | | [optional] [Max: 123.4] [Min: 67.8]
**string** | **character** | | [optional] [Pattern: [a-z]/i]
**byte** | **character** | |
**binary** | **data.frame** | | [optional]
**date** | **character** | | [default to &quot;Fri Jul 19 00:00:00 UTC 2019&quot;]
**dateTime** | **character** | | [optional] [default to &quot;2015-10-28T14:38:02Z&quot;]
**uuid** | **character** | | [optional]
**password** | **character** | | [Max. length: 64] [Min. length: 10]
**pattern_with_digits** | **character** | A string that is a 10 digit number. Can have leading zeros. | [optional] [Pattern: ^\\d{10}$]
**pattern_with_digits_and_delimiter** | **character** | A string starting with &#39;image_&#39; (case insensitive) and one to three digits following i.e. Image_01. | [optional] [Pattern: ^image_\\d{1,3}$/i]

View File

@ -0,0 +1,113 @@
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
context("Test FormatTest")
model_instance <- FormatTest$new()
test_that("integer", {
# tests for the property `integer` (integer)
# uncomment below to test the property
#expect_equal(model.instance$`integer`, "EXPECTED_RESULT")
})
test_that("int32", {
# tests for the property `int32` (integer)
# uncomment below to test the property
#expect_equal(model.instance$`int32`, "EXPECTED_RESULT")
})
test_that("int64", {
# tests for the property `int64` (integer)
# uncomment below to test the property
#expect_equal(model.instance$`int64`, "EXPECTED_RESULT")
})
test_that("number", {
# tests for the property `number` (numeric)
# uncomment below to test the property
#expect_equal(model.instance$`number`, "EXPECTED_RESULT")
})
test_that("float", {
# tests for the property `float` (numeric)
# uncomment below to test the property
#expect_equal(model.instance$`float`, "EXPECTED_RESULT")
})
test_that("double", {
# tests for the property `double` (numeric)
# uncomment below to test the property
#expect_equal(model.instance$`double`, "EXPECTED_RESULT")
})
test_that("string", {
# tests for the property `string` (character)
# uncomment below to test the property
#expect_equal(model.instance$`string`, "EXPECTED_RESULT")
})
test_that("byte", {
# tests for the property `byte` (character)
# uncomment below to test the property
#expect_equal(model.instance$`byte`, "EXPECTED_RESULT")
})
test_that("binary", {
# tests for the property `binary` (data.frame)
# uncomment below to test the property
#expect_equal(model.instance$`binary`, "EXPECTED_RESULT")
})
test_that("date", {
# tests for the property `date` (character)
# uncomment below to test the property
#expect_equal(model.instance$`date`, "EXPECTED_RESULT")
})
test_that("dateTime", {
# tests for the property `dateTime` (character)
# uncomment below to test the property
#expect_equal(model.instance$`dateTime`, "EXPECTED_RESULT")
})
test_that("uuid", {
# tests for the property `uuid` (character)
# uncomment below to test the property
#expect_equal(model.instance$`uuid`, "EXPECTED_RESULT")
})
test_that("password", {
# tests for the property `password` (character)
# uncomment below to test the property
#expect_equal(model.instance$`password`, "EXPECTED_RESULT")
})
test_that("pattern_with_digits", {
# tests for the property `pattern_with_digits` (character)
# A string that is a 10 digit number. Can have leading zeros.
# uncomment below to test the property
#expect_equal(model.instance$`pattern_with_digits`, "EXPECTED_RESULT")
})
test_that("pattern_with_digits_and_delimiter", {
# tests for the property `pattern_with_digits_and_delimiter` (character)
# A string starting with &#39;image_&#39; (case insensitive) and one to three digits following i.e. Image_01.
# uncomment below to test the property
#expect_equal(model.instance$`pattern_with_digits_and_delimiter`, "EXPECTED_RESULT")
})

View File

@ -21,6 +21,7 @@ R/date.R
R/dog.R
R/dog_all_of.R
R/fake_api.R
R/format_test.R
R/mammal.R
R/model_api_response.R
R/nested_one_of.R
@ -51,6 +52,7 @@ docs/Date.md
docs/Dog.md
docs/DogAllOf.md
docs/FakeApi.md
docs/FormatTest.md
docs/Mammal.md
docs/ModelApiResponse.md
docs/NestedOneOf.md

View File

@ -26,6 +26,7 @@ export(DanishPig)
export(Date)
export(Dog)
export(DogAllOf)
export(FormatTest)
export(Mammal)
export(ModelApiResponse)
export(NestedOneOf)

View File

@ -0,0 +1,687 @@
#' Create a new FormatTest
#'
#' @description
#' FormatTest Class
#'
#' @docType class
#' @title FormatTest
#' @description FormatTest Class
#' @format An \code{R6Class} generator object
#' @field integer integer [optional]
#' @field int32 integer [optional]
#' @field int64 integer [optional]
#' @field number numeric
#' @field float numeric [optional]
#' @field double numeric [optional]
#' @field string character [optional]
#' @field byte character
#' @field binary data.frame [optional]
#' @field date character
#' @field dateTime character [optional]
#' @field uuid character [optional]
#' @field password character
#' @field pattern_with_digits A string that is a 10 digit number. Can have leading zeros. character [optional]
#' @field pattern_with_digits_and_delimiter A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. character [optional]
#' @field _field_list a list of fields list(character)
#' @field additional_properties additional properties list(character) [optional]
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
FormatTest <- R6::R6Class(
"FormatTest",
public = list(
`integer` = NULL,
`int32` = NULL,
`int64` = NULL,
`number` = NULL,
`float` = NULL,
`double` = NULL,
`string` = NULL,
`byte` = NULL,
`binary` = NULL,
`date` = NULL,
`dateTime` = NULL,
`uuid` = NULL,
`password` = NULL,
`pattern_with_digits` = NULL,
`pattern_with_digits_and_delimiter` = NULL,
`_field_list` = c("integer", "int32", "int64", "number", "float", "double", "string", "byte", "binary", "date", "dateTime", "uuid", "password", "pattern_with_digits", "pattern_with_digits_and_delimiter"),
`additional_properties` = list(),
#' Initialize a new FormatTest class.
#'
#' @description
#' Initialize a new FormatTest class.
#'
#' @param number number
#' @param byte byte
#' @param date date
#' @param password password
#' @param integer integer
#' @param int32 int32
#' @param int64 int64
#' @param float float
#' @param double double
#' @param string string
#' @param binary binary
#' @param dateTime dateTime. Default to "2015-10-28T14:38:02Z".
#' @param uuid uuid
#' @param pattern_with_digits A string that is a 10 digit number. Can have leading zeros.
#' @param pattern_with_digits_and_delimiter A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
#' @param additional_properties additonal properties (optional)
#' @param ... Other optional arguments.
#' @export
initialize = function(`number`, `byte`, `date`, `password`, `integer` = NULL, `int32` = NULL, `int64` = NULL, `float` = NULL, `double` = NULL, `string` = NULL, `binary` = NULL, `dateTime` = "2015-10-28T14:38:02Z", `uuid` = NULL, `pattern_with_digits` = NULL, `pattern_with_digits_and_delimiter` = NULL, additional_properties = NULL, ...) {
if (!missing(`number`)) {
self$`number` <- `number`
}
if (!missing(`byte`)) {
self$`byte` <- `byte`
}
if (!missing(`date`)) {
if (!is.character(`date`)) {
stop(paste("Error! Invalid Date. Must be a string:", `date`))
}
self$`date` <- `date`
}
if (!missing(`password`)) {
stopifnot(is.character(`password`), length(`password`) == 1)
self$`password` <- `password`
}
if (!is.null(`integer`)) {
stopifnot(is.numeric(`integer`), length(`integer`) == 1)
self$`integer` <- `integer`
}
if (!is.null(`int32`)) {
stopifnot(is.numeric(`int32`), length(`int32`) == 1)
self$`int32` <- `int32`
}
if (!is.null(`int64`)) {
stopifnot(is.numeric(`int64`), length(`int64`) == 1)
self$`int64` <- `int64`
}
if (!is.null(`float`)) {
stopifnot(is.numeric(`float`), length(`float`) == 1)
self$`float` <- `float`
}
if (!is.null(`double`)) {
stopifnot(is.numeric(`double`), length(`double`) == 1)
self$`double` <- `double`
}
if (!is.null(`string`)) {
stopifnot(is.character(`string`), length(`string`) == 1)
self$`string` <- `string`
}
if (!is.null(`binary`)) {
self$`binary` <- `binary`
}
if (!is.null(`dateTime`)) {
if (!is.character(`dateTime`)) {
stop(paste("Error! Invalid DateTime. Must be a string:", `dateTime`))
}
self$`dateTime` <- `dateTime`
}
if (!is.null(`uuid`)) {
stopifnot(is.character(`uuid`), length(`uuid`) == 1)
self$`uuid` <- `uuid`
}
if (!is.null(`pattern_with_digits`)) {
stopifnot(is.character(`pattern_with_digits`), length(`pattern_with_digits`) == 1)
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)
self$`pattern_with_digits_and_delimiter` <- `pattern_with_digits_and_delimiter`
}
if (!is.null(additional_properties)) {
for (key in names(additional_properties)) {
self$additional_properties[[key]] <- additional_properties[[key]]
}
}
},
#' To JSON string
#'
#' @description
#' To JSON String
#'
#' @return FormatTest in JSON format
#' @export
toJSON = function() {
FormatTestObject <- list()
if (!is.null(self$`integer`)) {
FormatTestObject[["integer"]] <-
self$`integer`
}
if (!is.null(self$`int32`)) {
FormatTestObject[["int32"]] <-
self$`int32`
}
if (!is.null(self$`int64`)) {
FormatTestObject[["int64"]] <-
self$`int64`
}
if (!is.null(self$`number`)) {
FormatTestObject[["number"]] <-
self$`number`
}
if (!is.null(self$`float`)) {
FormatTestObject[["float"]] <-
self$`float`
}
if (!is.null(self$`double`)) {
FormatTestObject[["double"]] <-
self$`double`
}
if (!is.null(self$`string`)) {
FormatTestObject[["string"]] <-
self$`string`
}
if (!is.null(self$`byte`)) {
FormatTestObject[["byte"]] <-
self$`byte`
}
if (!is.null(self$`binary`)) {
FormatTestObject[["binary"]] <-
self$`binary`
}
if (!is.null(self$`date`)) {
FormatTestObject[["date"]] <-
self$`date`
}
if (!is.null(self$`dateTime`)) {
FormatTestObject[["dateTime"]] <-
self$`dateTime`
}
if (!is.null(self$`uuid`)) {
FormatTestObject[["uuid"]] <-
self$`uuid`
}
if (!is.null(self$`password`)) {
FormatTestObject[["password"]] <-
self$`password`
}
if (!is.null(self$`pattern_with_digits`)) {
FormatTestObject[["pattern_with_digits"]] <-
self$`pattern_with_digits`
}
if (!is.null(self$`pattern_with_digits_and_delimiter`)) {
FormatTestObject[["pattern_with_digits_and_delimiter"]] <-
self$`pattern_with_digits_and_delimiter`
}
for (key in names(self$additional_properties)) {
FormatTestObject[[key]] <- self$additional_properties[[key]]
}
FormatTestObject
},
#' Deserialize JSON string into an instance of FormatTest
#'
#' @description
#' Deserialize JSON string into an instance of FormatTest
#'
#' @param input_json the JSON input
#' @return the instance of FormatTest
#' @export
fromJSON = function(input_json) {
this_object <- jsonlite::fromJSON(input_json)
if (!is.null(this_object$`integer`)) {
self$`integer` <- this_object$`integer`
}
if (!is.null(this_object$`int32`)) {
self$`int32` <- this_object$`int32`
}
if (!is.null(this_object$`int64`)) {
self$`int64` <- this_object$`int64`
}
if (!is.null(this_object$`number`)) {
self$`number` <- this_object$`number`
}
if (!is.null(this_object$`float`)) {
self$`float` <- this_object$`float`
}
if (!is.null(this_object$`double`)) {
self$`double` <- this_object$`double`
}
if (!is.null(this_object$`string`)) {
self$`string` <- this_object$`string`
}
if (!is.null(this_object$`byte`)) {
self$`byte` <- this_object$`byte`
}
if (!is.null(this_object$`binary`)) {
self$`binary` <- this_object$`binary`
}
if (!is.null(this_object$`date`)) {
self$`date` <- this_object$`date`
}
if (!is.null(this_object$`dateTime`)) {
self$`dateTime` <- this_object$`dateTime`
}
if (!is.null(this_object$`uuid`)) {
self$`uuid` <- this_object$`uuid`
}
if (!is.null(this_object$`password`)) {
self$`password` <- this_object$`password`
}
if (!is.null(this_object$`pattern_with_digits`)) {
self$`pattern_with_digits` <- this_object$`pattern_with_digits`
}
if (!is.null(this_object$`pattern_with_digits_and_delimiter`)) {
self$`pattern_with_digits_and_delimiter` <- this_object$`pattern_with_digits_and_delimiter`
}
# process additional properties/fields in the payload
for (key in names(this_object)) {
if (!(key %in% self$`_field_list`)) { # json key not in list of fields
self$additional_properties[[key]] <- this_object[[key]]
}
}
self
},
#' To JSON string
#'
#' @description
#' To JSON String
#'
#' @return FormatTest in JSON format
#' @export
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`integer`)) {
sprintf(
'"integer":
%d
',
self$`integer`
)
},
if (!is.null(self$`int32`)) {
sprintf(
'"int32":
%d
',
self$`int32`
)
},
if (!is.null(self$`int64`)) {
sprintf(
'"int64":
%d
',
self$`int64`
)
},
if (!is.null(self$`number`)) {
sprintf(
'"number":
%d
',
self$`number`
)
},
if (!is.null(self$`float`)) {
sprintf(
'"float":
%d
',
self$`float`
)
},
if (!is.null(self$`double`)) {
sprintf(
'"double":
%d
',
self$`double`
)
},
if (!is.null(self$`string`)) {
sprintf(
'"string":
"%s"
',
self$`string`
)
},
if (!is.null(self$`byte`)) {
sprintf(
'"byte":
"%s"
',
self$`byte`
)
},
if (!is.null(self$`binary`)) {
sprintf(
'"binary":
"%s"
',
self$`binary`
)
},
if (!is.null(self$`date`)) {
sprintf(
'"date":
"%s"
',
self$`date`
)
},
if (!is.null(self$`dateTime`)) {
sprintf(
'"dateTime":
"%s"
',
self$`dateTime`
)
},
if (!is.null(self$`uuid`)) {
sprintf(
'"uuid":
"%s"
',
self$`uuid`
)
},
if (!is.null(self$`password`)) {
sprintf(
'"password":
"%s"
',
self$`password`
)
},
if (!is.null(self$`pattern_with_digits`)) {
sprintf(
'"pattern_with_digits":
"%s"
',
self$`pattern_with_digits`
)
},
if (!is.null(self$`pattern_with_digits_and_delimiter`)) {
sprintf(
'"pattern_with_digits_and_delimiter":
"%s"
',
self$`pattern_with_digits_and_delimiter`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]]
}
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA)))
},
#' Deserialize JSON string into an instance of FormatTest
#'
#' @description
#' Deserialize JSON string into an instance of FormatTest
#'
#' @param input_json the JSON input
#' @return the instance of FormatTest
#' @export
fromJSONString = function(input_json) {
this_object <- jsonlite::fromJSON(input_json)
self$`integer` <- this_object$`integer`
self$`int32` <- this_object$`int32`
self$`int64` <- this_object$`int64`
self$`number` <- this_object$`number`
self$`float` <- this_object$`float`
self$`double` <- this_object$`double`
self$`string` <- this_object$`string`
self$`byte` <- this_object$`byte`
self$`binary` <- this_object$`binary`
self$`date` <- this_object$`date`
self$`dateTime` <- this_object$`dateTime`
self$`uuid` <- this_object$`uuid`
self$`password` <- this_object$`password`
self$`pattern_with_digits` <- this_object$`pattern_with_digits`
self$`pattern_with_digits_and_delimiter` <- this_object$`pattern_with_digits_and_delimiter`
# process additional properties/fields in the payload
for (key in names(this_object)) {
if (!(key %in% self$`_field_list`)) { # json key not in list of fields
self$additional_properties[[key]] <- this_object[[key]]
}
}
self
},
#' Validate JSON input with respect to FormatTest
#'
#' @description
#' Validate JSON input with respect to FormatTest and throw an exception if invalid
#'
#' @param input the JSON input
#' @export
validateJSON = function(input) {
input_json <- jsonlite::fromJSON(input)
# check the required field `number`
if (!is.null(input_json$`number`)) {
} else {
stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `number` is missing."))
}
# check the required field `byte`
if (!is.null(input_json$`byte`)) {
} else {
stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `byte` is missing."))
}
# check the required field `date`
if (!is.null(input_json$`date`)) {
stopifnot(is.character(input_json$`date`), length(input_json$`date`) == 1)
} 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)
} else {
stop(paste("The JSON input `", input, "` is invalid for FormatTest: the required field `password` is missing."))
}
},
#' To string (JSON format)
#'
#' @description
#' To string (JSON format)
#'
#' @return String representation of FormatTest
#' @export
toString = function() {
self$toJSONString()
},
#' Return true if the values in all fields are valid.
#'
#' @description
#' Return true if the values in all fields are valid.
#'
#' @return true if the values in all fields are valid.
#' @export
isValid = function() {
if (self$`integer` > 100) {
return(FALSE)
}
if (self$`integer` < 10) {
return(FALSE)
}
if (self$`int32` > 200) {
return(FALSE)
}
if (self$`int32` < 20) {
return(FALSE)
}
# check if the required `number` is null
if (is.null(self$`number`)) {
return(FALSE)
}
if (self$`number` > 543.2) {
return(FALSE)
}
if (self$`number` < 32.1) {
return(FALSE)
}
if (self$`float` > 987.6) {
return(FALSE)
}
if (self$`float` < 54.3) {
return(FALSE)
}
if (self$`double` > 123.4) {
return(FALSE)
}
if (self$`double` < 67.8) {
return(FALSE)
}
if (!str_detect(self$`string`, "[a-z]/i")) {
return(FALSE)
}
# check if the required `byte` is null
if (is.null(self$`byte`)) {
return(FALSE)
}
# check if the required `date` is null
if (is.null(self$`date`)) {
return(FALSE)
}
# check if the required `password` is null
if (is.null(self$`password`)) {
return(FALSE)
}
if (nchar(self$`password`) > 64) {
return(FALSE)
}
if (nchar(self$`password`) < 10) {
return(FALSE)
}
if (!str_detect(self$`pattern_with_digits`, "^\\d{10}$")) {
return(FALSE)
}
if (!str_detect(self$`pattern_with_digits_and_delimiter`, "^image_\\d{1,3}$/i")) {
return(FALSE)
}
TRUE
},
#' Return a list of invalid fields (if any).
#'
#' @description
#' Return a list of invalid fields (if any).
#'
#' @return A list of invalid fields (if any).
#' @export
getInvalidFields = function() {
invalid_fields <- list()
if (self$`integer` > 100) {
invalid_fields["integer"] <- "Invalid value for `integer`, must be smaller than or equal to 100."
}
if (self$`integer` < 10) {
invalid_fields["integer"] <- "Invalid value for `integer`, must be bigger than or equal to 10."
}
if (self$`int32` > 200) {
invalid_fields["int32"] <- "Invalid value for `int32`, must be smaller than or equal to 200."
}
if (self$`int32` < 20) {
invalid_fields["int32"] <- "Invalid value for `int32`, must be bigger than or equal to 20."
}
# check if the required `number` is null
if (is.null(self$`number`)) {
invalid_fields["number"] <- "Non-nullable required field `number` cannot be null."
}
if (self$`number` > 543.2) {
invalid_fields["number"] <- "Invalid value for `number`, must be smaller than or equal to 543.2."
}
if (self$`number` < 32.1) {
invalid_fields["number"] <- "Invalid value for `number`, must be bigger than or equal to 32.1."
}
if (self$`float` > 987.6) {
invalid_fields["float"] <- "Invalid value for `float`, must be smaller than or equal to 987.6."
}
if (self$`float` < 54.3) {
invalid_fields["float"] <- "Invalid value for `float`, must be bigger than or equal to 54.3."
}
if (self$`double` > 123.4) {
invalid_fields["double"] <- "Invalid value for `double`, must be smaller than or equal to 123.4."
}
if (self$`double` < 67.8) {
invalid_fields["double"] <- "Invalid value for `double`, must be bigger than or equal to 67.8."
}
if (!str_detect(self$`string`, "[a-z]/i")) {
invalid_fields["string"] <- "Invalid value for `string`, must conform to the pattern [a-z]/i."
}
# check if the required `byte` is null
if (is.null(self$`byte`)) {
invalid_fields["byte"] <- "Non-nullable required field `byte` cannot be null."
}
# check if the required `date` is null
if (is.null(self$`date`)) {
invalid_fields["date"] <- "Non-nullable required field `date` cannot be null."
}
# check if the required `password` is null
if (is.null(self$`password`)) {
invalid_fields["password"] <- "Non-nullable required field `password` cannot be null."
}
if (nchar(self$`password`) > 64) {
invalid_fields["password"] <- "Invalid length for `password`, must be smaller than or equal to 64."
}
if (nchar(self$`password`) < 10) {
invalid_fields["password"] <- "Invalid length for `password`, must be bigger than or equal to 10."
}
if (!str_detect(self$`pattern_with_digits`, "^\\d{10}$")) {
invalid_fields["pattern_with_digits"] <- "Invalid value for `pattern_with_digits`, must conform to the pattern ^\\d{10}$."
}
if (!str_detect(self$`pattern_with_digits_and_delimiter`, "^image_\\d{1,3}$/i")) {
invalid_fields["pattern_with_digits_and_delimiter"] <- "Invalid value for `pattern_with_digits_and_delimiter`, must conform to the pattern ^image_\\d{1,3}$/i."
}
invalid_fields
},
#' Print the object
#'
#' @description
#' Print the object
#'
#' @export
print = function() {
print(jsonlite::prettify(self$toJSONString()))
invisible(self)
}
),
# Lock the class to prevent modifications to the method or field
lock_class = TRUE
)
## Uncomment below to unlock the class to allow modifications of the method or field
# FormatTest$unlock()
#
## Below is an example to define the print fnuction
# FormatTest$set("public", "print", function(...) {
# print(jsonlite::prettify(self$toJSONString()))
# invisible(self)
# })
## Uncomment below to lock the class to prevent modifications to the method or field
# FormatTest$lock()

View File

@ -57,7 +57,9 @@ Order <- R6::R6Class(
self$`quantity` <- `quantity`
}
if (!is.null(`shipDate`)) {
stopifnot(is.character(`shipDate`), length(`shipDate`) == 1)
if (!is.character(`shipDate`)) {
stop(paste("Error! Invalid DateTime. Must be a string:", `shipDate`))
}
self$`shipDate` <- `shipDate`
}
if (!is.null(`status`)) {

View File

@ -115,6 +115,7 @@ Class | Method | HTTP request | Description
- [Date](docs/Date.md)
- [Dog](docs/Dog.md)
- [DogAllOf](docs/DogAllOf.md)
- [FormatTest](docs/FormatTest.md)
- [Mammal](docs/Mammal.md)
- [ModelApiResponse](docs/ModelApiResponse.md)
- [NestedOneOf](docs/NestedOneOf.md)

View File

@ -0,0 +1,23 @@
# petstore::FormatTest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**integer** | **integer** | | [optional] [Max: 100] [Min: 10]
**int32** | **integer** | | [optional] [Max: 200] [Min: 20]
**int64** | **integer** | | [optional]
**number** | **numeric** | | [Max: 543.2] [Min: 32.1]
**float** | **numeric** | | [optional] [Max: 987.6] [Min: 54.3]
**double** | **numeric** | | [optional] [Max: 123.4] [Min: 67.8]
**string** | **character** | | [optional] [Pattern: [a-z]/i]
**byte** | **character** | |
**binary** | **data.frame** | | [optional]
**date** | **character** | | [default to &quot;Fri Jul 19 00:00:00 UTC 2019&quot;]
**dateTime** | **character** | | [optional] [default to &quot;2015-10-28T14:38:02Z&quot;]
**uuid** | **character** | | [optional]
**password** | **character** | | [Max. length: 64] [Min. length: 10]
**pattern_with_digits** | **character** | A string that is a 10 digit number. Can have leading zeros. | [optional] [Pattern: ^\\d{10}$]
**pattern_with_digits_and_delimiter** | **character** | A string starting with &#39;image_&#39; (case insensitive) and one to three digits following i.e. Image_01. | [optional] [Pattern: ^image_\\d{1,3}$/i]

View File

@ -0,0 +1,113 @@
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
context("Test FormatTest")
model_instance <- FormatTest$new()
test_that("integer", {
# tests for the property `integer` (integer)
# uncomment below to test the property
#expect_equal(model.instance$`integer`, "EXPECTED_RESULT")
})
test_that("int32", {
# tests for the property `int32` (integer)
# uncomment below to test the property
#expect_equal(model.instance$`int32`, "EXPECTED_RESULT")
})
test_that("int64", {
# tests for the property `int64` (integer)
# uncomment below to test the property
#expect_equal(model.instance$`int64`, "EXPECTED_RESULT")
})
test_that("number", {
# tests for the property `number` (numeric)
# uncomment below to test the property
#expect_equal(model.instance$`number`, "EXPECTED_RESULT")
})
test_that("float", {
# tests for the property `float` (numeric)
# uncomment below to test the property
#expect_equal(model.instance$`float`, "EXPECTED_RESULT")
})
test_that("double", {
# tests for the property `double` (numeric)
# uncomment below to test the property
#expect_equal(model.instance$`double`, "EXPECTED_RESULT")
})
test_that("string", {
# tests for the property `string` (character)
# uncomment below to test the property
#expect_equal(model.instance$`string`, "EXPECTED_RESULT")
})
test_that("byte", {
# tests for the property `byte` (character)
# uncomment below to test the property
#expect_equal(model.instance$`byte`, "EXPECTED_RESULT")
})
test_that("binary", {
# tests for the property `binary` (data.frame)
# uncomment below to test the property
#expect_equal(model.instance$`binary`, "EXPECTED_RESULT")
})
test_that("date", {
# tests for the property `date` (character)
# uncomment below to test the property
#expect_equal(model.instance$`date`, "EXPECTED_RESULT")
})
test_that("dateTime", {
# tests for the property `dateTime` (character)
# uncomment below to test the property
#expect_equal(model.instance$`dateTime`, "EXPECTED_RESULT")
})
test_that("uuid", {
# tests for the property `uuid` (character)
# uncomment below to test the property
#expect_equal(model.instance$`uuid`, "EXPECTED_RESULT")
})
test_that("password", {
# tests for the property `password` (character)
# uncomment below to test the property
#expect_equal(model.instance$`password`, "EXPECTED_RESULT")
})
test_that("pattern_with_digits", {
# tests for the property `pattern_with_digits` (character)
# A string that is a 10 digit number. Can have leading zeros.
# uncomment below to test the property
#expect_equal(model.instance$`pattern_with_digits`, "EXPECTED_RESULT")
})
test_that("pattern_with_digits_and_delimiter", {
# tests for the property `pattern_with_digits_and_delimiter` (character)
# A string starting with &#39;image_&#39; (case insensitive) and one to three digits following i.e. Image_01.
# uncomment below to test the property
#expect_equal(model.instance$`pattern_with_digits_and_delimiter`, "EXPECTED_RESULT")
})