Skip to content

Commit 012f908

Browse files
authored
add doc to api exception, response object in R client (#12659)
1 parent a599ae9 commit 012f908

4 files changed

Lines changed: 72 additions & 12 deletions

File tree

modules/openapi-generator/src/main/resources/r/ApiResponse.mustache

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
1+
{{>partial_header}}
12
#' @docType class
23
#' @title ApiResponse
34
#' @description ApiResponse Class
45
#' @format An \code{R6Class} generator object
56
#' @field content The deserialized response body.
67
#' @field response The raw response from the endpoint.
78
#' @export
8-
ApiResponse <- R6::R6Class(
9+
ApiResponse <- R6::R6Class(
910
"ApiResponse",
1011
public = list(
1112
content = NULL,
1213
response = NULL,
14+
#' Initialize a new ApiResponse class.
15+
#'
16+
#' @description
17+
#' Initialize a new ApiResponse class.
18+
#'
19+
#' @param content The deserialized response body.
20+
#' @param response The raw response from the endpoint.
21+
#' @export
1322
initialize = function(content, response) {
1423
self$content <- content
1524
self$response <- response

modules/openapi-generator/src/main/resources/r/api_exception.mustache

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{>partial_header}}
12
{{! ApiException class for returning the ApiException object on encountering errors}}
23
#' @docType class
34
#' @title ApiException
@@ -15,13 +16,21 @@ ApiException <- R6::R6Class(
1516
reason = NULL,
1617
body = NULL,
1718
headers = NULL,
18-
19+
#' Initialize a new ApiException class.
20+
#'
21+
#' @description
22+
#' Initialize a new ApiExceptino class.
23+
#'
24+
#' @param status HTTP status.
25+
#' @param reason Reason of the ApiException.
26+
#' @param http_response HTTP response object.
27+
#' @export
1928
initialize = function(status = NULL, reason = NULL, http_response = NULL) {
2029
if (!is.null(http_response)) {
2130
self$status <- http_response$status_code
2231
errorMsg <- toString(content(http_response))
2332
if(errorMsg == ""){
24-
errorMsg <- "Api exception encountered."
33+
errorMsg <- "Api exception encountered. No details given."
2534
}
2635
self$body <- errorMsg
2736
self$headers <- http_response$headers
@@ -33,8 +42,13 @@ ApiException <- R6::R6Class(
3342
self$headers <- NULL
3443
}
3544
},
36-
37-
# returns the string format of ApiException
45+
#' Returns the string format of ApiException.
46+
#'
47+
#' @description
48+
#' Returns the string format of ApiException.
49+
#'
50+
#' @return the string format of ApiException.
51+
#' @export
3852
toString = function() {
3953
errorMsg <- ""
4054
errorMsg <- paste("status : ", self$status, "\n", sep = "")
@@ -52,4 +66,4 @@ ApiException <- R6::R6Class(
5266
errorMsg
5367
}
5468
)
55-
)
69+
)

samples/client/petstore/R/R/api_exception.R

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
#' OpenAPI Petstore
2+
#'
3+
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
4+
#'
5+
#' The version of the OpenAPI document: 1.0.0
6+
#' Generated by: https://openapi-generator.tech
7+
#'
8+
19
#' @docType class
210
#' @title ApiException
311
#' @description ApiException Class
@@ -14,13 +22,21 @@ ApiException <- R6::R6Class(
1422
reason = NULL,
1523
body = NULL,
1624
headers = NULL,
17-
25+
#' Initialize a new ApiException class.
26+
#'
27+
#' @description
28+
#' Initialize a new ApiExceptino class.
29+
#'
30+
#' @param status HTTP status.
31+
#' @param reason Reason of the ApiException.
32+
#' @param http_response HTTP response object.
33+
#' @export
1834
initialize = function(status = NULL, reason = NULL, http_response = NULL) {
1935
if (!is.null(http_response)) {
2036
self$status <- http_response$status_code
2137
errorMsg <- toString(content(http_response))
2238
if(errorMsg == ""){
23-
errorMsg <- "Api exception encountered."
39+
errorMsg <- "Api exception encountered. No details given."
2440
}
2541
self$body <- errorMsg
2642
self$headers <- http_response$headers
@@ -32,8 +48,13 @@ ApiException <- R6::R6Class(
3248
self$headers <- NULL
3349
}
3450
},
35-
36-
# returns the string format of ApiException
51+
#' Returns the string format of ApiException.
52+
#'
53+
#' @description
54+
#' Returns the string format of ApiException.
55+
#'
56+
#' @return the string format of ApiException.
57+
#' @export
3758
toString = function() {
3859
errorMsg <- ""
3960
errorMsg <- paste("status : ", self$status, "\n", sep = "")
@@ -51,4 +72,4 @@ ApiException <- R6::R6Class(
5172
errorMsg
5273
}
5374
)
54-
)
75+
)

samples/client/petstore/R/R/api_response.R

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
1+
#' OpenAPI Petstore
2+
#'
3+
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
4+
#'
5+
#' The version of the OpenAPI document: 1.0.0
6+
#' Generated by: https://openapi-generator.tech
7+
#'
8+
19
#' @docType class
210
#' @title ApiResponse
311
#' @description ApiResponse Class
412
#' @format An \code{R6Class} generator object
513
#' @field content The deserialized response body.
614
#' @field response The raw response from the endpoint.
715
#' @export
8-
ApiResponse <- R6::R6Class(
16+
ApiResponse <- R6::R6Class(
917
"ApiResponse",
1018
public = list(
1119
content = NULL,
1220
response = NULL,
21+
#' Initialize a new ApiResponse class.
22+
#'
23+
#' @description
24+
#' Initialize a new ApiResponse class.
25+
#'
26+
#' @param content The deserialized response body.
27+
#' @param response The raw response from the endpoint.
28+
#' @export
1329
initialize = function(content, response) {
1430
self$content <- content
1531
self$response <- response

0 commit comments

Comments
 (0)