forked from loafle/openapi-generator-original
added set support
This commit is contained in:
parent
5f61d20610
commit
f766937ac7
@ -120,8 +120,10 @@ class BasicJavaGenerator extends BasicGenerator {
|
||||
val declaredType = dt.indexOf("[") match {
|
||||
case -1 => dt
|
||||
case n: Int => {
|
||||
if (dt.substring(0, n).toLowerCase == "array")
|
||||
if (dt.substring(0, n) == "Array")
|
||||
"List" + dt.substring(n).replaceAll("\\[", "<").replaceAll("\\]", ">")
|
||||
else if (dt.substring(0, n) == "Set")
|
||||
"Set" + dt.substring(n).replaceAll("\\[", "<").replaceAll("\\]", ">")
|
||||
else dt.replaceAll("\\[", "<").replaceAll("\\]", ">")
|
||||
}
|
||||
}
|
||||
@ -146,6 +148,15 @@ class BasicJavaGenerator extends BasicGenerator {
|
||||
}
|
||||
declaredType += "<" + toDeclaredType(inner) + ">"
|
||||
}
|
||||
case "Set" => {
|
||||
val inner = {
|
||||
obj.items match {
|
||||
case Some(items) => items.ref.getOrElse(items.`type`)
|
||||
case _ => throw new Exception("no inner type defined")
|
||||
}
|
||||
}
|
||||
declaredType += "<" + toDeclaredType(inner) + ">"
|
||||
}
|
||||
case _ =>
|
||||
}
|
||||
(declaredType, defaultValue)
|
||||
|
@ -146,8 +146,10 @@ class BasicScalaGenerator extends BasicGenerator {
|
||||
val declaredType = dt.indexOf("[") match {
|
||||
case -1 => dt
|
||||
case n: Int => {
|
||||
if (dt.substring(0, n).toLowerCase == "array")
|
||||
if (dt.substring(0, n) == "Array")
|
||||
"List" + dt.substring(n)
|
||||
else if (dt.substring(0, n) == "Set")
|
||||
"Set" + dt.substring(n)
|
||||
else dt
|
||||
}
|
||||
}
|
||||
@ -176,6 +178,16 @@ class BasicScalaGenerator extends BasicGenerator {
|
||||
val e = "List[%s]" format toDeclaredType(inner)
|
||||
(e, toDefaultValue(inner, obj))
|
||||
}
|
||||
case "Set" => {
|
||||
val inner = {
|
||||
obj.items match {
|
||||
case Some(items) => items.ref.getOrElse(items.`type`)
|
||||
case _ => throw new Exception("no inner type defined")
|
||||
}
|
||||
}
|
||||
val e = "Set[%s]" format toDeclaredType(inner)
|
||||
(e, toDefaultValue(inner, obj))
|
||||
}
|
||||
case e: String => (toDeclaredType(e), toDefaultValue(e, obj))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user