forked from loafle/openapi-generator-original
better enum status validation (#13486)
This commit is contained in:
@@ -34,6 +34,9 @@ Zebra <- R6::R6Class(
|
||||
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)
|
||||
self$`type` <- `type`
|
||||
}
|
||||
@@ -68,6 +71,9 @@ Zebra <- R6::R6Class(
|
||||
fromJSON = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
if (!is.null(this_object$`type`)) {
|
||||
if (!is.null(this_object$`type`) && !(this_object$`type` %in% c("plains", "mountain", "grevys"))) {
|
||||
stop(paste("Error! \"", this_object$`type`, "\" cannot be assigned to `type`. Must be \"plains\", \"mountain\", \"grevys\".", sep = ""))
|
||||
}
|
||||
self$`type` <- this_object$`type`
|
||||
}
|
||||
if (!is.null(this_object$`className`)) {
|
||||
@@ -114,6 +120,9 @@ Zebra <- R6::R6Class(
|
||||
#' @export
|
||||
fromJSONString = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
if (!is.null(this_object$`type`) && !(this_object$`type` %in% c("plains", "mountain", "grevys"))) {
|
||||
stop(paste("Error! \"", this_object$`type`, "\" cannot be assigned to `type`. Must be \"plains\", \"mountain\", \"grevys\".", sep = ""))
|
||||
}
|
||||
self$`type` <- this_object$`type`
|
||||
self$`className` <- this_object$`className`
|
||||
self
|
||||
|
||||
Reference in New Issue
Block a user