[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 <wing328hk@gmail.com>
Co-authored-by: Robert Pyke <robertpyke@fb.com>
This commit is contained in:
Robert Pyke 2020-12-03 00:21:08 -08:00 committed by GitHub
parent ebac0a8ed4
commit 7644f3ee83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 0 deletions

View File

@ -226,6 +226,11 @@
{{/bodyParams}}
{{/hasBodyParam}}
{{^hasBodyParam}}
{{^hasFormParams}}
body <- NULL
{{/hasFormParams}}
{{/hasBodyParam}}
urlPath <- "{{path}}"
{{#hasPathParams}}
{{#pathParams}}

View File

@ -406,6 +406,7 @@ PetApi <- R6::R6Class(
headerParams['api_key'] <- `api.key`
body <- NULL
urlPath <- "/pet/{petId}"
if (!missing(`pet.id`)) {
urlPath <- gsub(paste0("\\{", "petId", "\\}"), URLencode(as.character(`pet.id`), reserved = TRUE), urlPath)
@ -456,6 +457,7 @@ PetApi <- R6::R6Class(
queryParams['status'] <- status
body <- NULL
urlPath <- "/pet/findByStatus"
# OAuth token
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
@ -508,6 +510,7 @@ PetApi <- R6::R6Class(
queryParams['tags'] <- tags
body <- NULL
urlPath <- "/pet/findByTags"
# OAuth token
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
@ -558,6 +561,7 @@ PetApi <- R6::R6Class(
stop("Missing required parameter `pet.id`.")
}
body <- NULL
urlPath <- "/pet/{petId}"
if (!missing(`pet.id`)) {
urlPath <- gsub(paste0("\\{", "petId", "\\}"), URLencode(as.character(`pet.id`), reserved = TRUE), urlPath)

View File

@ -197,6 +197,7 @@ StoreApi <- R6::R6Class(
stop("Missing required parameter `order.id`.")
}
body <- NULL
urlPath <- "/store/order/{orderId}"
if (!missing(`order.id`)) {
urlPath <- gsub(paste0("\\{", "orderId", "\\}"), URLencode(as.character(`order.id`), reserved = TRUE), urlPath)
@ -239,6 +240,7 @@ StoreApi <- R6::R6Class(
queryParams <- list()
headerParams <- c()
body <- NULL
urlPath <- "/store/inventory"
# API key authentication
if ("api_key" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["api_key"]) > 0) {
@ -291,6 +293,7 @@ StoreApi <- R6::R6Class(
stop("Missing required parameter `order.id`.")
}
body <- NULL
urlPath <- "/store/order/{orderId}"
if (!missing(`order.id`)) {
urlPath <- gsub(paste0("\\{", "orderId", "\\}"), URLencode(as.character(`order.id`), reserved = TRUE), urlPath)

View File

@ -460,6 +460,7 @@ UserApi <- R6::R6Class(
stop("Missing required parameter `username`.")
}
body <- NULL
urlPath <- "/user/{username}"
if (!missing(`username`)) {
urlPath <- gsub(paste0("\\{", "username", "\\}"), URLencode(as.character(`username`), reserved = TRUE), urlPath)
@ -506,6 +507,7 @@ UserApi <- R6::R6Class(
stop("Missing required parameter `username`.")
}
body <- NULL
urlPath <- "/user/{username}"
if (!missing(`username`)) {
urlPath <- gsub(paste0("\\{", "username", "\\}"), URLencode(as.character(`username`), reserved = TRUE), urlPath)
@ -566,6 +568,7 @@ UserApi <- R6::R6Class(
queryParams['password'] <- password
body <- NULL
urlPath <- "/user/login"
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
@ -610,6 +613,7 @@ UserApi <- R6::R6Class(
queryParams <- list()
headerParams <- c()
body <- NULL
urlPath <- "/user/logout"
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),