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)
|
||||
enumvec <- .parse_{{name}}()
|
||||
|
||||
stopifnot(length(val) == 1L)
|
||||
if (length(val) == 0L) {
|
||||
val = "DUMMY_ENUM"
|
||||
} else {
|
||||
stopifnot(length(val) == 1L)
|
||||
}
|
||||
|
||||
if (!val %in% enumvec)
|
||||
if (!val %in% enumvec) {
|
||||
if (!(val=="DUMMY_ENUM")) {
|
||||
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
|
||||
},
|
||||
#' To JSON string
|
||||
|
@ -20,11 +20,21 @@ StringEnumRef <- R6::R6Class(
|
||||
val <- unlist(local.optional.var)
|
||||
enumvec <- .parse_StringEnumRef()
|
||||
|
||||
stopifnot(length(val) == 1L)
|
||||
if (length(val) == 0L) {
|
||||
val = "DUMMY_ENUM"
|
||||
} else {
|
||||
stopifnot(length(val) == 1L)
|
||||
}
|
||||
|
||||
if (!val %in% enumvec)
|
||||
if (!val %in% enumvec) {
|
||||
if (!(val=="DUMMY_ENUM")) {
|
||||
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
|
||||
},
|
||||
#' To JSON string
|
||||
|
Loading…
x
Reference in New Issue
Block a user