Skip to content

Commit f2cc3b8

Browse files
authored
fix roxygen warnings in oneof, anyof, api_client (#12654)
1 parent 042f717 commit f2cc3b8

6 files changed

Lines changed: 134 additions & 44 deletions

File tree

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

Lines changed: 67 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{{>partial_header}}
2-
32
#' ApiClient Class
43
#'
54
#' Generic API client for OpenAPI client library builds.
@@ -18,11 +17,11 @@
1817
#' @format An \code{R6Class} generator object
1918
#' @field base_path Base url
2019
#' @field user_agent Default user agent
21-
#' @field default_headers
20+
#' @field default_headers Default headers
2221
#' @field username Username for HTTP basic authentication
2322
#' @field password Password for HTTP basic authentication
24-
#' @field api_keys
25-
#' @field access_token
23+
#' @field api_keys API keys
24+
#' @field access_token Access token
2625
#' @field timeout Default timeout in seconds
2726
#' @field retry_status_codes vector of status codes to retry
2827
#' @field max_retry_attempts maximum number of retries for the status codes
@@ -54,7 +53,22 @@ ApiClient <- R6::R6Class(
5453
retry_status_codes = NULL,
5554
# Maximum number of retry attempts for the retry status codes
5655
max_retry_attempts = NULL,
57-
# constructor
56+
#' Initialize a new ApiClient.
57+
#'
58+
#' @description
59+
#' Initialize a new ApiClient.
60+
#'
61+
#' @param base_path Base path.
62+
#' @param user_agent User agent.
63+
#' @param default_headers Default headers.
64+
#' @param username User name.
65+
#' @param password Password.
66+
#' @param api_keys API keys.
67+
#' @param access_token Access token.
68+
#' @param timeout Timeout.
69+
#' @param retry_status_codes Status codes for retry.
70+
#' @param max_retry_attempts Maxmium number of retry.
71+
#' @export
5872
initialize = function(base_path=NULL, user_agent=NULL, default_headers=NULL,
5973
username=NULL, password=NULL, api_keys=NULL,
6074
access_token=NULL, timeout=NULL,
@@ -101,7 +115,19 @@ ApiClient <- R6::R6Class(
101115
self$max_retry_attempts <- max_retry_attempts
102116
}
103117
},
104-
118+
#' Prepare to make an API call with the retry logic.
119+
#'
120+
#' @description
121+
#' Prepare to make an API call with the retry logic.
122+
#'
123+
#' @param url URL.
124+
#' @param method HTTP method.
125+
#' @param query_params The query parameters.
126+
#' @param header_params The header parameters.
127+
#' @param body The HTTP request body.
128+
#' @param ... Other optional arguments.
129+
#' @return HTTP response
130+
#' @export
105131
CallApi = function(url, method, query_params, header_params, body, ...) {
106132
107133
resp <- self$Execute(url, method, query_params, header_params, body, ...)
@@ -126,7 +152,19 @@ ApiClient <- R6::R6Class(
126152
127153
resp
128154
},
129-
155+
#' Make an API call
156+
#'
157+
#' @description
158+
#' Make an API call
159+
#'
160+
#' @param url URL.
161+
#' @param method HTTP method.
162+
#' @param query_params The query parameters.
163+
#' @param header_params The header parameters.
164+
#' @param body The HTTP request body.
165+
#' @param ... Other optional arguments.
166+
#' @return HTTP response
167+
#' @export
130168
Execute = function(url, method, query_params, header_params, body, ...) {
131169
headers <- httr::add_headers(c(header_params, self$default_headers))
132170
@@ -158,18 +196,33 @@ ApiClient <- R6::R6Class(
158196
{{/useRlangExceptionHandling}}
159197
}
160198
},
161-
162-
# Deserialize the content of api response to the given type.
199+
#' Deserialize the content of api response to the given type.
200+
#'
201+
#' @description
202+
#' Deserialize the content of api response to the given type.
203+
#'
204+
#' @param resp Response object.
205+
#' @param return_type R return type.
206+
#' @param pkg_env Package environment.
207+
#' @return Deserialized object.
208+
#' @export
163209
deserialize = function(resp, return_type, pkg_env) {
164210
resp_obj <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
165211
self$deserializeObj(resp_obj, return_type, pkg_env)
166212
},
167213

168-
169-
# Deserialize the response from jsonlite object based on the given type
170-
# by handling complex and nested types by iterating recursively
171-
# Example return_types will be like "array[integer]", "map(Pet)", "array[map(Tag)]", etc.,
172-
214+
#' Deserialize the response from jsonlite object based on the given type
215+
#'
216+
#' @description
217+
#' Deserialize the response from jsonlite object based on the given type
218+
#' by handling complex and nested types by iterating recursively
219+
#' Example return_types will be like "array[integer]", "map(Pet)", "array[map(Tag)]", etc.,
220+
#'
221+
#' @param obj Response object.
222+
#' @param return_type R return type.
223+
#' @param pkg_env Package environment.
224+
#' @return Deserialized object.
225+
#' @export
173226
deserializeObj = function(obj, return_type, pkg_env) {
174227
return_obj <- NULL
175228
primitive_types <- c("character", "numeric", "integer", "logical", "complex")

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#'
2525
#' @param instance an instance of the object defined in the anyOf schemas: {{#anyOf}}"{{{.}}}"{{^-last}}, {{/-last}}{{/anyOf}}
2626
#' @export
27-
#' @md
2827
initialize = function(instance = NULL) {
2928
if (is.null(instance)) {
3029
# do nothing
@@ -43,7 +42,6 @@
4342
#' @param input The input JSON.
4443
#' @return An instance of {{{classname}}}.
4544
#' @export
46-
#' @md
4745
fromJSON = function(input) {
4846
error_messages <- list()
4947
@@ -73,7 +71,6 @@
7371
#'
7472
#' @return JSON string reprenation of the {{{classname}}}.
7573
#' @export
76-
#' @md
7774
toJSON = function() {
7875
if (!is.null(self$actual_instance)) {
7976
self$actual_instance$toJSONString()
@@ -89,7 +86,6 @@
8986
#'
9087
#' @param input The input JSON.
9188
#' @export
92-
#' @md
9389
validateJSON = function(input) {
9490
# backup current values
9591
actual_instance_bak <- self$actual_instance

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#'
2525
#' @param instance an instance of the object defined in the oneOf schemas: {{#oneOf}}"{{{.}}}"{{^-last}}, {{/-last}}{{/oneOf}}
2626
#' @export
27-
#' @md
2827
initialize = function(instance = NULL) {
2928
if (is.null(instance)) {
3029
# do nothing
@@ -43,7 +42,6 @@
4342
#' @param input The input JSON.
4443
#' @return An instance of {{{classname}}}.
4544
#' @export
46-
#' @md
4745
fromJSON = function(input) {
4846
matched <- 0 # match counter
4947
matched_schemas <- list() #names of matched schemas
@@ -88,7 +86,6 @@
8886
#'
8987
#' @return JSON string reprenation of the {{{classname}}}.
9088
#' @export
91-
#' @md
9289
toJSON = function() {
9390
if (!is.null(self$actual_instance)) {
9491
self$actual_instance$toJSONString()
@@ -104,7 +101,6 @@
104101
#'
105102
#' @param input The input JSON.
106103
#' @export
107-
#' @md
108104
validateJSON = function(input) {
109105
# backup current values
110106
actual_instance_bak <- self$actual_instance

samples/client/petstore/R/R/any_of_pig.R

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ AnyOfPig <- R6::R6Class(
3232
#'
3333
#' @param instance an instance of the object defined in the anyOf schemas: "BasquePig", "DanishPig"
3434
#' @export
35-
#' @md
3635
initialize = function(instance = NULL) {
3736
if (is.null(instance)) {
3837
# do nothing
@@ -54,7 +53,6 @@ AnyOfPig <- R6::R6Class(
5453
#' @param input The input JSON.
5554
#' @return An instance of AnyOfPig.
5655
#' @export
57-
#' @md
5856
fromJSON = function(input) {
5957
error_messages <- list()
6058

@@ -96,7 +94,6 @@ AnyOfPig <- R6::R6Class(
9694
#'
9795
#' @return JSON string reprenation of the AnyOfPig.
9896
#' @export
99-
#' @md
10097
toJSON = function() {
10198
if (!is.null(self$actual_instance)) {
10299
self$actual_instance$toJSONString()
@@ -112,7 +109,6 @@ AnyOfPig <- R6::R6Class(
112109
#'
113110
#' @param input The input JSON.
114111
#' @export
115-
#' @md
116112
validateJSON = function(input) {
117113
# backup current values
118114
actual_instance_bak <- self$actual_instance

samples/client/petstore/R/R/api_client.R

Lines changed: 67 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#' Generated by: https://openapi-generator.tech
77
#'
88

9-
109
#' ApiClient Class
1110
#'
1211
#' Generic API client for OpenAPI client library builds.
@@ -25,11 +24,11 @@
2524
#' @format An \code{R6Class} generator object
2625
#' @field base_path Base url
2726
#' @field user_agent Default user agent
28-
#' @field default_headers
27+
#' @field default_headers Default headers
2928
#' @field username Username for HTTP basic authentication
3029
#' @field password Password for HTTP basic authentication
31-
#' @field api_keys
32-
#' @field access_token
30+
#' @field api_keys API keys
31+
#' @field access_token Access token
3332
#' @field timeout Default timeout in seconds
3433
#' @field retry_status_codes vector of status codes to retry
3534
#' @field max_retry_attempts maximum number of retries for the status codes
@@ -59,7 +58,22 @@ ApiClient <- R6::R6Class(
5958
retry_status_codes = NULL,
6059
# Maximum number of retry attempts for the retry status codes
6160
max_retry_attempts = NULL,
62-
# constructor
61+
#' Initialize a new ApiClient.
62+
#'
63+
#' @description
64+
#' Initialize a new ApiClient.
65+
#'
66+
#' @param base_path Base path.
67+
#' @param user_agent User agent.
68+
#' @param default_headers Default headers.
69+
#' @param username User name.
70+
#' @param password Password.
71+
#' @param api_keys API keys.
72+
#' @param access_token Access token.
73+
#' @param timeout Timeout.
74+
#' @param retry_status_codes Status codes for retry.
75+
#' @param max_retry_attempts Maxmium number of retry.
76+
#' @export
6377
initialize = function(base_path=NULL, user_agent=NULL, default_headers=NULL,
6478
username=NULL, password=NULL, api_keys=NULL,
6579
access_token=NULL, timeout=NULL,
@@ -106,7 +120,19 @@ ApiClient <- R6::R6Class(
106120
self$max_retry_attempts <- max_retry_attempts
107121
}
108122
},
109-
123+
#' Prepare to make an API call with the retry logic.
124+
#'
125+
#' @description
126+
#' Prepare to make an API call with the retry logic.
127+
#'
128+
#' @param url URL.
129+
#' @param method HTTP method.
130+
#' @param query_params The query parameters.
131+
#' @param header_params The header parameters.
132+
#' @param body The HTTP request body.
133+
#' @param ... Other optional arguments.
134+
#' @return HTTP response
135+
#' @export
110136
CallApi = function(url, method, query_params, header_params, body, ...) {
111137

112138
resp <- self$Execute(url, method, query_params, header_params, body, ...)
@@ -131,7 +157,19 @@ ApiClient <- R6::R6Class(
131157

132158
resp
133159
},
134-
160+
#' Make an API call
161+
#'
162+
#' @description
163+
#' Make an API call
164+
#'
165+
#' @param url URL.
166+
#' @param method HTTP method.
167+
#' @param query_params The query parameters.
168+
#' @param header_params The header parameters.
169+
#' @param body The HTTP request body.
170+
#' @param ... Other optional arguments.
171+
#' @return HTTP response
172+
#' @export
135173
Execute = function(url, method, query_params, header_params, body, ...) {
136174
headers <- httr::add_headers(c(header_params, self$default_headers))
137175

@@ -157,18 +195,33 @@ ApiClient <- R6::R6Class(
157195
rlang::abort(message = err_msg, .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = err_msg))
158196
}
159197
},
160-
161-
# Deserialize the content of api response to the given type.
198+
#' Deserialize the content of api response to the given type.
199+
#'
200+
#' @description
201+
#' Deserialize the content of api response to the given type.
202+
#'
203+
#' @param resp Response object.
204+
#' @param return_type R return type.
205+
#' @param pkg_env Package environment.
206+
#' @return Deserialized object.
207+
#' @export
162208
deserialize = function(resp, return_type, pkg_env) {
163209
resp_obj <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
164210
self$deserializeObj(resp_obj, return_type, pkg_env)
165211
},
166212

167-
168-
# Deserialize the response from jsonlite object based on the given type
169-
# by handling complex and nested types by iterating recursively
170-
# Example return_types will be like "array[integer]", "map(Pet)", "array[map(Tag)]", etc.,
171-
213+
#' Deserialize the response from jsonlite object based on the given type
214+
#'
215+
#' @description
216+
#' Deserialize the response from jsonlite object based on the given type
217+
#' by handling complex and nested types by iterating recursively
218+
#' Example return_types will be like "array[integer]", "map(Pet)", "array[map(Tag)]", etc.,
219+
#'
220+
#' @param obj Response object.
221+
#' @param return_type R return type.
222+
#' @param pkg_env Package environment.
223+
#' @return Deserialized object.
224+
#' @export
172225
deserializeObj = function(obj, return_type, pkg_env) {
173226
return_obj <- NULL
174227
primitive_types <- c("character", "numeric", "integer", "logical", "complex")

samples/client/petstore/R/R/pig.R

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ Pig <- R6::R6Class(
3232
#'
3333
#' @param instance an instance of the object defined in the oneOf schemas: "BasquePig", "DanishPig"
3434
#' @export
35-
#' @md
3635
initialize = function(instance = NULL) {
3736
if (is.null(instance)) {
3837
# do nothing
@@ -54,7 +53,6 @@ Pig <- R6::R6Class(
5453
#' @param input The input JSON.
5554
#' @return An instance of Pig.
5655
#' @export
57-
#' @md
5856
fromJSON = function(input) {
5957
matched <- 0 # match counter
6058
matched_schemas <- list() #names of matched schemas
@@ -112,7 +110,6 @@ Pig <- R6::R6Class(
112110
#'
113111
#' @return JSON string reprenation of the Pig.
114112
#' @export
115-
#' @md
116113
toJSON = function() {
117114
if (!is.null(self$actual_instance)) {
118115
self$actual_instance$toJSONString()
@@ -128,7 +125,6 @@ Pig <- R6::R6Class(
128125
#'
129126
#' @param input The input JSON.
130127
#' @export
131-
#' @md
132128
validateJSON = function(input) {
133129
# backup current values
134130
actual_instance_bak <- self$actual_instance

0 commit comments

Comments
 (0)