This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-02
Channels
- # announcements (11)
- # aws (2)
- # babashka (42)
- # beginners (26)
- # calva (17)
- # cider (1)
- # clara (2)
- # clj-kondo (44)
- # clojars (30)
- # clojure (43)
- # clojure-australia (6)
- # clojure-europe (29)
- # clojure-gamedev (4)
- # clojure-greece (1)
- # clojure-nl (4)
- # clojure-spec (4)
- # clojure-uk (6)
- # clojurescript (28)
- # cursive (16)
- # data-science (1)
- # datahike (4)
- # datomic (26)
- # emacs (6)
- # events (3)
- # fulcro (11)
- # graalvm (7)
- # holy-lambda (118)
- # java (9)
- # jobs (1)
- # leiningen (3)
- # lsp (21)
- # luminus (2)
- # malli (13)
- # membrane-term (1)
- # music (1)
- # nrepl (3)
- # off-topic (38)
- # pedestal (2)
- # polylith (39)
- # re-frame (33)
- # reagent (7)
- # releases (1)
- # remote-jobs (4)
- # rewrite-clj (28)
- # ring (21)
- # sql (2)
- # tools-deps (23)
- # vim (4)
- # xtdb (15)
I have a beginner question: I validate incoming JSONs by first stripping extra keys, then validating against a malli schema and then output avro. How can I keep/specify the type of floats/doubles? E.g.
(-> [:map [:score double?]]
(m/encode {:score 0} mt/strip-extra-keys-transformer)
:score
type)
;; => java.lang.Long
While I want double.This seems to work when it's a string. So
(-> [:map [:score double?]]
(m/decode {:score "0"} mt/string-transformer)
:score
type)
;; => java.lang.Double
works.. but I get {:score 0}
as input and then it's still Long.But this lead me to look at the other transformers and decode with json-transformer seems to do the trick 🙂
Apparently I got that mixed up. But when I only use strip-extra-keys-transformer
I can use encode or decode.. In both cases the extra keys got stripped. But for my (new) use-case where I want to have a double where the schema is double I have to use decode like you said.
I write with jackdaw a kstreams app that validates the incoming JSON events, does some simple transformations and outputs to multiple different topics depending on the event content.
Hey there. I was just wondering if there were plans to expand malli to include support for openapi 3? Or should i just stick to spec-tools for the immediate future?
There's an issue for that where somebody was going to work on it, but I haven't got a reply last month. That said, I heard a rumour that someone else would tackle it by Christmas. Might be that I need it sooner and might have a look too. Didn't seem terribly difficult, considering that the jsonschema support is already there. At least a simple version that is valid openapi3. Perhaps something that handles all the refs etc. would be more complex.
that's great to hear that it's tentatively on the roadmap! I'll keep a close eye on things and switch over ASAP. Thanks!