mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 22:50:53 +00:00
fix http basc auth in R client (#13330)
This commit is contained in:
parent
225204093f
commit
d1f44e8a7e
@ -430,18 +430,9 @@
|
|||||||
{{#isBasic}}
|
{{#isBasic}}
|
||||||
{{#isBasicBasic}}
|
{{#isBasicBasic}}
|
||||||
# HTTP basic auth
|
# HTTP basic auth
|
||||||
if (is.null(self$api_client$username) || is.null(self$api_client$password)) {
|
if (!is.null(self$api_client$username) || !is.null(self$api_client$password)) {
|
||||||
{{#useDefaultExceptionHandling}}
|
header_params["Authorization"] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$api_client$username, self$api_client$password, sep = ":"))))
|
||||||
stop("username, password in `api_client` must be set for authentication in the endpoint `{{{operationId}}}`.")
|
|
||||||
{{/useDefaultExceptionHandling}}
|
|
||||||
{{#useRlangExceptionHandling}}
|
|
||||||
rlang::abort(message = "username, password in `api_client` must be set for authentication in the endpoint `{{{operationId}}}`.",
|
|
||||||
.subclass = "ApiException",
|
|
||||||
ApiException = ApiException$new(status = 0,
|
|
||||||
reason = "username, password in `api_client` must be set for authentication in the endpoint `{{{operationId}}}`."))
|
|
||||||
{{/useRlangExceptionHandling}}
|
|
||||||
}
|
}
|
||||||
header_params["Authorization"] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$api_client$username, self$api_client$password, sep = ":"))))
|
|
||||||
{{/isBasicBasic}}
|
{{/isBasicBasic}}
|
||||||
{{#isBasicBearer}}
|
{{#isBasicBearer}}
|
||||||
# Bearer token
|
# Bearer token
|
||||||
|
@ -719,13 +719,9 @@ PetApi <- R6::R6Class(
|
|||||||
|
|
||||||
local_var_url_path <- "/pet"
|
local_var_url_path <- "/pet"
|
||||||
# HTTP basic auth
|
# HTTP basic auth
|
||||||
if (is.null(self$api_client$username) || is.null(self$api_client$password)) {
|
if (!is.null(self$api_client$username) || !is.null(self$api_client$password)) {
|
||||||
rlang::abort(message = "username, password in `api_client` must be set for authentication in the endpoint `add_pet`.",
|
header_params["Authorization"] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$api_client$username, self$api_client$password, sep = ":"))))
|
||||||
.subclass = "ApiException",
|
|
||||||
ApiException = ApiException$new(status = 0,
|
|
||||||
reason = "username, password in `api_client` must be set for authentication in the endpoint `add_pet`."))
|
|
||||||
}
|
}
|
||||||
header_params["Authorization"] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$api_client$username, self$api_client$password, sep = ":"))))
|
|
||||||
|
|
||||||
# The Accept request HTTP header
|
# The Accept request HTTP header
|
||||||
local_var_accepts <- list("application/xml", "application/json")
|
local_var_accepts <- list("application/xml", "application/json")
|
||||||
|
@ -719,13 +719,9 @@ PetApi <- R6::R6Class(
|
|||||||
|
|
||||||
local_var_url_path <- "/pet"
|
local_var_url_path <- "/pet"
|
||||||
# HTTP basic auth
|
# HTTP basic auth
|
||||||
if (is.null(self$api_client$username) || is.null(self$api_client$password)) {
|
if (!is.null(self$api_client$username) || !is.null(self$api_client$password)) {
|
||||||
rlang::abort(message = "username, password in `api_client` must be set for authentication in the endpoint `add_pet`.",
|
header_params["Authorization"] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$api_client$username, self$api_client$password, sep = ":"))))
|
||||||
.subclass = "ApiException",
|
|
||||||
ApiException = ApiException$new(status = 0,
|
|
||||||
reason = "username, password in `api_client` must be set for authentication in the endpoint `add_pet`."))
|
|
||||||
}
|
}
|
||||||
header_params["Authorization"] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$api_client$username, self$api_client$password, sep = ":"))))
|
|
||||||
|
|
||||||
# The Accept request HTTP header
|
# The Accept request HTTP header
|
||||||
local_var_accepts <- list("application/xml", "application/json")
|
local_var_accepts <- list("application/xml", "application/json")
|
||||||
|
@ -719,13 +719,9 @@ PetApi <- R6::R6Class(
|
|||||||
|
|
||||||
local_var_url_path <- "/pet"
|
local_var_url_path <- "/pet"
|
||||||
# HTTP basic auth
|
# HTTP basic auth
|
||||||
if (is.null(self$api_client$username) || is.null(self$api_client$password)) {
|
if (!is.null(self$api_client$username) || !is.null(self$api_client$password)) {
|
||||||
rlang::abort(message = "username, password in `api_client` must be set for authentication in the endpoint `AddPet`.",
|
header_params["Authorization"] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$api_client$username, self$api_client$password, sep = ":"))))
|
||||||
.subclass = "ApiException",
|
|
||||||
ApiException = ApiException$new(status = 0,
|
|
||||||
reason = "username, password in `api_client` must be set for authentication in the endpoint `AddPet`."))
|
|
||||||
}
|
}
|
||||||
header_params["Authorization"] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$api_client$username, self$api_client$password, sep = ":"))))
|
|
||||||
|
|
||||||
# The Accept request HTTP header
|
# The Accept request HTTP header
|
||||||
local_var_accepts <- list("application/xml", "application/json")
|
local_var_accepts <- list("application/xml", "application/json")
|
||||||
|
@ -12,8 +12,10 @@ pet <- Pet$new("name_test",
|
|||||||
status = "available"
|
status = "available"
|
||||||
)
|
)
|
||||||
|
|
||||||
pet_api$api_client$username <- ""
|
# no need to set uasername, password and there should be no error
|
||||||
pet_api$api_client$password <- ""
|
# since the endpoint can support multi auth schema
|
||||||
|
#pet_api$api_client$username <- ""
|
||||||
|
#pet_api$api_client$password <- ""
|
||||||
result <- pet_api$AddPet(pet)
|
result <- pet_api$AddPet(pet)
|
||||||
|
|
||||||
test_that("Test toJSONString", {
|
test_that("Test toJSONString", {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user