Skip to content

Commit ed3666f

Browse files
authored
[R] Minor improvements to the documentation (#13226)
* minor improvement to r doc * better scopes
1 parent 18bb546 commit ed3666f

File tree

17 files changed

+107
-116
lines changed

17 files changed

+107
-116
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,20 @@ Class | Method | HTTP request | Description
115115
- **Refresh URL**: {{refreshUrl}}
116116
{{/refreshUrl}}
117117
- **Scopes**: {{^scopes}}N/A{{/scopes}}
118-
{{#scopes}} - {{scope}}: {{description}}
118+
{{#scopes}} - `{{scope}}`: {{description}}
119119
{{/scopes}}
120120
{{/isOAuth}}
121121

122122
{{/authMethods}}
123123

124-
124+
{{#apiInfo}}
125+
{{#apis}}
126+
{{#-last}}
127+
{{#infoEmail}}
125128
## Author
126129

127-
{{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}}
128-
{{/-last}}{{/apis}}{{/apiInfo}}
130+
{{{infoEmail}}}
131+
{{/infoEmail}}
132+
{{/-last}}
133+
{{/apis}}
134+
{{/apiInfo}}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var_{{{paramName}}} <- {{{vendorExtensions.x-r-example}}} # {{{dataType}}} | {{{
2626
{{/allParams}}
2727

2828
{{#summary}}
29-
#{{{.}}}
29+
# {{{.}}}
3030
{{/summary}}
3131
{{#generateWrapper}}
3232
api_instance <- {{#lambda.lowercase}}{{{packageName}}}{{/lambda.lowercase}}_api$new()
@@ -62,10 +62,10 @@ api_instance$api_client$access_token <- Sys.getenv("ACCESS_TOKEN")
6262
result <- tryCatch(
6363
{{#returnType}}
6464
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
65-
# api_instance${{{operationId}}}({{#requiredParams}}var_{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-first}}{{#requiredParams.0}}, {{/requiredParams.0}}{{/-first}}{{{paramName}}} = var_{{{paramName}}}{{^-last}}, {{/-last}}{{/optionalParams}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}data_file = "result.txt"),
65+
# api_instance{{#generateWrapper}}${{#lambda.snakecase}}{{{classname}}}{{/lambda.snakecase}}{{/generateWrapper}}${{{operationId}}}({{#requiredParams}}var_{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-first}}{{#requiredParams.0}}, {{/requiredParams.0}}{{/-first}}{{{paramName}}} = var_{{{paramName}}}{{^-last}}, {{/-last}}{{/optionalParams}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}data_file = "result.txt"),
6666
{{#vendorExtensions.x-streaming}}
6767
# this endpoint supports data streaming via a callback function using the optional `stream_callback` parameter, e.g.
68-
# api_instance${{{operationId}}}({{#requiredParams}}var_{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-first}}{{#requiredParams.0}}, {{/requiredParams.0}}{{/-first}}{{{paramName}}} = var_{{{paramName}}}{{^-last}}, {{/-last}}{{/optionalParams}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}stream_callback = function(x){ print(length(x)) }),
68+
# api_instance{{#generateWrapper}}${{#lambda.snakecase}}{{{classname}}}{{/lambda.snakecase}}{{/generateWrapper}}${{{operationId}}}({{#requiredParams}}var_{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-first}}{{#requiredParams.0}}, {{/requiredParams.0}}{{/-first}}{{{paramName}}} = var_{{{paramName}}}{{^-last}}, {{/-last}}{{/optionalParams}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}stream_callback = function(x){ print(length(x)) }),
6969
{{/vendorExtensions.x-streaming}}
7070
{{/returnType}}
7171
api_instance{{#generateWrapper}}${{#lambda.snakecase}}{{{classname}}}{{/lambda.snakecase}}{{/generateWrapper}}${{{operationId}}}({{#requiredParams}}var_{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-first}}{{#requiredParams.0}}, {{/requiredParams.0}}{{/-first}}{{{paramName}}} = var_{{{paramName}}}{{^-last}}, {{/-last}}{{/optionalParams}}),

samples/client/petstore/R-httr2-wrapper/README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,7 @@ Class | Method | HTTP request | Description
133133
- **Flow**: implicit
134134
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
135135
- **Scopes**:
136-
- write:pets: modify pets in your account
137-
- read:pets: read your pets
138-
139-
140-
141-
## Author
142-
136+
- `write:pets`: modify pets in your account
137+
- `read:pets`: read your pets
143138

144139

samples/client/petstore/R-httr2-wrapper/docs/FakeApi.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ library(petstore)
2222
var_dummy <- "dummy_example" # character | dummy required parameter
2323
var_var_data_file <- "var_data_file_example" # character | header data file (Optional)
2424

25-
#test data_file to ensure it's escaped correctly
25+
# test data_file to ensure it's escaped correctly
2626
api_instance <- petstore_api$new()
2727
result <- tryCatch(
2828
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
29-
# api_instance$fake_data_file(var_dummy, var_data_file = var_var_data_file, data_file = "result.txt"),
29+
# api_instance$fake_api$fake_data_file(var_dummy, var_data_file = var_var_data_file, data_file = "result.txt"),
3030
api_instance$fake_api$fake_data_file(var_dummy, var_data_file = var_var_data_file),
3131
ApiException = function(ex) ex
3232
)
@@ -82,7 +82,7 @@ library(petstore)
8282

8383
var_reg_exp_test <- "reg_exp_test_example" # character | dummy required parameter
8484

85-
#test regular expression to ensure no exception
85+
# test regular expression to ensure no exception
8686
api_instance <- petstore_api$new()
8787
result <- tryCatch(
8888
api_instance$fake_api$fake_regular_expression(var_reg_exp_test),

samples/client/petstore/R-httr2-wrapper/docs/PetApi.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ library(petstore)
2929

3030
var_pet <- Pet$new("name_example", list("photoUrls_example"), 123, Category$new(123, "name_example"), list(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
3131

32-
#Add a new pet to the store
32+
# Add a new pet to the store
3333
api_instance <- petstore_api$new()
3434
# Configure HTTP basic authorization: http_auth
3535
api_instance$api_client$username <- Sys.getenv("USERNAME")
3636
api_instance$api_client$password <- Sys.getenv("PASSWORD")
3737
result <- tryCatch(
3838
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
39-
# api_instance$add_pet(var_pet, data_file = "result.txt"),
39+
# api_instance$pet_api$add_pet(var_pet, data_file = "result.txt"),
4040
api_instance$pet_api$add_pet(var_pet),
4141
ApiException = function(ex) ex
4242
)
@@ -93,7 +93,7 @@ library(petstore)
9393
var_pet_id <- 56 # integer | Pet id to delete
9494
var_api_key <- "api_key_example" # character | (Optional)
9595

96-
#Deletes a pet
96+
# Deletes a pet
9797
api_instance <- petstore_api$new()
9898
# Configure OAuth2 access token for authorization: petstore_auth
9999
api_instance$api_client$access_token <- Sys.getenv("ACCESS_TOKEN")
@@ -149,13 +149,13 @@ library(petstore)
149149

150150
var_status <- list("available") # array[character] | Status values that need to be considered for filter
151151

152-
#Finds Pets by status
152+
# Finds Pets by status
153153
api_instance <- petstore_api$new()
154154
# Configure OAuth2 access token for authorization: petstore_auth
155155
api_instance$api_client$access_token <- Sys.getenv("ACCESS_TOKEN")
156156
result <- tryCatch(
157157
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
158-
# api_instance$find_pets_by_status(var_status, data_file = "result.txt"),
158+
# api_instance$pet_api$find_pets_by_status(var_status, data_file = "result.txt"),
159159
api_instance$pet_api$find_pets_by_status(var_status),
160160
ApiException = function(ex) ex
161161
)
@@ -211,13 +211,13 @@ library(petstore)
211211

212212
var_tags <- list("inner_example") # array[character] | Tags to filter by
213213

214-
#Finds Pets by tags
214+
# Finds Pets by tags
215215
api_instance <- petstore_api$new()
216216
# Configure OAuth2 access token for authorization: petstore_auth
217217
api_instance$api_client$access_token <- Sys.getenv("ACCESS_TOKEN")
218218
result <- tryCatch(
219219
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
220-
# api_instance$find_pets_by_tags(var_tags, data_file = "result.txt"),
220+
# api_instance$pet_api$find_pets_by_tags(var_tags, data_file = "result.txt"),
221221
api_instance$pet_api$find_pets_by_tags(var_tags),
222222
ApiException = function(ex) ex
223223
)
@@ -273,13 +273,13 @@ library(petstore)
273273

274274
var_pet_id <- 56 # integer | ID of pet to return
275275

276-
#Find pet by ID
276+
# Find pet by ID
277277
api_instance <- petstore_api$new()
278278
# Configure HTTP bearer authorization: BearerToken
279279
api_instance$api_client$bearer_token <- Sys.getenv("BEARER_TOKEN")
280280
result <- tryCatch(
281281
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
282-
# api_instance$get_pet_by_id(var_pet_id, data_file = "result.txt"),
282+
# api_instance$pet_api$get_pet_by_id(var_pet_id, data_file = "result.txt"),
283283
api_instance$pet_api$get_pet_by_id(var_pet_id),
284284
ApiException = function(ex) ex
285285
)
@@ -336,15 +336,15 @@ library(petstore)
336336

337337
var_pet_id <- 56 # integer | ID of pet to return
338338

339-
#Find pet by ID (streaming)
339+
# Find pet by ID (streaming)
340340
api_instance <- petstore_api$new()
341341
# Configure API key authorization: api_key
342342
api_instance$api_client$api_keys["api_key"] <- Sys.getenv("API_KEY")
343343
result <- tryCatch(
344344
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
345-
# api_instance$get_pet_by_id_streaming(var_pet_id, data_file = "result.txt"),
345+
# api_instance$pet_api$get_pet_by_id_streaming(var_pet_id, data_file = "result.txt"),
346346
# this endpoint supports data streaming via a callback function using the optional `stream_callback` parameter, e.g.
347-
# api_instance$get_pet_by_id_streaming(var_pet_id, stream_callback = function(x){ print(length(x)) }),
347+
# api_instance$pet_api$get_pet_by_id_streaming(var_pet_id, stream_callback = function(x){ print(length(x)) }),
348348
api_instance$pet_api$get_pet_by_id_streaming(var_pet_id),
349349
ApiException = function(ex) ex
350350
)
@@ -401,15 +401,15 @@ library(petstore)
401401

402402
var_header_test_int <- 56 # integer | header test int
403403

404-
#Header test
404+
# Header test
405405
api_instance <- petstore_api$new()
406406
# Configure API key authorization: api_key
407407
api_instance$api_client$api_keys["api_key"] <- Sys.getenv("API_KEY")
408408
result <- tryCatch(
409409
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
410-
# api_instance$test_header(var_header_test_int, data_file = "result.txt"),
410+
# api_instance$pet_api$test_header(var_header_test_int, data_file = "result.txt"),
411411
# this endpoint supports data streaming via a callback function using the optional `stream_callback` parameter, e.g.
412-
# api_instance$test_header(var_header_test_int, stream_callback = function(x){ print(length(x)) }),
412+
# api_instance$pet_api$test_header(var_header_test_int, stream_callback = function(x){ print(length(x)) }),
413413
api_instance$pet_api$test_header(var_header_test_int),
414414
ApiException = function(ex) ex
415415
)
@@ -466,13 +466,13 @@ library(petstore)
466466

467467
var_pet <- Pet$new("name_example", list("photoUrls_example"), 123, Category$new(123, "name_example"), list(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
468468

469-
#Update an existing pet
469+
# Update an existing pet
470470
api_instance <- petstore_api$new()
471471
# Configure OAuth2 access token for authorization: petstore_auth
472472
api_instance$api_client$access_token <- Sys.getenv("ACCESS_TOKEN")
473473
result <- tryCatch(
474474
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
475-
# api_instance$update_pet(var_pet, data_file = "result.txt"),
475+
# api_instance$pet_api$update_pet(var_pet, data_file = "result.txt"),
476476
api_instance$pet_api$update_pet(var_pet),
477477
ApiException = function(ex) ex
478478
)
@@ -532,7 +532,7 @@ var_pet_id <- 56 # integer | ID of pet that needs to be updated
532532
var_name <- "name_example" # character | Updated name of the pet (Optional)
533533
var_status <- "status_example" # character | Updated status of the pet (Optional)
534534

535-
#Updates a pet in the store with form data
535+
# Updates a pet in the store with form data
536536
api_instance <- petstore_api$new()
537537
result <- tryCatch(
538538
api_instance$pet_api$update_pet_with_form(var_pet_id, name = var_name, status = var_status),
@@ -589,13 +589,13 @@ var_pet_id <- 56 # integer | ID of pet to update
589589
var_additional_metadata <- "additional_metadata_example" # character | Additional data to pass to server (Optional)
590590
var_file <- File.new('/path/to/file') # data.frame | file to upload (Optional)
591591

592-
#uploads an image
592+
# uploads an image
593593
api_instance <- petstore_api$new()
594594
# Configure OAuth2 access token for authorization: petstore_auth
595595
api_instance$api_client$access_token <- Sys.getenv("ACCESS_TOKEN")
596596
result <- tryCatch(
597597
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
598-
# api_instance$upload_file(var_pet_id, additional_metadata = var_additional_metadata, file = var_file, data_file = "result.txt"),
598+
# api_instance$pet_api$upload_file(var_pet_id, additional_metadata = var_additional_metadata, file = var_file, data_file = "result.txt"),
599599
api_instance$pet_api$upload_file(var_pet_id, additional_metadata = var_additional_metadata, file = var_file),
600600
ApiException = function(ex) ex
601601
)

samples/client/petstore/R-httr2-wrapper/docs/StoreApi.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ library(petstore)
2323

2424
var_order_id <- "order_id_example" # character | ID of the order that needs to be deleted
2525

26-
#Delete purchase order by ID
26+
# Delete purchase order by ID
2727
api_instance <- petstore_api$new()
2828
result <- tryCatch(
2929
api_instance$store_api$delete_order(var_order_id),
@@ -76,13 +76,13 @@ Returns a map of status codes to quantities
7676
library(petstore)
7777

7878

79-
#Returns pet inventories by status
79+
# Returns pet inventories by status
8080
api_instance <- petstore_api$new()
8181
# Configure API key authorization: api_key
8282
api_instance$api_client$api_keys["api_key"] <- Sys.getenv("API_KEY")
8383
result <- tryCatch(
8484
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
85-
# api_instance$get_inventory(data_file = "result.txt"),
85+
# api_instance$store_api$get_inventory(data_file = "result.txt"),
8686
api_instance$store_api$get_inventory(),
8787
ApiException = function(ex) ex
8888
)
@@ -134,11 +134,11 @@ library(petstore)
134134

135135
var_order_id <- 56 # integer | ID of pet that needs to be fetched
136136

137-
#Find purchase order by ID
137+
# Find purchase order by ID
138138
api_instance <- petstore_api$new()
139139
result <- tryCatch(
140140
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
141-
# api_instance$get_order_by_id(var_order_id, data_file = "result.txt"),
141+
# api_instance$store_api$get_order_by_id(var_order_id, data_file = "result.txt"),
142142
api_instance$store_api$get_order_by_id(var_order_id),
143143
ApiException = function(ex) ex
144144
)
@@ -195,11 +195,11 @@ library(petstore)
195195

196196
var_order <- Order$new(123, 123, 123, "shipDate_example", "placed", "complete_example") # Order | order placed for purchasing the pet
197197

198-
#Place an order for a pet
198+
# Place an order for a pet
199199
api_instance <- petstore_api$new()
200200
result <- tryCatch(
201201
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
202-
# api_instance$place_order(var_order, data_file = "result.txt"),
202+
# api_instance$store_api$place_order(var_order, data_file = "result.txt"),
203203
api_instance$store_api$place_order(var_order),
204204
ApiException = function(ex) ex
205205
)

samples/client/petstore/R-httr2-wrapper/docs/UserApi.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ library(petstore)
2727

2828
var_user <- User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123) # User | Created user object
2929

30-
#Create user
30+
# Create user
3131
api_instance <- petstore_api$new()
3232
# Configure API key authorization: api_key
3333
api_instance$api_client$api_keys["api_key"] <- Sys.getenv("API_KEY")
@@ -82,7 +82,7 @@ library(petstore)
8282

8383
var_user <- list(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
8484

85-
#Creates list of users with given input array
85+
# Creates list of users with given input array
8686
api_instance <- petstore_api$new()
8787
# Configure API key authorization: api_key
8888
api_instance$api_client$api_keys["api_key"] <- Sys.getenv("API_KEY")
@@ -137,7 +137,7 @@ library(petstore)
137137

138138
var_user <- list(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
139139

140-
#Creates list of users with given input array
140+
# Creates list of users with given input array
141141
api_instance <- petstore_api$new()
142142
# Configure API key authorization: api_key
143143
api_instance$api_client$api_keys["api_key"] <- Sys.getenv("API_KEY")
@@ -192,7 +192,7 @@ library(petstore)
192192

193193
var_username <- "username_example" # character | The name that needs to be deleted
194194

195-
#Delete user
195+
# Delete user
196196
api_instance <- petstore_api$new()
197197
# Configure API key authorization: api_key
198198
api_instance$api_client$api_keys["api_key"] <- Sys.getenv("API_KEY")
@@ -248,11 +248,11 @@ library(petstore)
248248

249249
var_username <- "username_example" # character | The name that needs to be fetched. Use user1 for testing.
250250

251-
#Get user by user name
251+
# Get user by user name
252252
api_instance <- petstore_api$new()
253253
result <- tryCatch(
254254
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
255-
# api_instance$get_user_by_name(var_username, data_file = "result.txt"),
255+
# api_instance$user_api$get_user_by_name(var_username, data_file = "result.txt"),
256256
api_instance$user_api$get_user_by_name(var_username),
257257
ApiException = function(ex) ex
258258
)
@@ -310,11 +310,11 @@ library(petstore)
310310
var_username <- "username_example" # character | The user name for login
311311
var_password <- "password_example" # character | The password for login in clear text
312312

313-
#Logs user into the system
313+
# Logs user into the system
314314
api_instance <- petstore_api$new()
315315
result <- tryCatch(
316316
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
317-
# api_instance$login_user(var_username, var_password, data_file = "result.txt"),
317+
# api_instance$user_api$login_user(var_username, var_password, data_file = "result.txt"),
318318
api_instance$user_api$login_user(var_username, var_password),
319319
ApiException = function(ex) ex
320320
)
@@ -370,7 +370,7 @@ Logs out current logged in user session
370370
library(petstore)
371371

372372

373-
#Logs out current logged in user session
373+
# Logs out current logged in user session
374374
api_instance <- petstore_api$new()
375375
# Configure API key authorization: api_key
376376
api_instance$api_client$api_keys["api_key"] <- Sys.getenv("API_KEY")
@@ -423,7 +423,7 @@ library(petstore)
423423
var_username <- "username_example" # character | name that need to be deleted
424424
var_user <- User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123) # User | Updated user object
425425

426-
#Updated user
426+
# Updated user
427427
api_instance <- petstore_api$new()
428428
# Configure API key authorization: api_key
429429
api_instance$api_client$api_keys["api_key"] <- Sys.getenv("API_KEY")

samples/client/petstore/R-httr2/README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,7 @@ Class | Method | HTTP request | Description
133133
- **Flow**: implicit
134134
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
135135
- **Scopes**:
136-
- write:pets: modify pets in your account
137-
- read:pets: read your pets
138-
139-
140-
141-
## Author
142-
136+
- `write:pets`: modify pets in your account
137+
- `read:pets`: read your pets
143138

144139

0 commit comments

Comments
 (0)