mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-08 08:30:56 +00:00
add http basic test in r client (#12978)
This commit is contained in:
parent
f26985c239
commit
6e6c2f9a0e
@ -38,9 +38,7 @@ paths:
|
||||
'405':
|
||||
description: Invalid input
|
||||
security:
|
||||
- petstore_auth:
|
||||
- 'write:pets'
|
||||
- 'read:pets'
|
||||
- http_auth: []
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/Pet'
|
||||
put:
|
||||
@ -671,6 +669,9 @@ components:
|
||||
description: Pet object that needs to be added to the store
|
||||
required: true
|
||||
securitySchemes:
|
||||
http_auth:
|
||||
type : http
|
||||
scheme : basic
|
||||
BearerToken:
|
||||
type : http
|
||||
scheme : bearer
|
||||
|
@ -262,8 +262,11 @@
|
||||
#' #Add a new pet to the store
|
||||
#' api.instance <- PetApi$new()
|
||||
#'
|
||||
#' # Configure OAuth2 access token for authorization: petstore_auth
|
||||
#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
#' #Configure HTTP basic authorization: http_auth
|
||||
#' # provide the username
|
||||
#' api.instance$api_client$username <- 'TODO_YOUR_USERNAME';
|
||||
#' # provide the password
|
||||
#' api.instance$api_client$password <- 'TODO_YOUR_PASSWORD';
|
||||
#'
|
||||
#'result <- tryCatch(
|
||||
#' api.instance$AddPet(var.pet),
|
||||
@ -582,8 +585,8 @@ PetApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
url_path <- "/pet"
|
||||
# OAuth token
|
||||
header_params["Authorization"] <- paste("Bearer", self$api_client$access_token, sep = " ")
|
||||
# HTTP basic auth
|
||||
header_params["Authorization"] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$api_client$username, self$api_client$password, sep = ":"))))
|
||||
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "POST",
|
||||
|
@ -121,6 +121,10 @@ Class | Method | HTTP request | Description
|
||||
- **API key parameter name**: api_key
|
||||
- **Location**: HTTP header
|
||||
|
||||
### http_auth
|
||||
|
||||
- **Type**: HTTP basic authentication
|
||||
|
||||
### petstore_auth
|
||||
|
||||
- **Type**: OAuth
|
||||
|
@ -30,8 +30,9 @@ var_pet <- Pet$new("name_example", list("photoUrls_example"), 123, Category$new(
|
||||
|
||||
#Add a new pet to the store
|
||||
api_instance <- PetApi$new()
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
api_instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
# Configure HTTP basic authorization: http_auth
|
||||
api_instance$api_client$username <- 'TODO_YOUR_USERNAME';
|
||||
api_instance$api_client$password <- 'TODO_YOUR_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"),
|
||||
@ -63,7 +64,7 @@ Name | Type | Description | Notes
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
[http_auth](../README.md#http_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
|
@ -11,6 +11,8 @@ pet <- Pet$new("name_test",
|
||||
),
|
||||
status = "available"
|
||||
)
|
||||
pet_api$api_client$username <- "username123"
|
||||
pet_api$api_client$password <- "password123"
|
||||
result <- pet_api$AddPet(pet)
|
||||
|
||||
test_that("AddPet", {
|
||||
|
Loading…
x
Reference in New Issue
Block a user