Fork me on GitHub

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.


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! 👍