Skip to content

Commit 863dbc7

Browse files
authored
r better doc (#13447)
1 parent 7e87b5d commit 863dbc7

38 files changed

Lines changed: 259 additions & 111 deletions

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ Method | HTTP request | Description
2121
```R
2222
library({{{packageName}}})
2323

24+
{{#summary}}
25+
# {{{.}}}
26+
#
27+
{{/summary}}
2428
{{#allParams}}
29+
{{#-first}}
30+
# prepare function argument(s)
31+
{{/-first}}
2532
var_{{{paramName}}} <- {{{vendorExtensions.x-r-example}}} # {{{dataType}}} | {{{description}}}{{^required}} (Optional){{/required}}
2633
{{/allParams}}
2734

28-
{{#summary}}
29-
# {{{.}}}
30-
{{/summary}}
3135
{{#generateWrapper}}
3236
api_instance <- {{#lambda.lowercase}}{{{packageName}}}{{/lambda.lowercase}}_api$new()
3337
{{/generateWrapper}}
@@ -39,21 +43,21 @@ api_instance <- {{{classname}}}$new()
3943
{{#isBasic}}
4044
{{#isBasicBasic}}
4145
# Configure HTTP basic authorization: {{{name}}}
42-
api_instance$api_client$username <- Sys.getenv("USERNAME")
43-
api_instance$api_client$password <- Sys.getenv("PASSWORD")
46+
{{^-first}}# {{/-first}}api_instance$api_client$username <- Sys.getenv("USERNAME")
47+
{{^-first}}# {{/-first}}api_instance$api_client$password <- Sys.getenv("PASSWORD")
4448
{{/isBasicBasic}}
4549
{{#isBasicBearer}}
4650
# Configure HTTP bearer authorization: {{{name}}}
47-
api_instance$api_client$bearer_token <- Sys.getenv("BEARER_TOKEN")
51+
{{^-first}}# {{/-first}}api_instance$api_client$bearer_token <- Sys.getenv("BEARER_TOKEN")
4852
{{/isBasicBearer}}
4953
{{/isBasic}}
5054
{{#isApiKey}}
5155
# Configure API key authorization: {{{name}}}
52-
api_instance$api_client$api_keys["{{{keyParamName}}}"] <- Sys.getenv("API_KEY")
56+
{{^-first}}# {{/-first}}api_instance$api_client$api_keys["{{{keyParamName}}}"] <- Sys.getenv("API_KEY")
5357
{{/isApiKey}}
5458
{{#isOAuth}}
5559
# Configure OAuth2 access token for authorization: {{{name}}}
56-
api_instance$api_client$access_token <- Sys.getenv("ACCESS_TOKEN")
60+
{{^-first}}# {{/-first}}api_instance$api_client$access_token <- Sys.getenv("ACCESS_TOKEN")
5761
{{/isOAuth}}
5862
{{/authMethods}}
5963
{{/hasAuthMethods}}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
## Properties
77
Name | Type | Description | Notes
88
------------ | ------------- | ------------- | -------------
9-
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{.}}]{{/defaultValue}}
9+
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{.}}] {{/defaultValue}}{{#maximum}}[Max: {{{.}}}] {{/maximum}}{{#minimum}}[Min: {{{.}}}] {{/minimum}}{{#isEnum}}[Enum: {{_enum}}] {{/isEnum}}{{#pattern}}[Pattern: {{.}}] {{/pattern}}{{#maxItems}}[Max. items: {{.}}] {{/maxItems}}{{#minItems}}[Min. items: {{.}}] {{/minItems}}{{#maxLength}}[Max. length: {{.}}] {{/maxLength}}{{#minLength}}[Min. length: {{.}}] {{/minLength}}
1010
{{/vars}}
1111

1212
{{/model}}{{/models}}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**className** | **character** | |
8-
**color** | **character** | | [optional] [default to &quot;red&quot;]
8+
**color** | **character** | | [optional] [default to &quot;red&quot;]
99

1010

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**className** | **character** | |
8-
**color** | **character** | | [optional] [default to &quot;red&quot;]
8+
**color** | **character** | | [optional] [default to &quot;red&quot;]
99
**declawed** | **character** | | [optional]
1010

1111

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ A category for a pet
66
Name | Type | Description | Notes
77
------------ | ------------- | ------------- | -------------
88
**id** | **integer** | | [optional]
9-
**name** | **character** | | [optional]
9+
**name** | **character** | | [optional] [Pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$]
1010

1111

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**className** | **character** | |
8-
**color** | **character** | | [optional] [default to &quot;red&quot;]
8+
**color** | **character** | | [optional] [default to &quot;red&quot;]
99
**breed** | **character** | | [optional]
1010

1111

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ test data_file to ensure it's escaped correctly
2020
```R
2121
library(petstore)
2222

23+
# test data_file to ensure it's escaped correctly
24+
#
25+
# prepare function argument(s)
2326
var_dummy <- "dummy_example" # character | dummy required parameter
2427
var_var_data_file <- "var_data_file_example" # character | header data file (Optional)
2528

26-
# test data_file to ensure it's escaped correctly
2729
api_instance <- petstore_api$new()
2830
result <- tryCatch(
2931
# to save the result into a file, simply add the optional `data_file` parameter, e.g.
@@ -81,9 +83,11 @@ test regular expression to ensure no exception
8183
```R
8284
library(petstore)
8385

86+
# test regular expression to ensure no exception
87+
#
88+
# prepare function argument(s)
8489
var_reg_exp_test <- "reg_exp_test_example" # character | dummy required parameter
8590

86-
# test regular expression to ensure no exception
8791
api_instance <- petstore_api$new()
8892
result <- tryCatch(
8993
api_instance$fake_api$fake_regular_expression(var_reg_exp_test),
@@ -134,10 +138,12 @@ test set query parameter
134138
```R
135139
library(petstore)
136140

141+
# test set query parameter
142+
#
143+
# prepare function argument(s)
137144
var_set_dummy <- list("inner_example") # set[character] | set query
138145
var_array_dummy <- list("inner_example") # array[character] | array query
139146

140-
# test set query parameter
141147
api_instance <- petstore_api$new()
142148
result <- tryCatch(
143149
api_instance$fake_api$fake_set_query(var_set_dummy, var_array_dummy),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ Name | Type | Description | Notes
77
**hasBaleen** | **character** | | [optional]
88
**hasTeeth** | **character** | | [optional]
99
**className** | **character** | |
10-
**type** | **character** | | [optional]
10+
**type** | **character** | | [optional] [Enum: [plains, mountain, grevys]]
1111

1212

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Name | Type | Description | Notes
99
**petId** | **integer** | | [optional]
1010
**quantity** | **integer** | | [optional]
1111
**shipDate** | **character** | | [optional]
12-
**status** | **character** | Order Status | [optional]
13-
**complete** | **character** | | [optional] [default to FALSE]
12+
**status** | **character** | Order Status | [optional] [Enum: [placed, approved, delivered]]
13+
**complete** | **character** | | [optional] [default to FALSE]
1414

1515

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ Name | Type | Description | Notes
1010
**name** | **character** | |
1111
**photoUrls** | **array[character]** | |
1212
**tags** | [**array[Tag]**](Tag.md) | | [optional]
13-
**status** | **character** | pet status in the store | [optional]
13+
**status** | **character** | pet status in the store | [optional] [Enum: [available, pending, sold]]
1414

1515

0 commit comments

Comments
 (0)