forked from loafle/openapi-generator-original
fix query parameter in r client (#13348)
This commit is contained in:
parent
513496a399
commit
f0d8c3e735
@ -381,7 +381,14 @@
|
||||
|
||||
{{/headerParams}}
|
||||
{{#queryParams}}
|
||||
{{#isArray}}
|
||||
for (query_item in `{{{paramName}}}`) {
|
||||
query_params[["{{{baseName}}}"]] <- c(query_params[["{{{baseName}}}"]], list(`{{{baseName}}}` = query_item))
|
||||
}
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
query_params["{{baseName}}"] <- `{{paramName}}`
|
||||
{{/isArray}}
|
||||
|
||||
{{/queryParams}}
|
||||
{{#hasFormParams}}
|
||||
|
@ -234,7 +234,9 @@ ApiClient <- R6::R6Class(
|
||||
}
|
||||
|
||||
## add query parameters
|
||||
req <- req %>% req_url_query(!!!query_params)
|
||||
for (query_param in query_params) {
|
||||
req <- req %>% req_url_query(!!!query_param)
|
||||
}
|
||||
|
||||
# has file upload?
|
||||
if (!is.null(file_params) && length(file_params) != 0) {
|
||||
|
@ -226,7 +226,9 @@ ApiClient <- R6::R6Class(
|
||||
}
|
||||
|
||||
## add query parameters
|
||||
req <- req %>% req_url_query(!!!query_params)
|
||||
for (query_param in query_params) {
|
||||
req <- req %>% req_url_query(!!!query_param)
|
||||
}
|
||||
|
||||
# has file upload?
|
||||
if (!is.null(file_params) && length(file_params) != 0) {
|
||||
|
@ -944,7 +944,9 @@ PetApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
|
||||
query_params["status"] <- `status`
|
||||
for (query_item in `status`) {
|
||||
query_params[["status"]] <- c(query_params[["status"]], list(`status` = query_item))
|
||||
}
|
||||
|
||||
local_var_url_path <- "/pet/findByStatus"
|
||||
# OAuth-related settings
|
||||
@ -1062,7 +1064,9 @@ PetApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
|
||||
query_params["tags"] <- `tags`
|
||||
for (query_item in `tags`) {
|
||||
query_params[["tags"]] <- c(query_params[["tags"]], list(`tags` = query_item))
|
||||
}
|
||||
|
||||
local_var_url_path <- "/pet/findByTags"
|
||||
# OAuth-related settings
|
||||
|
@ -3,6 +3,32 @@ install.packages("petstore_1.0.0.tar.gz",repos=NULL, type="source")
|
||||
library(petstore)
|
||||
library(jsonlite)
|
||||
|
||||
var_tags <- list("innerzzzzzzz", "second_example", "345") # array[character] | Tags to filter by
|
||||
|
||||
# Finds Pets by tags
|
||||
api_instance <- petstore_api$new()
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
api_instance$api_client$access_token <- Sys.getenv("ACCESS_TOKEN")
|
||||
result <- tryCatch(
|
||||
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
|
||||
# api_instance$pet_api$find_pets_by_tags(var_tags, data_file = "result.txt"),
|
||||
api_instance$pet_api$find_pets_by_tags(var_tags),
|
||||
ApiException = function(ex) ex
|
||||
)
|
||||
# In case of error, print the error object
|
||||
if (!is.null(result$ApiException)) {
|
||||
print("Exception occurs when calling `find_pets_by_tags`:")
|
||||
dput(result$ApiException$toString())
|
||||
# error object
|
||||
dput(result$ApiException$error_object$toJSONString())
|
||||
} else {
|
||||
# deserialized response object
|
||||
print("The response is ...")
|
||||
dput(result)
|
||||
}
|
||||
|
||||
invokeRestart("abort")
|
||||
|
||||
t <- Tag$new()
|
||||
t$id <- 123
|
||||
t$additional_properties <- c("abc" = 849, "array" = list('a', 'b', 'c'))
|
||||
|
@ -226,7 +226,9 @@ ApiClient <- R6::R6Class(
|
||||
}
|
||||
|
||||
## add query parameters
|
||||
req <- req %>% req_url_query(!!!query_params)
|
||||
for (query_param in query_params) {
|
||||
req <- req %>% req_url_query(!!!query_param)
|
||||
}
|
||||
|
||||
# has file upload?
|
||||
if (!is.null(file_params) && length(file_params) != 0) {
|
||||
|
@ -944,7 +944,9 @@ PetApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
|
||||
query_params["status"] <- `status`
|
||||
for (query_item in `status`) {
|
||||
query_params[["status"]] <- c(query_params[["status"]], list(`status` = query_item))
|
||||
}
|
||||
|
||||
local_var_url_path <- "/pet/findByStatus"
|
||||
# OAuth-related settings
|
||||
@ -1062,7 +1064,9 @@ PetApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
|
||||
query_params["tags"] <- `tags`
|
||||
for (query_item in `tags`) {
|
||||
query_params[["tags"]] <- c(query_params[["tags"]], list(`tags` = query_item))
|
||||
}
|
||||
|
||||
local_var_url_path <- "/pet/findByTags"
|
||||
# OAuth-related settings
|
||||
|
@ -944,7 +944,9 @@ PetApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
|
||||
query_params["status"] <- `status`
|
||||
for (query_item in `status`) {
|
||||
query_params[["status"]] <- c(query_params[["status"]], list(`status` = query_item))
|
||||
}
|
||||
|
||||
local_var_url_path <- "/pet/findByStatus"
|
||||
# OAuth-related settings
|
||||
@ -1062,7 +1064,9 @@ PetApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
|
||||
query_params["tags"] <- `tags`
|
||||
for (query_item in `tags`) {
|
||||
query_params[["tags"]] <- c(query_params[["tags"]], list(`tags` = query_item))
|
||||
}
|
||||
|
||||
local_var_url_path <- "/pet/findByTags"
|
||||
# OAuth-related settings
|
||||
|
Loading…
x
Reference in New Issue
Block a user