mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 15:27:01 +00:00
#891 fixed the JSON schema (RFC) for request & response -- added the validation library
This commit is contained in:
parent
6078f43173
commit
5a41f2e2cb
9
pom.xml
9
pom.xml
@ -48,6 +48,10 @@
|
||||
<name>OpenBankProject Git based repo</name>
|
||||
<url>https://raw.githubusercontent.com/OpenBankProject/OBP-M2-REPO/master/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
@ -59,6 +63,11 @@
|
||||
</pluginRepositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.everit-org.json-schema</groupId>
|
||||
<artifactId>org.everit.json.schema</artifactId>
|
||||
<version>1.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
|
||||
@ -2053,7 +2053,7 @@ object SwaggerDefinitionsJSON {
|
||||
name = "String",
|
||||
version = "String",
|
||||
git_commit = "String",
|
||||
date = "String"
|
||||
date = "2013-01-21T23:08:00Z"
|
||||
)
|
||||
|
||||
val thisAccountJsonV300 = ThisAccountJsonV300(
|
||||
|
||||
@ -2,22 +2,18 @@ package code.api.v1_4_0
|
||||
|
||||
import java.util.Date
|
||||
|
||||
import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON
|
||||
import code.api.util.APIUtil
|
||||
import code.api.util.APIUtil.{ApiVersion, ResourceDoc}
|
||||
import code.api.util.APIUtil.ResourceDoc
|
||||
import code.api.v1_4_0.JSONFactory1_4_0.ResourceDocJson
|
||||
import code.api.v2_1_0.OBPAPI2_1_0
|
||||
import code.api.v2_2_0.OBPAPI2_2_0
|
||||
import code.api.v3_0_0.OBPAPI3_0_0
|
||||
import code.util.Helper.MdcLoggable
|
||||
import net.liftweb.json.Extraction
|
||||
import net.liftweb.json.Extraction.decompose
|
||||
import net.liftweb.json._
|
||||
import org.everit.json.schema.loader.SchemaLoader
|
||||
import org.json.JSONObject
|
||||
import org.scalatest._
|
||||
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
import net.liftweb.json._
|
||||
|
||||
import scala.collection.mutable
|
||||
import scala.collection.mutable;
|
||||
|
||||
case class OneClass(
|
||||
string : String = "String",
|
||||
@ -73,4 +69,21 @@ class JSONFactory1_4_0Test extends FlatSpec
|
||||
logger.debug(prettyRender(result))
|
||||
}
|
||||
|
||||
|
||||
"validate all the resouceDocs json schema " should "work well, no exception is good enough" in {
|
||||
val resourceDocsRaw= OBPAPI3_0_0.allResourceDocs
|
||||
val resouceDocs = JSONFactory1_4_0.createResourceDocsJson(resourceDocsRaw.toList)
|
||||
|
||||
for{
|
||||
resouceDoc <- resouceDocs.resource_docs
|
||||
json <- List(compactRender(decompose(resouceDoc.success_response_body)))
|
||||
jsonSchema <- List(compactRender(resouceDoc.typed_success_response_body))
|
||||
} yield {
|
||||
val rawSchema = new JSONObject(jsonSchema)
|
||||
val schema = SchemaLoader.load(rawSchema)
|
||||
schema.validate(new JSONObject(json))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user