Skip to content

Commit

Permalink
fix default value for abstract scala and scalatra server impl (OpenAP…
Browse files Browse the repository at this point in the history
  • Loading branch information
chameleon82 authored and MikailBag committed Mar 23, 2020
1 parent ad51113 commit c0608c1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public String toDefaultValue(Schema p) {
"Iterable".equals(genericType) ||
"ListSet".equals(genericType)
) {
return genericType + "[" + inner + "].empty ";
return genericType + ".empty[" + inner + "] ";
}

// Assume that any other generic types can be new'd up.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ public ScalatraServerCodegen() {
supportingFiles.add(new SupportingFile("project/plugins.sbt", "project", "plugins.sbt"));
supportingFiles.add(new SupportingFile("sbt", "", "sbt"));

instantiationTypes.put("map", "HashMap");

importMapping = new HashMap<String, String>();
importMapping.put("BigDecimal", "java.math.BigDecimal");
importMapping.put("UUID", "java.util.UUID");
Expand All @@ -138,6 +136,8 @@ public ScalatraServerCodegen() {
importMapping.put("Set", "scala.collection.immutable.Set");
importMapping.put("ListSet", "scala.collection.immutable.ListSet");

instantiationTypes.put("array", "List");
instantiationTypes.put("map", "HashMap");
instantiationTypes.put("set", "Set");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void complexSetPropertyTest() {
Assert.assertEquals(property1.setter, "setChildren");
Assert.assertEquals(property1.dataType, "Set[Children]");
Assert.assertEquals(property1.name, "children");
Assert.assertEquals(property1.defaultValue, "Set[Children].empty ");
Assert.assertEquals(property1.defaultValue, "Set.empty[Children] ");
Assert.assertEquals(property1.baseType, "Set");
Assert.assertEquals(property1.containerType, "set");
Assert.assertFalse(property1.required);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class PetApi(implicit val swagger: Swagger) extends ScalatraServlet

val findPetsByStatusOperation = (apiOperation[List[Pet]]("findPetsByStatus")
summary "Finds Pets by status"
parameters(queryParam[List[String]]("status").description(""))
parameters(queryParam[List[String]]("status").description("").defaultValue(List.empty[String] ))
)

get("/pet/findByStatus", operation(findPetsByStatusOperation)) {
Expand All @@ -88,7 +88,7 @@ class PetApi(implicit val swagger: Swagger) extends ScalatraServlet

val findPetsByTagsOperation = (apiOperation[List[Pet]]("findPetsByTags")
summary "Finds Pets by tags"
parameters(queryParam[List[String]]("tags").description(""))
parameters(queryParam[List[String]]("tags").description("").defaultValue(List.empty[String] ))
)

get("/pet/findByTags", operation(findPetsByTagsOperation)) {
Expand Down

0 comments on commit c0608c1

Please sign in to comment.