mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 19:08:52 +00:00
Generate classes from the models declared in 'responseModel'
* ResponseMessage has new constructor parameter, an optional string for responseModel * Make sure we add it to list of models * make sure the responseModel is part of the error list available to mustache
This commit is contained in:
parent
11bede2b7d
commit
2dc6b485e0
@ -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
|
||||
})
|
||||
|
@ -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)
|
||||
}
|
||||
))
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user