diff --git a/src/spec_tools/json_schema.cljc b/src/spec_tools/json_schema.cljc index d7d59ffe..a02daf7f 100644 --- a/src/spec_tools/json_schema.cljc +++ b/src/spec_tools/json_schema.cljc @@ -282,7 +282,10 @@ json-schema-meta (impl/unlift-keys data "json-schema") extra-info (-> (select-keys data [:description]) (cond-> (and name (not synthetic?)) - (assoc :title (impl/qualified-name name))))] + (assoc :title (or (when-let [name-use (:name data)] + (when (string? name-use) + name-use)) + (impl/qualified-name name)))))] (merge (impl/unwrap children) extra-info json-schema-meta))) (defmethod accept-spec ::default [_ _ _ _] diff --git a/test/cljc/spec_tools/json_schema_test.cljc b/test/cljc/spec_tools/json_schema_test.cljc index d99117fb..81f8b78e 100644 --- a/test/cljc/spec_tools/json_schema_test.cljc +++ b/test/cljc/spec_tools/json_schema_test.cljc @@ -250,3 +250,11 @@ (s/and (s/keys :req-un [::bar]) (s/keys :req-un [::foo]))))) "allOf properties are merged into properties and required")) + +(s/def ::spec-with-explicit-name + (st/spec {:spec ::keys-no-req + :name "specific-name"})) + +(deftest name-is-respected-test + (is (= (:title (jsc/transform ::spec-with-explicit-name)) + "specific-name")))