Skip to content

Commit 7644f3e

Browse files
robertpykewing328Robert Pyke
authored
[R] Bug - Invalid code generated for POST with no request object (#8067)
* Default body to NULL * update samples * Update to set body to NULL only when no hasBodyParam * Revert any whitespace changes. * Makes defaulting body conditional on hasFormParams also not being set Co-authored-by: William Cheng <[email protected]> Co-authored-by: Robert Pyke <[email protected]>
1 parent ebac0a8 commit 7644f3e

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@
226226
227227
{{/bodyParams}}
228228
{{/hasBodyParam}}
229+
{{^hasBodyParam}}
230+
{{^hasFormParams}}
231+
body <- NULL
232+
{{/hasFormParams}}
233+
{{/hasBodyParam}}
229234
urlPath <- "{{path}}"
230235
{{#hasPathParams}}
231236
{{#pathParams}}

samples/client/petstore/R/R/pet_api.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ PetApi <- R6::R6Class(
406406

407407
headerParams['api_key'] <- `api.key`
408408

409+
body <- NULL
409410
urlPath <- "/pet/{petId}"
410411
if (!missing(`pet.id`)) {
411412
urlPath <- gsub(paste0("\\{", "petId", "\\}"), URLencode(as.character(`pet.id`), reserved = TRUE), urlPath)
@@ -456,6 +457,7 @@ PetApi <- R6::R6Class(
456457

457458
queryParams['status'] <- status
458459

460+
body <- NULL
459461
urlPath <- "/pet/findByStatus"
460462
# OAuth token
461463
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
@@ -508,6 +510,7 @@ PetApi <- R6::R6Class(
508510

509511
queryParams['tags'] <- tags
510512

513+
body <- NULL
511514
urlPath <- "/pet/findByTags"
512515
# OAuth token
513516
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
@@ -558,6 +561,7 @@ PetApi <- R6::R6Class(
558561
stop("Missing required parameter `pet.id`.")
559562
}
560563

564+
body <- NULL
561565
urlPath <- "/pet/{petId}"
562566
if (!missing(`pet.id`)) {
563567
urlPath <- gsub(paste0("\\{", "petId", "\\}"), URLencode(as.character(`pet.id`), reserved = TRUE), urlPath)

samples/client/petstore/R/R/store_api.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ StoreApi <- R6::R6Class(
197197
stop("Missing required parameter `order.id`.")
198198
}
199199

200+
body <- NULL
200201
urlPath <- "/store/order/{orderId}"
201202
if (!missing(`order.id`)) {
202203
urlPath <- gsub(paste0("\\{", "orderId", "\\}"), URLencode(as.character(`order.id`), reserved = TRUE), urlPath)
@@ -239,6 +240,7 @@ StoreApi <- R6::R6Class(
239240
queryParams <- list()
240241
headerParams <- c()
241242

243+
body <- NULL
242244
urlPath <- "/store/inventory"
243245
# API key authentication
244246
if ("api_key" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["api_key"]) > 0) {
@@ -291,6 +293,7 @@ StoreApi <- R6::R6Class(
291293
stop("Missing required parameter `order.id`.")
292294
}
293295

296+
body <- NULL
294297
urlPath <- "/store/order/{orderId}"
295298
if (!missing(`order.id`)) {
296299
urlPath <- gsub(paste0("\\{", "orderId", "\\}"), URLencode(as.character(`order.id`), reserved = TRUE), urlPath)

samples/client/petstore/R/R/user_api.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ UserApi <- R6::R6Class(
460460
stop("Missing required parameter `username`.")
461461
}
462462

463+
body <- NULL
463464
urlPath <- "/user/{username}"
464465
if (!missing(`username`)) {
465466
urlPath <- gsub(paste0("\\{", "username", "\\}"), URLencode(as.character(`username`), reserved = TRUE), urlPath)
@@ -506,6 +507,7 @@ UserApi <- R6::R6Class(
506507
stop("Missing required parameter `username`.")
507508
}
508509

510+
body <- NULL
509511
urlPath <- "/user/{username}"
510512
if (!missing(`username`)) {
511513
urlPath <- gsub(paste0("\\{", "username", "\\}"), URLencode(as.character(`username`), reserved = TRUE), urlPath)
@@ -566,6 +568,7 @@ UserApi <- R6::R6Class(
566568

567569
queryParams['password'] <- password
568570

571+
body <- NULL
569572
urlPath <- "/user/login"
570573

571574
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
@@ -610,6 +613,7 @@ UserApi <- R6::R6Class(
610613
queryParams <- list()
611614
headerParams <- c()
612615

616+
body <- NULL
613617
urlPath <- "/user/logout"
614618

615619
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),

0 commit comments

Comments
 (0)