spec-tools.conform
just transform, dont' validate. Fixes #92. Thanks to Benjamin Albrechts/gen
triggers IllegalArgumentException
for nested aliased specs #94 by @johanwiren.spec-tools.data-spec/or
, thanks to Dmitri Sotnikov:(require '[clojure.spec.alpha :as s])
(require '[spec-tools.data-spec :as ds])
(s/conform
(ds/spec
::user
[(ds/or {:map {:alias string?}
:string string?})])
[{:alias "Rudi"}, "Rudolf"])
; [[:map {:alias "rudi"}] [:string "Rudolf"]]
map-of
data-spec keys are also data-specs. So this works now:(require '[clojure.spec.alpha :as s])
(require '[spec-tools.data-spec :as ds])
(s/valid?
(ds/spec ::ints {[int?] [int?]})
{[1 2 3] [4 5 6]})
; true
ds/spec
supports 1-arity version, allowing extra options :keys-spec
& :keys-default
.(require '[clojure.spec.alpha :as s])
(require '[spec-tools.data-spec :as ds])
(s/valid?
(ds/spec
{:name ::optiona-user
:spec {(ds/req :id) int?
:age pos-int?
:name string?}
:keys-default ds/opt})
{:id 123})
; true
ds/spec
option :name
is only required if non-qualified map keys are present.(require '[clojure.spec.alpha :as s])
(require '[spec-tools.data-spec :as ds])
(s/valid?
(ds/spec
{:spec [{::alias string?}]})
[{::alias "kikka"}
{::alias "kukka"}])
; true
spec-tools.core/merge
that selects only the specced keys from each conformed result, then merges those results onto the original input. This avoids overwriting conformed values with unconformed values while preserving all unspecced keys of the input. Fixes #90. By Arttu Kaipiainen.
updated deps:
[org.clojure/clojure "1.9.0"] is available but we use "1.9.0-beta4"
bigdec?
in favor of decimal?
(1.9.0-beta4 changes)[org.clojure/clojure "1.9.0-beta4"] is available but we use "1.9.0-beta4"
[org.clojure/spec.alpha "0.1.143"] is available but we use "0.1.134"
don't publish empty :required
fields for JSON Schemas, by acron0
added parsers for s/merge
& st/spec
.
Don't fail on recursive spec visits, fixes #75
BREAKING: spec-tools.visitor/visit-spec
should recurse with spec-tools.visitor/visit
instead of spec-tools.visitor/visit-spec
updated deps:
[org.clojure/clojure "1.9.0-beta2"] is available but we use "1.9.0-alpha19"
[org.clojure/clojurescript "1.9.946"] is available but we use "1.9.908"
or
and and
keys are parsed correctly for JSON Schema & Swagger, Fixes #79
BREAKING: spec-tools.type
is now spec-tools.parse
with public api of:
parse-spec
: given a spec name, form or instance, maybe returns a spec info map with resolved :type
and optionally other info, e.g. :keys
, :keys/req
and :keys/opt
for s/keys
specs.parse-form
: multimethod to parse info out of a formSpec Records of s/and
are fully resolved now, fixes https://github.com/metosin/compojure-api/issues/336
updated deps:
[org.clojure/spec.alpha "0.1.134"] is available but we use "0.1.123"
spec-tools.core/create-spec
fails with qualified keyword if they don't link to a spec, thanks to Camilo Roca
updated deps:
[org.clojure/clojure "1.9.0-alpha19"] is available but we use "1.9.0-alpha17"
[org.clojure/clojurescript "1.9.908"] is available but we use "1.9.660"
spec-tools.spec
predicate symbols into clojure.core
counterparts for JSON Schema / Swagger mappings.:type
from first predicate of s/and
, thanks to Andy ChambersSwagger2 integration (moved from spec-swagger)
spec-tools.swagger.core/transform
to transform Specs into Swagger Parameter Objects and Schema Objectsspec-tools.swagger.core/swagger-spec
to create valid Swagger Object.BREAKING: More configurable Spec Visitor
visit
to visit-spec
(to better support static analysis for arity errors)accept
function is now 4-arity (was 3-arity), taking the options-map as 4th argumentspec-tools.json-schema/transform
also has optional 4-arity with the options-map as 4th argumentvisitor (and by so, json-schema generation) supports also direct predicate specs, via form inference:
(require '[spec-tools.json-schema :as json-schema])
(json-schema/transform int?)
; {:type "integer", :format "int64"}
added spec-tools.core/spec-name
, to resolve spec name, like clojure.spec.alpha/spec-name
but non-private & understands Spec Records.
added spec-tools.core/spec-description
, to resolve spec description, understands Spec Records.
JSON Schema generation set :title
for Object Schemas based on st/spec-name
.
s/cat
& s/alt
don't set :minItems
and :maxItems
as they are Regexs.
moved many helper functions to spec-tools.impl
Spec Record describe*
uses the map syntax, e.g. (st/spec clojure.core/string? {}
=> (st/spec {:spec clojure.core/string?})
Spec Records inherit ::s/name
from underlaying specs, fixes #56
fixed explain*
for Spec Records
updated deps:
[org.clojure/clojure "0.1.123"] is available but we use "0.1.108"
[org.clojure/clojure "1.9.0-alpha17"] is available but we use "1.9.0-alpha16"
[org.clojure/clojurescript "1.9.562"] is available but we use "1.9.542"
BREAKING: update spec to alpha16
:
clojure.spec
=> clojure.spec.alpha
, cljs.spec
=> cljs.spec.alpha
etc.updated deps:
[org.clojure/spec.alpha "0.1.108"]
[org.clojure/clojure "1.9.0-alpha16"] is available but we use "1.9.0-alpha15"
[org.clojure/clojurescript "1.9.542"] is available but we use "1.9.518"
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close