This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-30
Channels
- # adventofcode (4)
- # aleph (1)
- # announcements (7)
- # aws (10)
- # babashka (23)
- # beginners (23)
- # calva (20)
- # chlorine-clover (13)
- # cider (17)
- # clj-kondo (13)
- # cljfx (9)
- # cljsrn (9)
- # clojure (98)
- # clojure-australia (1)
- # clojure-dev (15)
- # clojure-europe (127)
- # clojure-nl (4)
- # clojure-sanfrancisco (3)
- # clojure-uk (98)
- # clojurescript (25)
- # community-development (8)
- # core-async (15)
- # cryogen (9)
- # cursive (7)
- # data-science (1)
- # datascript (5)
- # datomic (3)
- # devcards (2)
- # fulcro (5)
- # graalvm (1)
- # helix (8)
- # jackdaw (1)
- # jobs (5)
- # kaocha (17)
- # malli (5)
- # meander (5)
- # off-topic (37)
- # pathom (33)
- # pedestal (3)
- # re-frame (12)
- # reitit (1)
- # remote-jobs (3)
- # sci (1)
- # shadow-cljs (6)
- # testing (1)
- # vim (6)
- # vrac (5)
Quick question: Is is possible to combine malli and spec-tools in order to get both, the JSON schema and the API schema? Do you plan to extend spec-tools or malli? Actually it has to be malli right? Yesterday I realized how awesome programatically updating malli specs is. You can have a complex user schema with an ":active" boolean in in and all you need to do to specify an inactive user is to say (def inactive-user (mu/assoc user :active [:enum false]). It's like a language-agnostic type that would be perfectly exportable to e.g. openapi3 and JSON form to make use of the tools available for these standards. (trying to find good reasons to introduce clojure with malli as a way to generate openapi/json schema in our company that uses them).
Slow answer 😉 : I’m not sure I understand the question, but you can generate JSON Schema from malli. Glad you like it.
Yea, I know and I'm loving it. I'd like to experiment a bit with API-Driven development at our company. OpenApi is nice, but who wants to write JSON/YAML by hand when you can write edn instead and programmatically create JSON Schema and OpenAPI-Specs from that. The JSON Schema part is covered nicely by malli, which is wonderful, because we can utilize the nice ecosystem that uses JSON Schema already AND have the power of property-based testing. But what about speccing the endpoints? There is spec-tools, but spec-tools uses clojure.spec instead of malli. I imagine that I could e.g. specify an "Order" schema and a "Processed Order" schema in order to specify an entity and an entity in a certain state (with "processed" set to "true" and a "processed-on" field set to some date and so on. With the ability to even spec functions with malli, we have all the building blocks to extend malli's capabilities to also specify the actual API: (def =>process-oder [:=> [:tuple entities/order events/process-order] entities/processed-order]) Now all that's missing is to map this to e.g. a POST request and generate a complete openapi-spec from it (schema+end points), so that e.g. a REST-Client can be generated from this code. At least that's how I would imagine it. Maybe I'm on the wrong track here, though.
have you looked at reitit-malli
? here’s an example: https://github.com/metosin/reitit/tree/master/examples/ring-malli-swagger
That's the best possible reply. Yes, there already is something and btw it's even better than what you had in mind. Thanks a bunch! 👍