Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix auto-generated R doc #8584

Merged
merged 3 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,11 @@ public String constructExampleCode(CodegenProperty codegenProperty, HashMap<Stri
if (StringUtils.isEmpty(codegenProperty.example)) {
return "\"" + codegenProperty.example + "\"";
} else {
return "\"" + codegenProperty.name + "_example\"";
if (Boolean.TRUE.equals(codegenProperty.isEnum)) { // enum
return "\"" + String.valueOf(((List<Object>) codegenProperty.allowableValues.get("values")).get(0)) + "\"";
} else {
return "\"" + codegenProperty.name + "_example\"";
}
}
} else { // numeric
if (StringUtils.isEmpty(codegenProperty.example)) {
Expand All @@ -756,9 +760,16 @@ public String constructExampleCode(CodegenModel codegenModel, HashMap<String, Co
String example;
example = codegenModel.name + "$new(";
List<String> propertyExamples = new ArrayList<>();
for (CodegenProperty codegenProperty : codegenModel.vars) {
// required properties first
for (CodegenProperty codegenProperty : codegenModel.requiredVars) {
propertyExamples.add(constructExampleCode(codegenProperty, modelMaps));
}

// optional properties second
for (CodegenProperty codegenProperty : codegenModel.optionalVars) {
propertyExamples.add(constructExampleCode(codegenProperty, modelMaps));
}

example += StringUtils.join(propertyExamples, ", ");
example += ")";
return example;
Expand Down
6 changes: 3 additions & 3 deletions samples/client/petstore/R/docs/PetApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Add a new pet to the store
```R
library(petstore)

var.body <- Pet$new(123, Category$new(123, "name_example"), "name_example", list("photoUrls_example"), list(Tag$new(123, "name_example")), "status_example") # Pet | Pet object that needs to be added to the store
var.body <- 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

#Add a new pet to the store
api.instance <- PetApi$new()
Expand Down Expand Up @@ -111,7 +111,7 @@ Multiple status values can be provided with comma separated strings
```R
library(petstore)

var.status <- list("status_example") # array[character] | Status values that need to be considered for filter
var.status <- list("available") # array[character] | Status values that need to be considered for filter

#Finds Pets by status
api.instance <- PetApi$new()
Expand Down Expand Up @@ -248,7 +248,7 @@ Update an existing pet
```R
library(petstore)

var.body <- Pet$new(123, Category$new(123, "name_example"), "name_example", list("photoUrls_example"), list(Tag$new(123, "name_example")), "status_example") # Pet | Pet object that needs to be added to the store
var.body <- 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

#Update an existing pet
api.instance <- PetApi$new()
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/R/docs/StoreApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Place an order for a pet
```R
library(petstore)

var.body <- Order$new(123, 123, 123, "shipDate_example", "status_example", "complete_example") # Order | order placed for purchasing the pet
var.body <- Order$new(123, 123, 123, "shipDate_example", "placed", "complete_example") # Order | order placed for purchasing the pet

#Place an order for a pet
api.instance <- StoreApi$new()
Expand Down