forked from loafle/openapi-generator-original
fixed response type with array of simple types
This commit is contained in:
parent
56d5167a27
commit
a140ea2b9d
@ -237,19 +237,35 @@ object SwaggerSerializers {
|
|||||||
class OperationSerializer extends CustomSerializer[Operation](implicit formats => ({
|
class OperationSerializer extends CustomSerializer[Operation](implicit formats => ({
|
||||||
case json =>
|
case json =>
|
||||||
|
|
||||||
val responseClass = (json \ "items") match {
|
val t = SwaggerSerializers.jsonSchemaTypeMap.getOrElse(
|
||||||
case e: JObject => {
|
((json \ "type").extractOrElse(""), (json \ "format").extractOrElse(""))
|
||||||
val inner = {
|
, (json \ "type").extractOrElse(""))
|
||||||
(e \ "type").extractOrElse({
|
|
||||||
(e \ "$ref").extract[String]
|
val inner = {
|
||||||
})
|
val items = new scala.collection.mutable.HashSet[String]
|
||||||
|
val map = new scala.collection.mutable.HashMap[String, String]
|
||||||
|
(json \ "items") match {
|
||||||
|
case JObject(e) => {
|
||||||
|
for(a <- e) {
|
||||||
|
a._2 match {
|
||||||
|
case e: JString => map += a._1 -> e.s
|
||||||
|
case _ =>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val `type` = map.getOrElse("type", "")
|
||||||
|
val format = map.getOrElse("format", "")
|
||||||
|
if(map.contains("$ref")) {
|
||||||
|
Some(map("$ref"))
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Option(jsonSchemaTypeMap.getOrElse((`type`,format), `type`))
|
||||||
}
|
}
|
||||||
"%s[%s]".format((json \ "type").extract[String], inner)
|
case _ => None
|
||||||
}
|
}
|
||||||
case _ => (json \ "type").extractOrElse({
|
}
|
||||||
!!(json, OPERATION, "responseClass", "missing required field", ERROR)
|
val responseClass = inner match {
|
||||||
""
|
case Some(a) => "%s[%s]".format(t, a)
|
||||||
})
|
case _ => t
|
||||||
}
|
}
|
||||||
|
|
||||||
Operation(
|
Operation(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user