mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-02 21:50:55 +00:00
add doc to api exception, response object in R client (#12659)
This commit is contained in:
parent
a599ae927f
commit
012f90895f
@ -1,3 +1,4 @@
|
||||
{{>partial_header}}
|
||||
#' @docType class
|
||||
#' @title ApiResponse
|
||||
#' @description ApiResponse Class
|
||||
@ -5,11 +6,19 @@
|
||||
#' @field content The deserialized response body.
|
||||
#' @field response The raw response from the endpoint.
|
||||
#' @export
|
||||
ApiResponse <- R6::R6Class(
|
||||
ApiResponse <- R6::R6Class(
|
||||
"ApiResponse",
|
||||
public = list(
|
||||
content = 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) {
|
||||
self$content <- content
|
||||
self$response <- response
|
||||
|
@ -1,3 +1,4 @@
|
||||
{{>partial_header}}
|
||||
{{! ApiException class for returning the ApiException object on encountering errors}}
|
||||
#' @docType class
|
||||
#' @title ApiException
|
||||
@ -15,13 +16,21 @@ ApiException <- R6::R6Class(
|
||||
reason = NULL,
|
||||
body = 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) {
|
||||
if (!is.null(http_response)) {
|
||||
self$status <- http_response$status_code
|
||||
errorMsg <- toString(content(http_response))
|
||||
if(errorMsg == ""){
|
||||
errorMsg <- "Api exception encountered."
|
||||
errorMsg <- "Api exception encountered. No details given."
|
||||
}
|
||||
self$body <- errorMsg
|
||||
self$headers <- http_response$headers
|
||||
@ -33,8 +42,13 @@ ApiException <- R6::R6Class(
|
||||
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() {
|
||||
errorMsg <- ""
|
||||
errorMsg <- paste("status : ", self$status, "\n", sep = "")
|
||||
@ -52,4 +66,4 @@ ApiException <- R6::R6Class(
|
||||
errorMsg
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -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
|
||||
#' @title ApiException
|
||||
#' @description ApiException Class
|
||||
@ -14,13 +22,21 @@ ApiException <- R6::R6Class(
|
||||
reason = NULL,
|
||||
body = 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) {
|
||||
if (!is.null(http_response)) {
|
||||
self$status <- http_response$status_code
|
||||
errorMsg <- toString(content(http_response))
|
||||
if(errorMsg == ""){
|
||||
errorMsg <- "Api exception encountered."
|
||||
errorMsg <- "Api exception encountered. No details given."
|
||||
}
|
||||
self$body <- errorMsg
|
||||
self$headers <- http_response$headers
|
||||
@ -32,8 +48,13 @@ ApiException <- R6::R6Class(
|
||||
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() {
|
||||
errorMsg <- ""
|
||||
errorMsg <- paste("status : ", self$status, "\n", sep = "")
|
||||
@ -51,4 +72,4 @@ ApiException <- R6::R6Class(
|
||||
errorMsg
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -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
|
||||
#' @title ApiResponse
|
||||
#' @description ApiResponse Class
|
||||
@ -5,11 +13,19 @@
|
||||
#' @field content The deserialized response body.
|
||||
#' @field response The raw response from the endpoint.
|
||||
#' @export
|
||||
ApiResponse <- R6::R6Class(
|
||||
ApiResponse <- R6::R6Class(
|
||||
"ApiResponse",
|
||||
public = list(
|
||||
content = 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) {
|
||||
self$content <- content
|
||||
self$response <- response
|
||||
|
Loading…
x
Reference in New Issue
Block a user