|
32 | 32 | #' } |
33 | 33 | #' } |
34 | 34 | #' |
| 35 | +#' \strong{ fake_path_array } \emph{ test array parameter in path } |
| 36 | +#' |
| 37 | +#' |
| 38 | +#' \itemize{ |
| 39 | +#' \item \emph{ @param } path_array list( character ) |
| 40 | +#' |
| 41 | +#' \item On encountering errors, an error of subclass ApiException will be thrown. |
| 42 | +#' |
| 43 | +#' \item status code : 200 | successful operation |
| 44 | +#' |
| 45 | +#' |
| 46 | +#' \item response headers : |
| 47 | +#' |
| 48 | +#' \tabular{ll}{ |
| 49 | +#' } |
| 50 | +#' } |
| 51 | +#' |
35 | 52 | #' \strong{ fake_regular_expression } \emph{ test regular expression to ensure no exception } |
36 | 53 | #' |
37 | 54 | #' |
|
106 | 123 | #' |
107 | 124 | #' |
108 | 125 | #' |
| 126 | +#' #################### fake_path_array #################### |
| 127 | +#' |
| 128 | +#' library(petstore) |
| 129 | +#' var_path_array <- ["path_array_example"] # array[character] | dummy path parameter |
| 130 | +#' |
| 131 | +#' #test array parameter in path |
| 132 | +#' api_instance <- petstore_api$new() |
| 133 | +#' |
| 134 | +#' result <- tryCatch( |
| 135 | +#' |
| 136 | +#' api_instance$fake_api$fake_path_array(var_path_array), |
| 137 | +#' ApiException = function(ex) ex |
| 138 | +#' ) |
| 139 | +#' # In case of error, print the error object |
| 140 | +#' if (!is.null(result$ApiException)) { |
| 141 | +#' print("Exception occurs when calling `fake_path_array`:") |
| 142 | +#' dput(result$ApiException$toString()) |
| 143 | +#' |
| 144 | +#' # error object |
| 145 | +#' dput(result$ApiException$error_object$toJSONString()) |
| 146 | +#' |
| 147 | +#' }#' |
| 148 | +#' # This endpoint doesn't return data |
| 149 | +#' |
| 150 | +#' |
109 | 151 | #' #################### fake_regular_expression #################### |
110 | 152 | #' |
111 | 153 | #' library(petstore) |
@@ -300,6 +342,108 @@ FakeApi <- R6::R6Class( |
300 | 342 | ApiException = ApiException$new(http_response = local_var_resp)) |
301 | 343 | } |
302 | 344 | }, |
| 345 | + #' test array parameter in path |
| 346 | + #' |
| 347 | + #' @description |
| 348 | + #' test array parameter in path |
| 349 | + #' |
| 350 | + #' @param path_array dummy path parameter |
| 351 | + #' @param ... Other optional arguments |
| 352 | + #' @return void |
| 353 | + #' @export |
| 354 | + fake_path_array = function(path_array, ...) { |
| 355 | + local_var_response <- self$fake_path_array_with_http_info(path_array, ...) |
| 356 | + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { |
| 357 | + local_var_response$content |
| 358 | + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { |
| 359 | + local_var_response |
| 360 | + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { |
| 361 | + local_var_response |
| 362 | + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { |
| 363 | + local_var_response |
| 364 | + } |
| 365 | + }, |
| 366 | + #' test array parameter in path |
| 367 | + #' |
| 368 | + #' @description |
| 369 | + #' test array parameter in path |
| 370 | + #' |
| 371 | + #' @param path_array dummy path parameter |
| 372 | + #' @param ... Other optional arguments |
| 373 | + #' @return API response (void) with additional information such as HTTP status code, headers |
| 374 | + #' @export |
| 375 | + fake_path_array_with_http_info = function(path_array, ...) { |
| 376 | + args <- list(...) |
| 377 | + query_params <- list() |
| 378 | + header_params <- c() |
| 379 | + form_params <- list() |
| 380 | + file_params <- list() |
| 381 | + local_var_body <- NULL |
| 382 | + oauth_scopes <- NULL |
| 383 | + is_oauth <- FALSE |
| 384 | + |
| 385 | + if (missing(`path_array`)) { |
| 386 | + rlang::abort(message = "Missing required parameter `path_array`.", |
| 387 | + .subclass = "ApiException", |
| 388 | + ApiException = ApiException$new(status = 0, |
| 389 | + reason = "Missing required parameter `path_array`.")) |
| 390 | + } |
| 391 | + |
| 392 | + |
| 393 | + local_var_url_path <- "/fake/path_array/{path_array}/testing" |
| 394 | + if (!missing(`path_array`)) { |
| 395 | + local_var_url_path <- gsub("\\{path_array\\}", paste(URLencode(as.character(`path_array`), reserved = TRUE), collapse= ",", sep=""), local_var_url_path) |
| 396 | + } |
| 397 | + |
| 398 | + |
| 399 | + # The Accept request HTTP header |
| 400 | + local_var_accepts <- list() |
| 401 | + |
| 402 | + # The Content-Type representation header |
| 403 | + local_var_content_types <- list() |
| 404 | + |
| 405 | + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), |
| 406 | + method = "GET", |
| 407 | + query_params = query_params, |
| 408 | + header_params = header_params, |
| 409 | + form_params = form_params, |
| 410 | + file_params = file_params, |
| 411 | + accepts = local_var_accepts, |
| 412 | + content_types = local_var_content_types, |
| 413 | + body = local_var_body, |
| 414 | + is_oauth = is_oauth, |
| 415 | + oauth_scopes = oauth_scopes, |
| 416 | + ...) |
| 417 | + |
| 418 | + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { |
| 419 | + local_var_resp$content <- NULL |
| 420 | + local_var_resp |
| 421 | + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { |
| 422 | + local_var_error_msg <- local_var_resp$response |
| 423 | + if (local_var_error_msg == "") { |
| 424 | + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") |
| 425 | + } |
| 426 | + rlang::abort(message = local_var_error_msg, |
| 427 | + .subclass = "ApiException", |
| 428 | + ApiException = ApiException$new(http_response = local_var_resp)) |
| 429 | + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { |
| 430 | + local_var_error_msg <- local_var_resp$response |
| 431 | + if (local_var_error_msg == "") { |
| 432 | + local_var_error_msg <- "Api client exception encountered." |
| 433 | + } |
| 434 | + rlang::abort(message = local_var_error_msg, |
| 435 | + .subclass = "ApiException", |
| 436 | + ApiException = ApiException$new(http_response = local_var_resp)) |
| 437 | + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { |
| 438 | + local_var_error_msg <- local_var_resp$response |
| 439 | + if (local_var_error_msg == "") { |
| 440 | + local_var_error_msg <- "Api server exception encountered." |
| 441 | + } |
| 442 | + rlang::abort(message = error_msg, |
| 443 | + .subclass = "ApiException", |
| 444 | + ApiException = ApiException$new(http_response = local_var_resp)) |
| 445 | + } |
| 446 | + }, |
303 | 447 | #' test regular expression to ensure no exception |
304 | 448 | #' |
305 | 449 | #' @description |
|
0 commit comments