forked from loafle/openapi-generator-original
Merge pull request #51 from spatex/master
fixes for error messages in Java/JaxRS generated code
This commit is contained in:
commit
d30441dd27
@ -20,8 +20,10 @@ public class {{className}} {
|
|||||||
@{{httpMethod}}
|
@{{httpMethod}}
|
||||||
@Path("{{path}}")
|
@Path("{{path}}")
|
||||||
@ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", responseClass = "{{{returnType}}}")
|
@ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", responseClass = "{{{returnType}}}")
|
||||||
@ApiErrors(value = { @ApiError(code = 400, reason = "Invalid ID supplied"),
|
@ApiErrors(value = { {{#errorList}} @ApiError(code = {{{code}}}, reason = "{{{reason}}}"){{#hasMore}},{{/hasMore}}
|
||||||
@ApiError(code = 404, reason = "Pet not found") })
|
{{/errorList}}
|
||||||
|
})
|
||||||
|
|
||||||
public Response {{nickname}}(
|
public Response {{nickname}}(
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
{{#queryParameter}}
|
{{#queryParameter}}
|
||||||
|
@ -81,10 +81,12 @@ class Codegen(config: CodegenConfig) {
|
|||||||
lb
|
lb
|
||||||
})
|
})
|
||||||
opList += apiToMap(apiPath, operation)
|
opList += apiToMap(apiPath, operation)
|
||||||
|
|
||||||
CoreUtils.extractModelNames(operation).foreach(i => allImports += i)
|
CoreUtils.extractModelNames(operation).foreach(i => allImports += i)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
case None =>
|
case None =>
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,6 +208,18 @@ class Codegen(config: CodegenConfig) {
|
|||||||
val headerParams = new ListBuffer[AnyRef]
|
val headerParams = new ListBuffer[AnyRef]
|
||||||
val bodyParams = new ListBuffer[AnyRef]
|
val bodyParams = new ListBuffer[AnyRef]
|
||||||
var paramList = new ListBuffer[HashMap[String, AnyRef]]
|
var paramList = new ListBuffer[HashMap[String, AnyRef]]
|
||||||
|
var errorList = new ListBuffer[HashMap[String, AnyRef]]
|
||||||
|
|
||||||
|
if (operation.errorResponses != null) {
|
||||||
|
operation.errorResponses.foreach(param => {
|
||||||
|
val params = new HashMap[String, AnyRef]
|
||||||
|
params += "code" -> param.code.toString()
|
||||||
|
params += "reason" -> param.reason
|
||||||
|
params += "hasMore" -> "true"
|
||||||
|
errorList += params
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (operation.parameters != null) {
|
if (operation.parameters != null) {
|
||||||
operation.parameters.foreach(param => {
|
operation.parameters.foreach(param => {
|
||||||
@ -284,6 +298,10 @@ class Codegen(config: CodegenConfig) {
|
|||||||
case 0 =>
|
case 0 =>
|
||||||
case _ => pathParams.last.asInstanceOf[HashMap[String, String]] -= "hasMore"
|
case _ => pathParams.last.asInstanceOf[HashMap[String, String]] -= "hasMore"
|
||||||
}
|
}
|
||||||
|
errorList.size match{
|
||||||
|
case 0 =>
|
||||||
|
case _ => errorList.last.asInstanceOf[HashMap[String, String]] -= "hasMore"
|
||||||
|
}
|
||||||
|
|
||||||
val sp = {
|
val sp = {
|
||||||
val lb = new ListBuffer[AnyRef]
|
val lb = new ListBuffer[AnyRef]
|
||||||
@ -325,6 +343,7 @@ class Codegen(config: CodegenConfig) {
|
|||||||
"queryParams" -> queryParams.toList,
|
"queryParams" -> queryParams.toList,
|
||||||
"headerParams" -> headerParams.toList,
|
"headerParams" -> headerParams.toList,
|
||||||
"requiredParams" -> requiredParams.toList,
|
"requiredParams" -> requiredParams.toList,
|
||||||
|
"errorList" -> errorList,
|
||||||
"httpMethod" -> operation.httpMethod.toUpperCase,
|
"httpMethod" -> operation.httpMethod.toUpperCase,
|
||||||
operation.httpMethod.toLowerCase -> "true")
|
operation.httpMethod.toLowerCase -> "true")
|
||||||
if (requiredParams.size > 0) properties += "requiredParamCount" -> requiredParams.size.toString
|
if (requiredParams.size > 0) properties += "requiredParamCount" -> requiredParams.size.toString
|
||||||
|
Loading…
x
Reference in New Issue
Block a user