add doc to api exception, response object in R client (#12659)

This commit is contained in:
William Cheng 2022-06-22 16:47:27 +08:00 committed by GitHub
parent a599ae927f
commit 012f90895f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 12 deletions

View File

@ -1,3 +1,4 @@
{{>partial_header}}
#' @docType class #' @docType class
#' @title ApiResponse #' @title ApiResponse
#' @description ApiResponse Class #' @description ApiResponse Class
@ -10,6 +11,14 @@ ApiResponse <- R6::R6Class(
public = list( public = list(
content = NULL, content = NULL,
response = NULL, response = NULL,
#' Initialize a new ApiResponse class.
#'
#' @description
#' Initialize a new ApiResponse class.
#'
#' @param content The deserialized response body.
#' @param response The raw response from the endpoint.
#' @export
initialize = function(content, response) { initialize = function(content, response) {
self$content <- content self$content <- content
self$response <- response self$response <- response

View File

@ -1,3 +1,4 @@
{{>partial_header}}
{{! ApiException class for returning the ApiException object on encountering errors}} {{! ApiException class for returning the ApiException object on encountering errors}}
#' @docType class #' @docType class
#' @title ApiException #' @title ApiException
@ -15,13 +16,21 @@ ApiException <- R6::R6Class(
reason = NULL, reason = NULL,
body = NULL, body = NULL,
headers = NULL, headers = NULL,
#' Initialize a new ApiException class.
#'
#' @description
#' Initialize a new ApiExceptino class.
#'
#' @param status HTTP status.
#' @param reason Reason of the ApiException.
#' @param http_response HTTP response object.
#' @export
initialize = function(status = NULL, reason = NULL, http_response = NULL) { initialize = function(status = NULL, reason = NULL, http_response = NULL) {
if (!is.null(http_response)) { if (!is.null(http_response)) {
self$status <- http_response$status_code self$status <- http_response$status_code
errorMsg <- toString(content(http_response)) errorMsg <- toString(content(http_response))
if(errorMsg == ""){ if(errorMsg == ""){
errorMsg <- "Api exception encountered." errorMsg <- "Api exception encountered. No details given."
} }
self$body <- errorMsg self$body <- errorMsg
self$headers <- http_response$headers self$headers <- http_response$headers
@ -33,8 +42,13 @@ ApiException <- R6::R6Class(
self$headers <- NULL self$headers <- NULL
} }
}, },
#' Returns the string format of ApiException.
# returns the string format of ApiException #'
#' @description
#' Returns the string format of ApiException.
#'
#' @return the string format of ApiException.
#' @export
toString = function() { toString = function() {
errorMsg <- "" errorMsg <- ""
errorMsg <- paste("status : ", self$status, "\n", sep = "") errorMsg <- paste("status : ", self$status, "\n", sep = "")

View File

@ -1,3 +1,11 @@
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class #' @docType class
#' @title ApiException #' @title ApiException
#' @description ApiException Class #' @description ApiException Class
@ -14,13 +22,21 @@ ApiException <- R6::R6Class(
reason = NULL, reason = NULL,
body = NULL, body = NULL,
headers = NULL, headers = NULL,
#' Initialize a new ApiException class.
#'
#' @description
#' Initialize a new ApiExceptino class.
#'
#' @param status HTTP status.
#' @param reason Reason of the ApiException.
#' @param http_response HTTP response object.
#' @export
initialize = function(status = NULL, reason = NULL, http_response = NULL) { initialize = function(status = NULL, reason = NULL, http_response = NULL) {
if (!is.null(http_response)) { if (!is.null(http_response)) {
self$status <- http_response$status_code self$status <- http_response$status_code
errorMsg <- toString(content(http_response)) errorMsg <- toString(content(http_response))
if(errorMsg == ""){ if(errorMsg == ""){
errorMsg <- "Api exception encountered." errorMsg <- "Api exception encountered. No details given."
} }
self$body <- errorMsg self$body <- errorMsg
self$headers <- http_response$headers self$headers <- http_response$headers
@ -32,8 +48,13 @@ ApiException <- R6::R6Class(
self$headers <- NULL self$headers <- NULL
} }
}, },
#' Returns the string format of ApiException.
# returns the string format of ApiException #'
#' @description
#' Returns the string format of ApiException.
#'
#' @return the string format of ApiException.
#' @export
toString = function() { toString = function() {
errorMsg <- "" errorMsg <- ""
errorMsg <- paste("status : ", self$status, "\n", sep = "") errorMsg <- paste("status : ", self$status, "\n", sep = "")

View File

@ -1,3 +1,11 @@
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class #' @docType class
#' @title ApiResponse #' @title ApiResponse
#' @description ApiResponse Class #' @description ApiResponse Class
@ -10,6 +18,14 @@ ApiResponse <- R6::R6Class(
public = list( public = list(
content = NULL, content = NULL,
response = NULL, response = NULL,
#' Initialize a new ApiResponse class.
#'
#' @description
#' Initialize a new ApiResponse class.
#'
#' @param content The deserialized response body.
#' @param response The raw response from the endpoint.
#' @export
initialize = function(content, response) { initialize = function(content, response) {
self$content <- content self$content <- content
self$response <- response self$response <- response