diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java index bc9ee0f8432b..74cfe07f1f09 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java @@ -732,7 +732,11 @@ public String constructExampleCode(CodegenProperty codegenProperty, HashMap) codegenProperty.allowableValues.get("values")).get(0)) + "\""; + } else { + return "\"" + codegenProperty.name + "_example\""; + } } } else { // numeric if (StringUtils.isEmpty(codegenProperty.example)) { @@ -756,9 +760,16 @@ public String constructExampleCode(CodegenModel codegenModel, HashMap 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; diff --git a/samples/client/petstore/R/docs/PetApi.md b/samples/client/petstore/R/docs/PetApi.md index 971e94cf453a..b6739b621972 100644 --- a/samples/client/petstore/R/docs/PetApi.md +++ b/samples/client/petstore/R/docs/PetApi.md @@ -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() @@ -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() @@ -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() diff --git a/samples/client/petstore/R/docs/StoreApi.md b/samples/client/petstore/R/docs/StoreApi.md index 8ff91cfe8116..9ffccdc5fe3c 100644 --- a/samples/client/petstore/R/docs/StoreApi.md +++ b/samples/client/petstore/R/docs/StoreApi.md @@ -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()