Skip to content

Commit 9985a14

Browse files
committed
Release 0.3.2
1 parent 1673ddd commit 9985a14

File tree

4 files changed

+39
-19
lines changed

4 files changed

+39
-19
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
44

5+
## 0.3.2 - 2021-09-15
6+
7+
- Eliminated reflective function calls
8+
- Updated Java Library
9+
10+
## 0.3.1 - 2021-04-25
11+
12+
Now relative $ref's are supported.
13+
14+
## 0.3.0 - 2021-04-15
15+
16+
This release adds usage of $ref pointing to resources in the classpath.
17+
518
## 0.2.9 - 2020-12-03
619

720
### Changed

project.clj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
(defproject luposlip/json-schema "0.3.1"
1+
(defproject luposlip/json-schema "0.3.2"
22
:description "Clojure library for JSON Schema validation and generation - Draft-07 compatible"
33
:url "https://github.com/luposlip/json-schema"
44
:license {:name "Apache License, Version 2.0"
55
:url "https://www.apache.org/licenses/LICENSE-2.0"}
66
:repositories {"jitpack" {:url "https://jitpack.io"}}
7-
:dependencies [[org.clojure/clojure "1.10.1"]
8-
[cheshire "5.10.0"]
9-
[com.github.everit-org.json-schema/org.everit.json.schema "1.12.1"]]
7+
:dependencies [[org.clojure/clojure "1.10.3"]
8+
[cheshire "5.10.1"]
9+
[com.github.everit-org.json-schema/org.everit.json.schema "1.13.0"]]
10+
:global-vars {*warn-on-reflection* true}
1011
:repl-options {:init-ns json-schema.core}
1112
:profiles {:dev {:resource-paths ["test/resources"]}})

src/json_schema/core.clj

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
(ns json-schema.core
22
(:require [cheshire.core :as json])
3-
(:import [org.json JSONObject JSONArray JSONTokener]
4-
[org.everit.json.schema.loader SchemaLoader SchemaClient]
3+
(:import [java.io Reader StringReader]
4+
[org.json JSONObject JSONArray JSONTokener]
5+
[org.everit.json.schema.loader
6+
SchemaLoader SchemaClient SchemaLoader$SchemaLoaderBuilder]
57
[org.everit.json.schema Schema]
68
[org.everit.json.schema ValidationException]))
79

810
(defn- ^JSONTokener prepare-tokener
911
"Prepares a JSONTokener instance for further processing"
10-
[input]
11-
(JSONTokener. ^String (if (string? input)
12-
input
13-
(json/generate-string input))))
12+
[input]
13+
(JSONTokener.
14+
^Reader (StringReader.
15+
^String (if (string? input)
16+
input
17+
(json/generate-string input)))))
1418

1519
(defn- prepare-json
1620
"Prepares JSON instance based on input string, map or vector"
1721
[input]
1822
(if (or (associative? input)
1923
(and (string? input)
2024
(#{\{ \[} (first input))))
21-
(let [json-tokener (prepare-tokener input)]
25+
(let [json-tokener ^JSONTokener(prepare-tokener input)]
2226
(if (or (vector? input)
2327
(= \[ (first input)))
24-
(JSONArray. ^JSONTokener json-tokener)
25-
(JSONObject. ^JSONTokener json-tokener)))
28+
(JSONArray. json-tokener)
29+
(JSONObject. json-tokener)))
2630
(throw (ex-info "Unsupported JSON input" {:input input}))))
2731

2832
(defn- assert-schema-input-valid! [input]
@@ -52,13 +56,15 @@
5256
(if-not (:classpath-aware? params)
5357
(prepare-schema* input)
5458
(let [resolution-scope (:default-resolution-scope params)
55-
set-resolution-scope (fn [client] (if resolution-scope
56-
(.resolutionScope client resolution-scope)
57-
client))
59+
set-resolution-scope (fn [^SchemaLoader$SchemaLoaderBuilder builder]
60+
(if resolution-scope
61+
(.resolutionScope builder ^String resolution-scope)
62+
builder))
5863
schema-loader (-> (SchemaLoader/builder)
5964
(.schemaClient (SchemaClient/classPathAwareClient))
60-
(set-resolution-scope)
61-
(.schemaJson (JSONObject. (prepare-tokener input)))
65+
^SchemaLoader$SchemaLoaderBuilder (set-resolution-scope)
66+
(.schemaJson
67+
^JSONObject (JSONObject. (prepare-tokener input)))
6268
(.build))]
6369
(.build (.load schema-loader))))))
6470

test/json_schema/core_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
(json/validate schema "{}" :include-original-exception)
5050
(catch Throwable ex
5151
ex))]
52-
(is (instance? ValidationException (.getCause ex)))))
52+
(is (instance? ValidationException (.getCause ^Exception ex)))))
5353

5454
(testing "Causing ExceptionInfo when validation fails"
5555
(let [schema {:$schema "http://json-schema.org/draft-07/schema#"

0 commit comments

Comments
 (0)