From be1d39a268e328c67bc19596441195112f634057 Mon Sep 17 00:00:00 2001 From: shuang Date: Wed, 22 Apr 2020 22:19:47 +0800 Subject: [PATCH] feature/add_dynamic_endpoints_dynamic_entity_to_swagger: modify README.md about JDK version and request body response body type. --- README.md | 22 ++++++++++++++ .../ResourceDocs1_4_0/ResourceDocsTest.scala | 30 +++---------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 841004614..ad8e7c738 100644 --- a/README.md +++ b/README.md @@ -510,3 +510,25 @@ The same as `Frozen APIs`, if related unit test fail, make sure whether the modi * Advanced architecture: http://exploring.liftweb.net/master/index-9.html * A good book on Lift: "Lift in Action" by Timothy Perrett published by Manning. + +## Be tested JDK Version +* OracleJDK: 1.8, 13 +* OpenJdk: 11 + +## Endpoint Request and Response Example + ResourceDoc#exampleRequestBody and ResourceDoc#successResponseBody can be the follow type +* Any Case class +* JObject +* Wrapper JArray: JArrayBody(jArray) +* Wrapper String: StringBody("Hello") +* Wrapper primary type: IntBody(1), BooleanBody(true), FloatBody(1.2F)... +* Empty: EmptyBody + +example: +``` +resourceDocs += ResourceDoc( + exampleRequestBody= EmptyBody, + successResponseBody= BooleanBody(true), + ... +) +``` diff --git a/obp-api/src/test/scala/code/api/ResourceDocs1_4_0/ResourceDocsTest.scala b/obp-api/src/test/scala/code/api/ResourceDocs1_4_0/ResourceDocsTest.scala index f9c055412..a8502657b 100644 --- a/obp-api/src/test/scala/code/api/ResourceDocs1_4_0/ResourceDocsTest.scala +++ b/obp-api/src/test/scala/code/api/ResourceDocs1_4_0/ResourceDocsTest.scala @@ -5,7 +5,7 @@ import java.util import code.api.ResourceDocs1_4_0.ResourceDocsV140ServerSetup import code.api.util.{ApiRole, CustomJsonFormats} import code.api.v1_4_0.JSONFactory1_4_0.ResourceDocsJson -import com.openbankproject.commons.util.ApiVersion +import com.openbankproject.commons.util.{ApiVersion, Functions} import io.swagger.parser.OpenAPIParser import net.liftweb.json import net.liftweb.json.JsonAST._ @@ -24,33 +24,11 @@ class ResourceDocsTest extends ResourceDocsV140ServerSetup { private val CLAZZ = classOf[Product] override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, json.JValue), Product] = { - case (TypeInfo(CLAZZ, _), json) if json == JNull => null - case (TypeInfo(CLAZZ, _), json: JObject) => { - val keyValues = json.obj.map(pair => { - val JField(name, jvalue) = pair - val value = jvalue match { - case JBool(v) => v - case JString(v) => v - case JInt(v) => v - case JDouble(v) => v - case JArray(arr) => arr - case JObject(v) => v.map(it => (it.name, it.value)) - case _ => jvalue - } - (name, value) - }) - - new Product { - override def productElement(n: Int): Any = keyValues.lift(n) - override def productArity: Int = keyValues.size - override def canEqual(that: Any): Boolean = false - } - } + case (TypeInfo(CLAZZ, _), json) if json == JNull || json == JNothing => null + case (TypeInfo(CLAZZ, _), json: JObject) => json } - override def serialize(implicit format: Formats): PartialFunction[Any, json.JValue] = { - case null => JNull // not need do serialize - } + override def serialize(implicit format: Formats): PartialFunction[Any, json.JValue] = Functions.doNothing } // here must supply a Serializer of json, to support Product type, because the follow type are ApiRole: //ResourceDocsJson#ResourceDocJson.roles