forked from loafle/openapi-generator-original
fix default value for abstract scala and scalatra server impl (#5578)
This commit is contained in:
parent
27175c71df
commit
b40257f53a
@ -347,7 +347,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
|
|||||||
"Iterable".equals(genericType) ||
|
"Iterable".equals(genericType) ||
|
||||||
"ListSet".equals(genericType)
|
"ListSet".equals(genericType)
|
||||||
) {
|
) {
|
||||||
return genericType + "[" + inner + "].empty ";
|
return genericType + ".empty[" + inner + "] ";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assume that any other generic types can be new'd up.
|
// Assume that any other generic types can be new'd up.
|
||||||
|
@ -117,8 +117,6 @@ public class ScalatraServerCodegen extends AbstractScalaCodegen implements Codeg
|
|||||||
supportingFiles.add(new SupportingFile("project/plugins.sbt", "project", "plugins.sbt"));
|
supportingFiles.add(new SupportingFile("project/plugins.sbt", "project", "plugins.sbt"));
|
||||||
supportingFiles.add(new SupportingFile("sbt", "", "sbt"));
|
supportingFiles.add(new SupportingFile("sbt", "", "sbt"));
|
||||||
|
|
||||||
instantiationTypes.put("map", "HashMap");
|
|
||||||
|
|
||||||
importMapping = new HashMap<String, String>();
|
importMapping = new HashMap<String, String>();
|
||||||
importMapping.put("BigDecimal", "java.math.BigDecimal");
|
importMapping.put("BigDecimal", "java.math.BigDecimal");
|
||||||
importMapping.put("UUID", "java.util.UUID");
|
importMapping.put("UUID", "java.util.UUID");
|
||||||
@ -138,6 +136,8 @@ public class ScalatraServerCodegen extends AbstractScalaCodegen implements Codeg
|
|||||||
importMapping.put("Set", "scala.collection.immutable.Set");
|
importMapping.put("Set", "scala.collection.immutable.Set");
|
||||||
importMapping.put("ListSet", "scala.collection.immutable.ListSet");
|
importMapping.put("ListSet", "scala.collection.immutable.ListSet");
|
||||||
|
|
||||||
|
instantiationTypes.put("array", "List");
|
||||||
|
instantiationTypes.put("map", "HashMap");
|
||||||
instantiationTypes.put("set", "Set");
|
instantiationTypes.put("set", "Set");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ public class ScalaHttpClientModelTest {
|
|||||||
Assert.assertEquals(property1.setter, "setChildren");
|
Assert.assertEquals(property1.setter, "setChildren");
|
||||||
Assert.assertEquals(property1.dataType, "Set[Children]");
|
Assert.assertEquals(property1.dataType, "Set[Children]");
|
||||||
Assert.assertEquals(property1.name, "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.baseType, "Set");
|
||||||
Assert.assertEquals(property1.containerType, "set");
|
Assert.assertEquals(property1.containerType, "set");
|
||||||
Assert.assertFalse(property1.required);
|
Assert.assertFalse(property1.required);
|
||||||
|
@ -68,7 +68,7 @@ class PetApi(implicit val swagger: Swagger) extends ScalatraServlet
|
|||||||
|
|
||||||
val findPetsByStatusOperation = (apiOperation[List[Pet]]("findPetsByStatus")
|
val findPetsByStatusOperation = (apiOperation[List[Pet]]("findPetsByStatus")
|
||||||
summary "Finds Pets by status"
|
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)) {
|
get("/pet/findByStatus", operation(findPetsByStatusOperation)) {
|
||||||
@ -88,7 +88,7 @@ class PetApi(implicit val swagger: Swagger) extends ScalatraServlet
|
|||||||
|
|
||||||
val findPetsByTagsOperation = (apiOperation[List[Pet]]("findPetsByTags")
|
val findPetsByTagsOperation = (apiOperation[List[Pet]]("findPetsByTags")
|
||||||
summary "Finds Pets by tags"
|
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)) {
|
get("/pet/findByTags", operation(findPetsByTagsOperation)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user