diff --git a/src/main/scala/com/wordnik/swagger/codegen/Codegen.scala b/src/main/scala/com/wordnik/swagger/codegen/Codegen.scala index ac71ef7864..ec0d0116b8 100644 --- a/src/main/scala/com/wordnik/swagger/codegen/Codegen.scala +++ b/src/main/scala/com/wordnik/swagger/codegen/Codegen.scala @@ -227,10 +227,12 @@ class Codegen(config: CodegenConfig) { var bodyParamRequired: Option[String] = Some("true") if (operation.responseMessages != null) { - operation.responseMessages.foreach(param => { + operation.responseMessages.foreach(param => { val params = new HashMap[String, AnyRef] params += "code" -> param.code.toString() params += "reason" -> param.message + if (!param.responseModel.isEmpty) + params += "responseModel" -> param.responseModel params += "hasMore" -> "true" errorList += params }) diff --git a/src/main/scala/com/wordnik/swagger/codegen/model/SwaggerModelSerializer.scala b/src/main/scala/com/wordnik/swagger/codegen/model/SwaggerModelSerializer.scala index 88c1d8f01e..ea1d49721e 100644 --- a/src/main/scala/com/wordnik/swagger/codegen/model/SwaggerModelSerializer.scala +++ b/src/main/scala/com/wordnik/swagger/codegen/model/SwaggerModelSerializer.scala @@ -222,12 +222,14 @@ object SwaggerSerializers { case json => ResponseMessage( (json \ "code").extractOrElse(0), - (json \ "message").extractOrElse("") + (json \ "message").extractOrElse(""), + (json \ "responseModel").extractOpt[String] ) }, { case x: ResponseMessage => ("code" -> x.code) ~ - ("message" -> x.message) + ("message" -> x.message) ~ + ("responseModel" -> x.responseModel) } )) diff --git a/src/main/scala/com/wordnik/swagger/codegen/util/CoreUtils.scala b/src/main/scala/com/wordnik/swagger/codegen/util/CoreUtils.scala index cd93e44dc6..7a47d4b0a3 100644 --- a/src/main/scala/com/wordnik/swagger/codegen/util/CoreUtils.scala +++ b/src/main/scala/com/wordnik/swagger/codegen/util/CoreUtils.scala @@ -35,7 +35,7 @@ object CoreUtils { def extractModelNames(op: Operation): Set[String] = { // // POST, PUT, DELETE body - val modelNames = Set(op.responseClass) ++ op.parameters.filter(_.paramType == "body").map(_.dataType) + val modelNames = Set(op.responseClass) ++ op.parameters.filter(_.paramType == "body").map(_.dataType) ++ op.responseMessages.filter(!_.responseModel.isEmpty).map(_.responseModel.get) modelNames map extractBasePartFromType }