A library for serializing Prismatic Schema definitions with Transit.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



schema-transit is a library that glues together Prismatic's Schema library and Cognitect's Transit library.

Using schema-transit you can turn a schema into data. Once it is data you can send it over the wire, store it in a database, etc.

The latest version of schema-transit is:

Clojars Project


The schema-transit cross-platform read/write handlers are defined as outpace.schema-transit/cross-platform-read-handlers and outpace.schema-transit/cross-platform-write-handlers, respectively.

The platform specific read/write handlers are defined as outpace.schema-transit/read-handlers and outpace.schema-transit/write-handlers, respectively

You can use these like you would any other transit handlers:

(require '[cognitect.transit :as t])
(require '[outpace.schema-transit :as st])

(defn transit-write [obj out]
  (t/write (t/writer out
                     {:handlers st/write-handlers})

(defn transit-read [in]
  (t/read (t/reader in
                    {:handlers st/read-handlers})))


Schemas can be divided into two sets: cross-platform and platform specific.

The cross-platform schemas can be serialized, deserialized, and transmitted between Clojure and ClojureScript. The following leaf schemas are currently considered cross-platform: s/Any, s/Int, s/Keyword, s/Symbol, s/String, s/Bool, s/Num, s/Regex, s/Inst, s/Uuid. The following composite schemas are cross-platform if their components are also cross-platform: s/eq, s/maybe, s/named, s/either, s/both, maps, sets, vectors, s/required-key, s/optional-key, s/map-entry, s/one, function schema, and s/pair.

The platform specific schemas include the cross-platform schemas, and additional schemas that can safely be serialized/deserialized but cannot be transmitted between Clojure and ClojureScript. Clojure's platform specific schemas are primitive schemas, a compiled regular expression, and a Java Class. In the case of a Java class it is serialized to its fully qualified class name. When deserialized a Java class must exist and have already been initialized; schema-transit finds classes using Class/forName but in a way that will not initialize a class. On the ClojureScript side, the only platform specific schema is a regular expression.


Copyright © Outpace Systems, Inc.

Released under the Apache License, Version 2.0