diff --git a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerJSONFactory.scala b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerJSONFactory.scala index f7ad80eb3f..940eb5d100 100644 --- a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerJSONFactory.scala +++ b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerJSONFactory.scala @@ -707,7 +707,13 @@ object SwaggerJSONFactory extends MdcLoggable { case _ => paramValue } - val definition = buildSwaggerSchema(paramType, exampleValue) + // Name the entity and field, so an unusable example can be found from the message alone. + val definition = + try buildSwaggerSchema(paramType, exampleValue) + catch { + case e: RuntimeException => + throw new RuntimeException(s"${entityType.typeSymbol.name}.$paramName: ${e.getMessage}", e) + } s""" "$paramName": $definition """ }) diff --git a/obp-api/src/main/scala/code/api/v7_0_0/Http4s700.scala b/obp-api/src/main/scala/code/api/v7_0_0/Http4s700.scala index 941a1ae918..fed02802d0 100644 --- a/obp-api/src/main/scala/code/api/v7_0_0/Http4s700.scala +++ b/obp-api/src/main/scala/code/api/v7_0_0/Http4s700.scala @@ -6989,7 +6989,8 @@ object Http4s700 { payload_hash = "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08", current_payload_hash = "", proposed_payload = Extraction.decompose(jsonDynamicResourceDoc), - current_payload = JNothing, + // A CREATE has nothing to replace. The swagger export needs an object here, not JNothing. + current_payload = JObject(Nil), requestor_user_id = code.api.util.ExampleValue.userIdExample.value, business_justification = "Expose the new loan quote endpoint for the mobile app.", checker_user_id = "", diff --git a/obp-api/src/test/scala/code/api/ResourceDocs1_4_0/SwaggerDocsTest.scala b/obp-api/src/test/scala/code/api/ResourceDocs1_4_0/SwaggerDocsTest.scala index f4c6342ce9..4fc4e223cc 100644 --- a/obp-api/src/test/scala/code/api/ResourceDocs1_4_0/SwaggerDocsTest.scala +++ b/obp-api/src/test/scala/code/api/ResourceDocs1_4_0/SwaggerDocsTest.scala @@ -110,6 +110,15 @@ class SwaggerDocsTest extends ResourceDocsV140ServerSetup with PropsReset with D errors.isEmpty should be (true) } + scenario(s"We will test ${ApiEndpoint1.name} Api - v7.0.0 swagger export succeeds", ApiEndpoint1, VersionOfApi) { + val requestGetSwagger = (ResourceDocsV5_1Request / "resource-docs" / "v7.0.0" / "swagger").GET + val responseGetSwagger = makeGetRequest(requestGetSwagger) + And("We should get 200, not OBP-50000 because one entity has no example") + withClue(responseGetSwagger.body.toString) { + responseGetSwagger.code should equal(200) + } + } + scenario(s"We will test ${ApiEndpoint1.name} Api - v4.0.0", ApiEndpoint1, VersionOfApi) { val requestGetObp = (ResourceDocsV4_0Request / "resource-docs" / "v4.0.0" / "swagger").GET val responseGetObp = makeGetRequest(requestGetObp)