Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump JSON Schema version and lower cache size. #789

Merged
merged 5 commits into from
Aug 22, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ object JsonSchema {
val Right(documentNode) = document.as[JsonNode]
val Right(schemaNode) = schema.as[JsonNode]

val validationErrors = jsf.getValidator.validate(schemaNode, documentNode)
val validationErrors = jsf.getJsonSchema(schemaNode).validate(documentNode)
if (validationErrors.isSuccess) {
Right[ValidationErrors, Unit](())
} else {
Expand Down Expand Up @@ -147,7 +147,7 @@ object JsonSchema {
},
jsonObject = { obj =>
val objectNode = JsonNodeFactory.instance.objectNode()
objectNode.setAll(obj.toMap.mapValues(circeJsonToJsonNode).asJava)
objectNode.setAll[JsonNode](obj.toMap.mapValues(circeJsonToJsonNode).asJava)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import java.io.StringWriter
import java.io.Writer
import java.nio.charset.StandardCharsets
import java.util.Base64

import com.github.fge.jsonschema.cfg.ValidationConfiguration

import collection.JavaConverters._

object PackageDefinitionRenderer {
Expand All @@ -38,7 +41,13 @@ object PackageDefinitionRenderer {
}
}

private[this] implicit val jsf: JsonSchemaFactory = JsonSchemaFactory.byDefault()
private[this] implicit val jsf: JsonSchemaFactory = {
// Disable cache because it uses the URI as a key. Since we are not using the URI the key is different on each
// call and thus has not performance advantage.
val validationConfiguration = ValidationConfiguration.newBuilder().setCacheSize(0).freeze()
JsonSchemaFactory.newBuilder()
.setValidationConfiguration(validationConfiguration).freeze()
}

def renderMarathonV2App(
sourceUri: Uri,
Expand Down
7 changes: 5 additions & 2 deletions project/Deps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ object Deps {

// APLv2.0 / LGPLv3.0
val jsonSchema = Seq(
"com.github.fge" % "json-schema-validator" % V.jsonSchema
"com.github.java-json-tools" % "json-schema-validator" % V.jsonSchema,
// Override Jackson dependency
"com.fasterxml.jackson.module" %% "jackson-module-scala" % V.jackson
)

// EPLv1.0 / LGPLv2.1
Expand Down Expand Up @@ -146,7 +148,8 @@ object V {
val fastparse = "1.0.0"
val finch = "0.18.0"
val guava = "28.0-jre"
val jsonSchema = "2.2.6"
val jackson = "2.11.0"
val jsonSchema = "2.2.14"
val logback = "1.2.3"
val mockito = "2.16.0"
val mustache = "0.9.6"
Expand Down