fix r body parameter null issue (#6786)

This commit is contained in:
wing328 2017-10-24 10:45:25 +08:00 committed by GitHub
parent f7471add70
commit 698149573d
10 changed files with 65 additions and 63 deletions

View File

@ -35,14 +35,15 @@
{{#operation}}
{{operationId}} = function({{#allParams}}{{paramName}}, {{/allParams}}...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
{{#hasHeaderParams}}
{{#headerParams}}
if (!missing(`{{paramName}}`)) {
headerParams['{{baseName}}'] <- `{{paramName}}`
}
{{/headerParams}}
{{/hasHeaderParams}}
{{#hasQueryParams}}
@ -50,6 +51,7 @@
if (!missing(`{{paramName}}`)) {
queryParams['{{baseName}}'] <- {{paramName}}
}
{{/queryParams}}
{{/hasQueryParams}}
{{#hasFormParams}}
@ -62,25 +64,28 @@
"{{baseName}}" = httr::upload_file({{paramName}}){{#hasMore}},{{/hasMore}}
{{/isFile}}
{{/formParams}}
)
)
{{/hasFormParams}}
{{#hasBodyParam}}
{{#bodyParams}}
if (!missing(`{{paramName}}`)) {
body <- `{{paramName}}`$toJSONString()
} else {
body <- NULL
}
{{/bodyParams}}
{{/hasBodyParam}}
urlPath <- "{{path}}"
{{#hasPathParams}}
{{#pathParams}}
if (!missing(`{{paramName}}`)) {
urlPath <- gsub(paste0("\\{", "{{baseName}}", "\\}"), `{{paramName}}`, urlPath)
}
{{/pathParams}}
{{/hasPathParams}}
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "{{httpMethod}}",
queryParams = queryParams,

View File

@ -65,9 +65,9 @@ ApiResponse <- R6::R6Class(
toJSONString = function() {
sprintf(
'{
"code": "%s",
"type": "%s",
"message": "%s"
"code": %s,
"type": %s,
"message": %s
}',
self$`code`,
self$`type`,

View File

@ -54,7 +54,7 @@ Category <- R6::R6Class(
sprintf(
'{
"id": %d,
"name": "%s"
"name": %s
}',
self$`id`,
self$`name`

View File

@ -102,10 +102,10 @@ Order <- R6::R6Class(
'{
"id": %d,
"petId": %d,
"quantity": "%s",
"shipDate": "%s",
"status": "%s",
"complete": "%s"
"quantity": %s,
"shipDate": %s,
"status": %s,
"complete": %s
}',
self$`id`,
self$`petId`,

View File

@ -111,10 +111,10 @@ Pet <- R6::R6Class(
'{
"id": %d,
"category": %s,
"name": "%s",
"photoUrls": ["%s"],
"name": %s,
"photoUrls": [%s],
"tags": [%s],
"status": "%s"
"status": %s
}',
self$`id`,
self$`category`$toJSON(),

View File

@ -59,15 +59,16 @@ PetApi <- R6::R6Class(
},
add_pet = function(body, ...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
if (!missing(`body`)) {
body <- `body`$toJSON()
body <- `body`$toJSONString()
} else {
body <- NULL
}
urlPath <- "/pet"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "POST",
queryParams = queryParams,
@ -86,9 +87,9 @@ PetApi <- R6::R6Class(
},
delete_pet = function(pet_id, api_key, ...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
if (!missing(`api_key`)) {
headerParams['api_key'] <- `api_key`
}
@ -116,15 +117,14 @@ PetApi <- R6::R6Class(
},
find_pets_by_status = function(status, ...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
if (!missing(`status`)) {
queryParams['status'] <- status
}
urlPath <- "/pet/findByStatus"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
@ -145,15 +145,14 @@ PetApi <- R6::R6Class(
},
find_pets_by_tags = function(tags, ...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
if (!missing(`tags`)) {
queryParams['tags'] <- tags
}
urlPath <- "/pet/findByTags"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
@ -174,7 +173,6 @@ PetApi <- R6::R6Class(
},
get_pet_by_id = function(pet_id, ...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
@ -203,15 +201,16 @@ PetApi <- R6::R6Class(
},
update_pet = function(body, ...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
if (!missing(`body`)) {
body <- `body`$toJSON()
body <- `body`$toJSONString()
} else {
body <- NULL
}
urlPath <- "/pet"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "PUT",
queryParams = queryParams,
@ -230,13 +229,13 @@ PetApi <- R6::R6Class(
},
update_pet_with_form = function(pet_id, name, status, ...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
body <- list(
"name" = name,
"status" = status
)
)
urlPath <- "/pet/{petId}"
if (!missing(`pet_id`)) {
@ -261,13 +260,13 @@ PetApi <- R6::R6Class(
},
upload_file = function(pet_id, additional_metadata, file, ...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
body <- list(
"additionalMetadata" = additional_metadata,
"file" = httr::upload_file(file)
)
)
urlPath <- "/pet/{petId}/uploadImage"
if (!missing(`pet_id`)) {

View File

@ -47,7 +47,6 @@ StoreApi <- R6::R6Class(
},
delete_order = function(order_id, ...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
@ -74,12 +73,10 @@ StoreApi <- R6::R6Class(
},
get_inventory = function(...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
urlPath <- "/store/inventory"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
@ -100,7 +97,6 @@ StoreApi <- R6::R6Class(
},
get_order_by_id = function(order_id, ...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
@ -129,15 +125,16 @@ StoreApi <- R6::R6Class(
},
place_order = function(body, ...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
if (!missing(`body`)) {
body <- `body`$toJSON()
body <- `body`$toJSONString()
} else {
body <- NULL
}
urlPath <- "/store/order"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "POST",
queryParams = queryParams,

View File

@ -54,7 +54,7 @@ Tag <- R6::R6Class(
sprintf(
'{
"id": %d,
"name": "%s"
"name": %s
}',
self$`id`,
self$`name`

View File

@ -126,13 +126,13 @@ User <- R6::R6Class(
sprintf(
'{
"id": %d,
"username": "%s",
"firstName": "%s",
"lastName": "%s",
"email": "%s",
"password": "%s",
"phone": "%s",
"userStatus": "%s"
"username": %s,
"firstName": %s,
"lastName": %s,
"email": %s,
"password": %s,
"phone": %s,
"userStatus": %s
}',
self$`id`,
self$`username`,

View File

@ -59,15 +59,16 @@ UserApi <- R6::R6Class(
},
create_user = function(body, ...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
if (!missing(`body`)) {
body <- `body`$toJSON()
body <- `body`$toJSONString()
} else {
body <- NULL
}
urlPath <- "/user"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "POST",
queryParams = queryParams,
@ -86,15 +87,16 @@ UserApi <- R6::R6Class(
},
create_users_with_array_input = function(body, ...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
if (!missing(`body`)) {
body <- `body`$toJSON()
body <- `body`$toJSONString()
} else {
body <- NULL
}
urlPath <- "/user/createWithArray"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "POST",
queryParams = queryParams,
@ -113,15 +115,16 @@ UserApi <- R6::R6Class(
},
create_users_with_list_input = function(body, ...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
if (!missing(`body`)) {
body <- `body`$toJSON()
body <- `body`$toJSONString()
} else {
body <- NULL
}
urlPath <- "/user/createWithList"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "POST",
queryParams = queryParams,
@ -140,7 +143,6 @@ UserApi <- R6::R6Class(
},
delete_user = function(username, ...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
@ -167,7 +169,6 @@ UserApi <- R6::R6Class(
},
get_user_by_name = function(username, ...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
@ -196,18 +197,18 @@ UserApi <- R6::R6Class(
},
login_user = function(username, password, ...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
if (!missing(`username`)) {
queryParams['username'] <- username
}
if (!missing(`password`)) {
queryParams['password'] <- password
}
urlPath <- "/user/login"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
@ -228,12 +229,10 @@ UserApi <- R6::R6Class(
},
logout_user = function(...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
urlPath <- "/user/logout"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
@ -252,11 +251,13 @@ UserApi <- R6::R6Class(
},
update_user = function(username, body, ...){
args <- list(...)
body <- NULL
queryParams <- list()
headerParams <- character()
if (!missing(`body`)) {
body <- `body`$toJSON()
body <- `body`$toJSONString()
} else {
body <- NULL
}
urlPath <- "/user/{username}"