forked from loafle/openapi-generator-original
made more testable, changed to use case classes + native scala lists
This commit is contained in:
parent
44d018b642
commit
e2c383bd80
@ -97,6 +97,10 @@ abstract class BasicGenerator extends CodegenConfig with PathUtil {
|
||||
|
||||
modelFiles.map(m => {
|
||||
val filename = m._1
|
||||
|
||||
val file = new java.io.File(filename)
|
||||
file.getParentFile().mkdirs
|
||||
|
||||
val fw = new FileWriter(filename, false)
|
||||
fw.write(m._2 + "\n")
|
||||
fw.close()
|
||||
@ -108,6 +112,10 @@ abstract class BasicGenerator extends CodegenConfig with PathUtil {
|
||||
|
||||
apiFiles.map(m => {
|
||||
val filename = m._1
|
||||
|
||||
val file = new java.io.File(filename)
|
||||
file.getParentFile().mkdirs
|
||||
|
||||
val fw = new FileWriter(filename, false)
|
||||
fw.write(m._2 + "\n")
|
||||
fw.close()
|
||||
|
@ -23,7 +23,8 @@ object BasicScalaGenerator extends BasicScalaGenerator {
|
||||
}
|
||||
|
||||
class BasicScalaGenerator extends BasicGenerator {
|
||||
override def defaultIncludes = Set("Int",
|
||||
override def defaultIncludes = Set(
|
||||
"Int",
|
||||
"String",
|
||||
"Long",
|
||||
"Float",
|
||||
@ -78,7 +79,7 @@ class BasicScalaGenerator extends BasicGenerator {
|
||||
if (obj.items.ref != null) obj.items.ref
|
||||
else obj.items.getType
|
||||
}
|
||||
val e = "java.util.List[%s]" format toDeclaredType(inner)
|
||||
val e = "List[%s]" format toDeclaredType(inner)
|
||||
(e, toDefaultValue(inner, obj))
|
||||
}
|
||||
case e: String => (toDeclaredType(e), toDefaultValue(e, obj))
|
||||
|
@ -138,7 +138,7 @@ class BasicScalaGeneratorTest extends FlatSpec with ShouldMatchers {
|
||||
model.items.setType("string")
|
||||
|
||||
val m = config.toDeclaration(model)
|
||||
m._1 should be ("java.util.List[String]")
|
||||
m._1 should be ("List[String]")
|
||||
m._2 should be ("_")
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ class BasicScalaGeneratorTest extends FlatSpec with ShouldMatchers {
|
||||
model.items.setType("int")
|
||||
|
||||
val m = config.toDeclaration(model)
|
||||
m._1 should be ("java.util.List[Int]")
|
||||
m._1 should be ("List[Int]")
|
||||
m._2 should be ("0")
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ class BasicScalaGeneratorTest extends FlatSpec with ShouldMatchers {
|
||||
model.items.setType("float")
|
||||
|
||||
val m = config.toDeclaration(model)
|
||||
m._1 should be ("java.util.List[Float]")
|
||||
m._1 should be ("List[Float]")
|
||||
m._2 should be ("0f")
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@ class BasicScalaGeneratorTest extends FlatSpec with ShouldMatchers {
|
||||
model.items.setType("double")
|
||||
|
||||
val m = config.toDeclaration(model)
|
||||
m._1 should be ("java.util.List[Double]")
|
||||
m._1 should be ("List[Double]")
|
||||
m._2 should be ("0.0")
|
||||
}
|
||||
|
||||
@ -199,7 +199,7 @@ class BasicScalaGeneratorTest extends FlatSpec with ShouldMatchers {
|
||||
model.items.setType("User")
|
||||
|
||||
val m = config.toDeclaration(model)
|
||||
m._1 should be ("java.util.List[User]")
|
||||
m._1 should be ("List[User]")
|
||||
m._2 should be ("_")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user