forked from loafle/openapi-generator-original
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
|
#' @docType class
|
||||||
#' @title ApiResponse
|
#' @title ApiResponse
|
||||||
#' @description ApiResponse Class
|
#' @description ApiResponse Class
|
||||||
@ -5,11 +6,19 @@
|
|||||||
#' @field content The deserialized response body.
|
#' @field content The deserialized response body.
|
||||||
#' @field response The raw response from the endpoint.
|
#' @field response The raw response from the endpoint.
|
||||||
#' @export
|
#' @export
|
||||||
ApiResponse <- R6::R6Class(
|
ApiResponse <- R6::R6Class(
|
||||||
"ApiResponse",
|
"ApiResponse",
|
||||||
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
|
||||||
|
@ -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 = "")
|
||||||
@ -52,4 +66,4 @@ ApiException <- R6::R6Class(
|
|||||||
errorMsg
|
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
|
#' @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 = "")
|
||||||
@ -51,4 +72,4 @@ ApiException <- R6::R6Class(
|
|||||||
errorMsg
|
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
|
#' @docType class
|
||||||
#' @title ApiResponse
|
#' @title ApiResponse
|
||||||
#' @description ApiResponse Class
|
#' @description ApiResponse Class
|
||||||
@ -5,11 +13,19 @@
|
|||||||
#' @field content The deserialized response body.
|
#' @field content The deserialized response body.
|
||||||
#' @field response The raw response from the endpoint.
|
#' @field response The raw response from the endpoint.
|
||||||
#' @export
|
#' @export
|
||||||
ApiResponse <- R6::R6Class(
|
ApiResponse <- R6::R6Class(
|
||||||
"ApiResponse",
|
"ApiResponse",
|
||||||
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user