forked from loafle/openapi-generator-original
[R][Client] allow to initialize enum classes without parameters (#18183)
* allow empty initialization of enum classes * regenerate samples
This commit is contained in:
parent
ed8b7ec7f6
commit
2600eb92dc
@ -21,11 +21,21 @@
|
|||||||
val <- unlist(local.optional.var)
|
val <- unlist(local.optional.var)
|
||||||
enumvec <- .parse_{{name}}()
|
enumvec <- .parse_{{name}}()
|
||||||
|
|
||||||
|
if (length(val) == 0L) {
|
||||||
|
val = "DUMMY_ENUM"
|
||||||
|
} else {
|
||||||
stopifnot(length(val) == 1L)
|
stopifnot(length(val) == 1L)
|
||||||
|
}
|
||||||
|
|
||||||
if (!val %in% enumvec)
|
if (!val %in% enumvec) {
|
||||||
|
if (!(val=="DUMMY_ENUM")) {
|
||||||
stop("Use one of the valid values: ",
|
stop("Use one of the valid values: ",
|
||||||
paste0(enumvec, collapse = ", "))
|
paste0(enumvec, collapse = ", "))
|
||||||
|
}
|
||||||
|
warning("Initializing {{{classname}}} with DUMMY_ENUM. Use one of the valid values: ",
|
||||||
|
paste0(enumvec, collapse = ", "),
|
||||||
|
". If you did not manually initialize {{{classname}}}, this may already be overwritten by an enum loaded from a JSON config.")
|
||||||
|
}
|
||||||
private$value <- val
|
private$value <- val
|
||||||
},
|
},
|
||||||
#' To JSON string
|
#' To JSON string
|
||||||
|
@ -20,11 +20,21 @@ StringEnumRef <- R6::R6Class(
|
|||||||
val <- unlist(local.optional.var)
|
val <- unlist(local.optional.var)
|
||||||
enumvec <- .parse_StringEnumRef()
|
enumvec <- .parse_StringEnumRef()
|
||||||
|
|
||||||
|
if (length(val) == 0L) {
|
||||||
|
val = "DUMMY_ENUM"
|
||||||
|
} else {
|
||||||
stopifnot(length(val) == 1L)
|
stopifnot(length(val) == 1L)
|
||||||
|
}
|
||||||
|
|
||||||
if (!val %in% enumvec)
|
if (!val %in% enumvec) {
|
||||||
|
if (!(val=="DUMMY_ENUM")) {
|
||||||
stop("Use one of the valid values: ",
|
stop("Use one of the valid values: ",
|
||||||
paste0(enumvec, collapse = ", "))
|
paste0(enumvec, collapse = ", "))
|
||||||
|
}
|
||||||
|
warning("Initializing StringEnumRef with DUMMY_ENUM. Use one of the valid values: ",
|
||||||
|
paste0(enumvec, collapse = ", "),
|
||||||
|
". If you did not manually initialize StringEnumRef, this may already be overwritten by an enum loaded from a JSON config.")
|
||||||
|
}
|
||||||
private$value <- val
|
private$value <- val
|
||||||
},
|
},
|
||||||
#' To JSON string
|
#' To JSON string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user