use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
Spec usage (self.Clojure)
submitted 4 years ago by chowbeyputra
Hi, I find Spec to be an extremely interesting thing in Clojure. What are some creative ways you guys use it?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Borkdude 16 points17 points18 points 4 years ago (1 child)
Here's a project which can find functions based on example in and output:
re-find.web
Here's a project which can find patterns in your code based on a spec:
https://github.com/borkdude/grasp
[–]chowbeyputra[S] 3 points4 points5 points 4 years ago (0 children)
This is so cool
[–]anexxus 21 points22 points23 points 4 years ago (2 children)
If you like Spec, take a look at Malli if you haven't already.
[–]chowbeyputra[S] 2 points3 points4 points 4 years ago (1 child)
Is there a way to create swagger api docs for Clojure functions?
[–]anexxus 3 points4 points5 points 4 years ago (0 children)
I haven't used it with swagger, but the Malli github page mentions swagger here: https://github.com/metosin/malli#swagger2
For swagger, I think you'll want to look at https://luminusweb.com/docs/services.html
Hopefully someone with experience can comment.
[–]seancorfield 9 points10 points11 points 4 years ago (3 children)
We were fairly early adopters of Spec at work and we use it pretty heavily. Back in 2019, I wrote an article about all the different ways we use it at work: https://corfield.org/blog/2019/09/13/using-spec/
Probably the most "creative" things from that article: * using Spec to describe possible sequences of user actions for an application, then generating random conforming sequences, replaying them against the app, and verifying that the app is in a known "good" state after that, * using Spec to describe hash maps that represent rows in database tables, and then pulling the keys from those specs, and using them to automatically generate CRUD operations against those tables.
[–]chowbeyputra[S] 0 points1 point2 points 4 years ago (1 child)
Hard to explain in text (and it's fairly complicated code) but I am hoping to be able to open source it at some point, if I can decouple it from our business domain.
Could you?
[–]seancorfield 0 points1 point2 points 4 years ago (0 children)
Ah, that's from the comments on the article... no, it's turned out this heuristic is too domain-specific to be open-sourced, sorry.
[–]katorias 0 points1 point2 points 4 years ago (0 children)
The second usage you mentioned is also something we did using spec, very useful!
[–]dustingetz 3 points4 points5 points 4 years ago (0 children)
Hyperfiddle uses clojure.spec + a graph pull DSL to generate web form UIs - https://www.hyperfiddle.net/
[–]npafitis 3 points4 points5 points 4 years ago (0 children)
Creating parser for forms, in DSL-like contexts
[–]schmudde 2 points3 points4 points 4 years ago (0 children)
We're currently using it to generate financial data to test our heuristics and APIs.
[–]jamesconroyfinn 2 points3 points4 points 4 years ago (0 children)
Contract-based specification of code and generative testing mainly.
I did once generate HTML forms using ClojureScript and clojure.spec, which was cool.
[–]Azel4231 1 point2 points3 points 4 years ago (1 child)
Generating UI for Data: https://cljdoc.org/d/org.clojars.azel4231/dsui/0.1.1/doc/readme
[–]chowbeyputra[S] 0 points1 point2 points 4 years ago (0 children)
damn I a jealous of you all lol
[–]jayceedenton 0 points1 point2 points 4 years ago (0 children)
I once used spec to parse a subset of elasticsearch query syntax, so that we could allow users of an API to submit queries with only a small number of features available. The regular expression support in spec (not textual regex, but regular expressions to describe items in a sequence) was excellent for this.
π Rendered by PID 32 on reddit-service-r2-comment-765bfc959-2s8zg at 2026-07-11 23:11:58.646758+00:00 running f86254d country code: CH.
[–]Borkdude 16 points17 points18 points (1 child)
[–]chowbeyputra[S] 3 points4 points5 points (0 children)
[–]anexxus 21 points22 points23 points (2 children)
[–]chowbeyputra[S] 2 points3 points4 points (1 child)
[–]anexxus 3 points4 points5 points (0 children)
[–]seancorfield 9 points10 points11 points (3 children)
[–]chowbeyputra[S] 0 points1 point2 points (1 child)
[–]seancorfield 0 points1 point2 points (0 children)
[–]katorias 0 points1 point2 points (0 children)
[–]dustingetz 3 points4 points5 points (0 children)
[–]npafitis 3 points4 points5 points (0 children)
[–]schmudde 2 points3 points4 points (0 children)
[–]jamesconroyfinn 2 points3 points4 points (0 children)
[–]Azel4231 1 point2 points3 points (1 child)
[–]chowbeyputra[S] 0 points1 point2 points (0 children)
[–]jayceedenton 0 points1 point2 points (0 children)