Skip to content

Commit 4c7a454

Browse files
committed
handle isNullable when checking api parameters
1 parent 1d7111f commit 4c7a454

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

modules/openapi-generator/src/main/resources/r/api.mustache

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,19 @@
206206
207207
{{/requiredParams}}
208208
{{#allParams}}
209+
{{^isNullable}}
210+
if (is.null(`{{paramName}}`)) {
211+
{{#useDefaultExceptionHandling}}
212+
stop("Invalid value for `{{paramName}}` when calling {{classname}}${{operationId}}, `{{paramName}}` is not nullable")
213+
{{/useDefaultExceptionHandling}}
214+
{{#useRlangExceptionHandling}}
215+
rlang::abort(message = "Invalid value for `{{paramName}}` when calling {{classname}}${{operationId}}, `{{paramName}}` is not nullable",
216+
.subclass = "ApiException",
217+
ApiException = ApiException$new(status = 0,
218+
reason = "Invalid value for `{{paramName}}` when calling {{classname}}${{operationId}}, `{{paramName}}` is not nullable"))
219+
{{/useRlangExceptionHandling}}
220+
}
221+
{{/isNullable}}
209222
{{#maxLength}}
210223
if (!is.null(`{{paramName}}`) && nchar(`{{paramName}}`) > {{maxLength}}) {
211224
{{#useDefaultExceptionHandling}}

0 commit comments

Comments
 (0)