11package com.github.lppedd.cc.configuration
22
33import com.github.erosb.jsonsKema.*
4- import com.github.erosb.jsonsKema.FormatValidationPolicy.ALWAYS
54import com.github.lppedd.cc.*
65import com.intellij.openapi.application.WriteAction
76import com.intellij.openapi.components.Service
@@ -11,8 +10,6 @@ import com.intellij.openapi.vfs.LocalFileSystem
1110import com.intellij.openapi.vfs.VirtualFile
1211import org.codehaus.jettison.json.JSONArray
1312import org.codehaus.jettison.json.JSONObject
14- import java.io.Reader
15- import java.net.URI
1613
1714/* *
1815 * Manages bundled and custom commit message tokens.
@@ -30,27 +27,12 @@ internal class CCTokensService(private val project: Project) {
3027 * JSON Schema used to validate the default commit types and scopes JSON file.
3128 */
3229 private val tokensSchema: Schema by lazy {
33- // See https://github.com/erosb/json-sKema/tree/master/src/main/resources/json-meta-schemas
34- val draft04Reader = getResourceAsStream(" /json-meta-schemas/draft04/schema.json" ).bufferedReader()
35- val draft04Str = draft04Reader.use(Reader ::readText)
36-
3730 val schemaReader = getResourceAsStream(" /defaults/${CC .File .Schema } " ).bufferedReader()
3831 val schemaJson = schemaReader.use {
3932 JsonParser (schemaReader).parse()
4033 }
4134
42- // Pre-populate additional Draft 4 schemas to avoid network calls.
43- // I'm not sure whether all of these are needed, but let's play on the safe side.
44- val config = SchemaLoaderConfig .createDefaultConfig(
45- mapOf (
46- URI (" http://json-schema.org/draft-04/schema" ) to draft04Str,
47- URI (" http://json-schema.org/draft-04/schema#" ) to draft04Str,
48- URI (" https://json-schema.org/draft-04/schema" ) to draft04Str,
49- URI (" https://json-schema.org/draft-04/schema#" ) to draft04Str,
50- )
51- )
52-
53- return @lazy SchemaLoader (schemaJson, config).load()
35+ return @lazy SchemaLoader (schemaJson).load()
5436 }
5537
5638 /* *
@@ -337,7 +319,7 @@ internal class CCTokensService(private val project: Project) {
337319
338320 private fun Schema.validateJson (content : String ): ValidationFailure ? {
339321 val jsonValue = JsonParser (content).parse()
340- val validator = Validator .create(this , ValidatorConfig (ALWAYS ))
322+ val validator = Validator .create(this , ValidatorConfig (FormatValidationPolicy . ALWAYS ))
341323 return validator.validate(jsonValue)
342324 }
343325}
0 commit comments