From 97ddcc2257e77cae47f90c08b5491a5929769c3c Mon Sep 17 00:00:00 2001 From: Steffen Neumann Date: Sat, 15 May 2021 17:22:48 +0200 Subject: [PATCH] Add support for Boolean in R client generator (#9469) * Add support for Boolean in R client generator * Regenerated with updated R generator --- .../src/main/resources/r/model.mustache | 13 +++++++++---- samples/client/petstore/R/R/category.R | 1 - samples/client/petstore/R/R/model_api_response.R | 1 - samples/client/petstore/R/R/order.R | 6 +++--- samples/client/petstore/R/R/pet.R | 1 - samples/client/petstore/R/R/tag.R | 1 - samples/client/petstore/R/R/user.R | 1 - 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/r/model.mustache b/modules/openapi-generator/src/main/resources/r/model.mustache index 1b853ec3730..28b7ce9145b 100644 --- a/modules/openapi-generator/src/main/resources/r/model.mustache +++ b/modules/openapi-generator/src/main/resources/r/model.mustache @@ -47,6 +47,9 @@ {{#isString}} stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1) {{/isString}} + {{#isBoolean}} + stopifnot(is.logical(`{{baseName}}`), length(`{{baseName}}`) == 1) + {{/isBoolean}} {{#isDate}} stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1) {{/isDate}} @@ -88,6 +91,9 @@ {{#isString}} stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1) {{/isString}} + {{#isBoolean}} + stopifnot(is.logical(`{{baseName}}`), length(`{{baseName}}`) == 1) + {{/isBoolean}} {{#isDate}} stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1) {{/isDate}} @@ -185,7 +191,7 @@ {{/isArray}} {{#isMap}} {{#isPrimitiveType}} - {{#isNumeric}}%d{{/isNumeric}}{{^isNumeric}}"%s"{{/isNumeric}} + {{#isNumeric}}%d{{/isNumeric}}{{^isNumeric}}{{^isBoolean}}"{{/isBoolean}}%s{{^isBoolean}}"{{/isBoolean}}{{/isNumeric}} {{/isPrimitiveType}} {{^isPrimitiveType}}%s {{/isPrimitiveType}} @@ -193,7 +199,7 @@ {{/isContainer}} {{^isContainer}} {{#isPrimitiveType}} - {{#isNumeric}}%d{{/isNumeric}}{{^isNumeric}}"%s"{{/isNumeric}} + {{#isNumeric}}%d{{/isNumeric}}{{^isNumeric}}{{^isBoolean}}"{{/isBoolean}}%s{{^isBoolean}}"{{/isBoolean}}{{/isNumeric}} {{/isPrimitiveType}} {{^isPrimitiveType}}%s {{/isPrimitiveType}} @@ -218,7 +224,7 @@ {{/isContainer}} {{^isContainer}} {{#isPrimitiveType}} - self$`{{baseName}}` + {{#isBoolean}}tolower({{/isBoolean}}self$`{{baseName}}`{{#isBoolean}}){{/isBoolean}} {{/isPrimitiveType}} {{^isPrimitiveType}} jsonlite::toJSON(self$`{{baseName}}`$toJSON(), auto_unbox=TRUE, digits = NA) @@ -253,4 +259,3 @@ {{/isEnum}} {{/model}} {{/models}} - diff --git a/samples/client/petstore/R/R/category.R b/samples/client/petstore/R/R/category.R index 7c74320d1ac..059b64e3748 100644 --- a/samples/client/petstore/R/R/category.R +++ b/samples/client/petstore/R/R/category.R @@ -89,4 +89,3 @@ Category <- R6::R6Class( } ) ) - diff --git a/samples/client/petstore/R/R/model_api_response.R b/samples/client/petstore/R/R/model_api_response.R index c7cdbb76c2a..a1c16133557 100644 --- a/samples/client/petstore/R/R/model_api_response.R +++ b/samples/client/petstore/R/R/model_api_response.R @@ -111,4 +111,3 @@ ModelApiResponse <- R6::R6Class( } ) ) - diff --git a/samples/client/petstore/R/R/order.R b/samples/client/petstore/R/R/order.R index 3218835cc35..d3e2e46b493 100644 --- a/samples/client/petstore/R/R/order.R +++ b/samples/client/petstore/R/R/order.R @@ -62,6 +62,7 @@ Order <- R6::R6Class( self$`status` <- `status` } if (!is.null(`complete`)) { + stopifnot(is.logical(`complete`), length(`complete`) == 1) self$`complete` <- `complete` } }, @@ -156,9 +157,9 @@ Order <- R6::R6Class( if (!is.null(self$`complete`)) { sprintf( '"complete": - "%s" + %s ', - self$`complete` + tolower(self$`complete`) )} ) jsoncontent <- paste(jsoncontent, collapse = ",") @@ -176,4 +177,3 @@ Order <- R6::R6Class( } ) ) - diff --git a/samples/client/petstore/R/R/pet.R b/samples/client/petstore/R/R/pet.R index 509d16934e1..1960b16906a 100644 --- a/samples/client/petstore/R/R/pet.R +++ b/samples/client/petstore/R/R/pet.R @@ -181,4 +181,3 @@ Pet <- R6::R6Class( } ) ) - diff --git a/samples/client/petstore/R/R/tag.R b/samples/client/petstore/R/R/tag.R index 56b89c6b425..ba2def34c43 100644 --- a/samples/client/petstore/R/R/tag.R +++ b/samples/client/petstore/R/R/tag.R @@ -89,4 +89,3 @@ Tag <- R6::R6Class( } ) ) - diff --git a/samples/client/petstore/R/R/user.R b/samples/client/petstore/R/R/user.R index bf88bee4027..47ffaea0d88 100644 --- a/samples/client/petstore/R/R/user.R +++ b/samples/client/petstore/R/R/user.R @@ -221,4 +221,3 @@ User <- R6::R6Class( } ) ) -