fix query, header params (#13034)

This commit is contained in:
William Cheng
2022-07-28 16:31:12 +08:00
committed by GitHub
parent bc65be4c9a
commit c905760898
6 changed files with 38 additions and 15 deletions

View File

@@ -251,14 +251,14 @@
}
{{/requiredParams}}
{{#header_params}}
{{#headerParams}}
header_params["{{baseName}}"] <- `{{paramName}}`
{{/header_params}}
{{#query_params}}
{{/headerParams}}
{{#queryParams}}
query_params["{{baseName}}"] <- {{paramName}}
{{/query_params}}
{{/queryParams}}
{{#hasFormParams}}
local_var_body <- list(
{{#formParams}}

View File

@@ -134,6 +134,10 @@ FakeApi <- R6::R6Class(
reason = "Missing required parameter `dummy`."))
}
header_params["dummy"] <- `dummy`
header_params["data_file"] <- `var_data_file`
local_var_body <- NULL
local_var_url_path <- "/fake/data_file"

View File

@@ -689,6 +689,8 @@ PetApi <- R6::R6Class(
reason = "Missing required parameter `pet_id`."))
}
header_params["api_key"] <- `api_key`
local_var_body <- NULL
local_var_url_path <- "/pet/{petId}?streaming"
if (!missing(`pet_id`)) {
@@ -786,6 +788,8 @@ PetApi <- R6::R6Class(
reason = "Missing required parameter `status`."))
}
query_params["status"] <- status
local_var_body <- NULL
local_var_url_path <- "/pet/findByStatus"
# OAuth token
@@ -892,6 +896,8 @@ PetApi <- R6::R6Class(
reason = "Missing required parameter `tags`."))
}
query_params["tags"] <- tags
local_var_body <- NULL
local_var_url_path <- "/pet/findByTags"
# OAuth token

View File

@@ -984,6 +984,10 @@ UserApi <- R6::R6Class(
reason = "Missing required parameter `password`."))
}
query_params["username"] <- username
query_params["password"] <- password
local_var_body <- NULL
local_var_url_path <- "/user/login"

View File

@@ -8,6 +8,8 @@ var_pet <- Pet$new("name_example", list("photoUrls_example"), 56, Category$new(5
api_instance <- PetApi$new()
# Configure OAuth2 access token for authorization: petstore_auth
api_instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
api_instance$api_client$username <- 'username';
api_instance$api_client$password <- 'password';
result <- tryCatch(
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
# api_instance$AddPet(var_pet, data_file = "result.txt"),
@@ -17,16 +19,18 @@ result <- tryCatch(
var_pet_id <- 56 # integer | ID of pet to return
#Find pet by ID (streaming)
api_instance <- PetApi$new()
# Configure API key authorization: api_key
api_instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
result <- tryCatch(
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
# api_instance$GetPetByIdStreaming(var_pet_id, data_file = "result.txt"),
api_instance$GetPetByIdStreaming(var_pet_id, stream_callback = function(x) { print(x) }),
ApiException = function(ex) ex
)
result <- api_instance$FindPetsByStatus("available")
dput(result)
##Find pet by ID (streaming)
#api_instance <- PetApi$new()
## Configure API key authorization: api_key
#api_instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
#result <- tryCatch(
# # to save the result into a file, simply add the optional `data_file` parameter, e.g.
# # api_instance$GetPetByIdStreaming(var_pet_id, data_file = "result.txt"),
# api_instance$GetPetByIdStreaming(var_pet_id, stream_callback = function(x) { print(x) }),
# ApiException = function(ex) ex
# )
# In case of error, print the error object
#if (!is.null(result$ApiException)) {
# cat(result$ApiException$toString())

View File

@@ -15,11 +15,16 @@ pet_api$api_client$username <- "username123"
pet_api$api_client$password <- "password123"
result <- pet_api$AddPet(pet)
test_that("AddPet", {
test_that("Test toJSONString", {
expect_equal(pet_id, 123321)
expect_equal(pet$toJSONString(), '{"id":123321,"category":{"id":450,"name":"test_cat"},"name":"name_test","photoUrls":["photo_test","second test"],"tags":[{"id":123,"name":"tag_test"},{"id":456,"name":"unknown"}],"status":"available"}')
})
test_that("Test FindPetByStatus", {
result <- pet_api$FindPetsByStatus("available")
expect_equal(result[[1]]$status, "available")
})
test_that("Test toJSON toJSONString fromJSON fromJSONString", {
pet0 <- Pet$new()
jsonpet <- pet0$toJSON()