bugfix/set the default value for Swagger Array value.

This commit is contained in:
Hongwei 2025-02-24 17:08:22 +01:00
parent ade36321ff
commit e867fcd6bd
2 changed files with 5 additions and 3 deletions

View File

@ -22,6 +22,7 @@ object SwaggerDefinitionsJsonUtil {
"iat": 1730373271,
"nbf": 1730373271,
"exp": 1730937600,
"request_headers":[],
"entitlements": [],
"views": [ {
"bank_id": "nlbkb",

View File

@ -752,9 +752,10 @@ object SwaggerJSONFactory extends MdcLoggable {
case _ if isTypeOf[JArray] =>
exampleValue match {
case JArray(v ::_) => s""" {"type": "array", "items":${buildSwaggerSchema(JsonUtils.getType(v), v)} }"""
case _ =>
logger.error(s"Empty JArray is not allowed in request body and response body example.")
throw new RuntimeException("JArray type should not be empty.")
case _ => s""" {"type": "array","items": {}}""" //if array is empty, we can not know the type here.
// case _ =>
// logger.error(s"Empty JArray is not allowed in request body and response body example.")
// throw new RuntimeException("JArray type should not be empty.")
}
case _ if isTypeOf[JObject] =>