Custom generators may build (via fmap/bind) on spec generators. Generator overrides at the top level will not take effect inside custom generators:
(require '[clojure.spec :as s])
(require '[clojure.test.check.generators :as gen])
;; A map that holds a single integer value
(s/def ::val integer?)
(s/def ::body (s/keys :req [::val]))
;; This spec matches stringified versions of 'body'.
;; (read-string is for demonstration purposes only, of course)
(s/def ::stringy-body
(s/with-gen
(s/and string? #(s/valid? ::body (read-string %)))
#(gen/fmap pr-str (s/gen ::body))))
(s/valid? ::stringy-body "{:user/val 37}") ;; => true
;; This makes various stringified maps, as expected
(take 3 (gen/sample (s/gen ::stringy-body)))
;; => ("#:user{:val -1}" "#:user{:val 0}" "#:user{:val -1}")
;; *** But the overrides don't get passed through ***
(take 3 (gen/sample (s/gen ::stringy-body {::val #(s/gen #{42})})))
;; ("#:user{:val -1}" "#:user{:val 0}" "#:user{:val 0}")
Should consider documenting this in s/gen, s/with-gen, etc.