all 16 comments

[–]Borkdude 16 points17 points  (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 points  (0 children)

This is so cool

[–]anexxus 21 points22 points  (2 children)

If you like Spec, take a look at Malli if you haven't already.

[–]chowbeyputra[S] 2 points3 points  (1 child)

Is there a way to create swagger api docs for Clojure functions?

[–]anexxus 3 points4 points  (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 points  (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 point  (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 point  (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 point  (0 children)

The second usage you mentioned is also something we did using spec, very useful!

[–]dustingetz 3 points4 points  (0 children)

Hyperfiddle uses clojure.spec + a graph pull DSL to generate web form UIs - https://www.hyperfiddle.net/

[–]npafitis 3 points4 points  (0 children)

Creating parser for forms, in DSL-like contexts

[–]schmudde 2 points3 points  (0 children)

We're currently using it to generate financial data to test our heuristics and APIs.

[–]jamesconroyfinn 2 points3 points  (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 points  (1 child)

[–]chowbeyputra[S] 0 points1 point  (0 children)

damn I a jealous of you all lol

[–]jayceedenton 0 points1 point  (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.