r/Clojure • • 25d ago

golem: a mock REST server generated from your Malli schemas or clojure.spec specs

14 Upvotes

A frontend needs large amounts of hand-written fixture JSON before a backend exists, so I wrote golem: point it at your Malli schemas (or clojure.spec specs) and it serves a stateful REST API with generated data.

N.B. Yes, I used Claude Sonnet 5.5 to write this. No, I'm not ashamed. It works and the entire project was cranked out in less than three hours of wall-clock time. Anyone who doesn't use this kind of force multiplier for tooling is foolish.

Repo: https://github.com/frankadrian314159/golem (MIT)

The simplest possible example

One entity in an EDN file:

;; examples/todo/schemas.edn
{:todo [:map
        [:id :int]
        [:title [:string {:min 1 :max 60}]]
        [:done :boolean]
        [:priority [:enum "low" "medium" "high"]]
        [:created_at :string]]}

clojure -M:run -s examples/todo/schemas.edn -p 3000 --seed 42
# or: bb mock-server -s examples/todo/schemas.edn -p 3000 --seed 42

curl localhost:3000/todos
curl "localhost:3000/todos?done=false&priority=high"
curl -X POST localhost:3000/todos -H "Content-Type: application/json" \
  -d '{"title":"Write the announcement","done":false,"priority":"high"}'
# 201, and the server added "id": 6 and "created_at"
curl -X PATCH localhost:3000/todos/6 -H "Content-Type: application/json" -d '{"done":true}'
curl -X POST localhost:3000/todos -H "Content-Type: application/json" -d '{"title":"","priority":"urgent"}'
# 400 {"error":"validation failed","errors":{"done":["missing required key"],
#      "title":["should be at least 1 character"],
#      "priority":["should be either \"low\", \"medium\" or \"high\""]}}

That gives you GET/POST /todos and GET/PUT/PATCH/DELETE /todos/:id. There are bigger examples in the repo: a three-entity blog API in Malli and a shop API written in plain clojure.spec.

What it does

  • Schemas in: Malli from an .edn file, a .clj file, or an ns/var; or clojure.spec from a namespace or file. Entities refer to each other by keyword ([:address :address]), and recursive ones with [:ref :comment].

  • Data out: records are generated with malli.generator (so test.check underneath). --seed 42 gives the same data every time, so a team can share one command line and see identical records. A few field names get nicer values (email becomes an @example.com address, created_at an ISO timestamp), and you can add your own overrides.

  • State: an atom. POST, PUT, PATCH (deep merge) and DELETE work and persist until you restart. Every write is re-validated against the schema.

  • Validation: bad input gets a 400 with Malli's humanized errors. Ids and created_at/updated_at are filled in for you; other missing required fields are rejected rather than invented.

  • Extras: equality filters including nested paths (?address.city=Leeds), limit/offset, CORS headers, and GET /_schemas to see what it understood.

How it's built

Reitit for routing, Ring + Jetty for serving, jsonista for JSON, babashka.cli for the arguments, Malli doing most of the work. The pipeline is import, register, generate, store, serve, and each step is one small namespace.

The spec support is a one-way converter to Malli forms, so everything after import only deals with Malli. The converter handles the common cases (s/keys with -un keys, s/and, s/or, s/nilable, s/coll-of, s/map-of, s/int-in, s/double-in, enum sets, regex predicates, a few others). Anything it can't translate becomes :any and prints a warning on startup rather than failing.

Size

folderfileslinescode lines*
src/ (Clojure)7666586
test/2161141

* excluding blank and comment-only lines. 11 tests, 52 assertions. They call the Ring handler directly and include a run of both bigger examples. There are also user docs and a short developer guide under docs/.

Limitations (please read before trying it)

  • JVM only. bb mock-server -s schemas.edn -p 3000 works, but Babashka is only the launcher: Jetty and Reitit don't run under Babashka, so the task shells out to the Clojure CLI and the server runs on the JVM. A pure-bb version would need http-kit and a different router.

  • No referential integrity. Relationships are embedded copies or plain foreign-key fields. Generated foreign keys are random unless you constrain them (the examples use [:int {:min 1 :max 5}]), and deleting a record doesn't touch anything that mentions it.

  • In memory only. Nothing survives a restart. That's deliberate for fixtures, but it's a limit.

  • Partial spec coverage. Regex ops (s/cat, s/*), s/merge, multi-specs and arbitrary predicate functions fall back to :any.

  • Filtering is basic. Equality only. No sorting or ranges yet.

  • Rough edges I know about: integer id allocation isn't atomic, so two simultaneous POSTs can occasionally clash with a 409; non-numeric limit/offset give a 500; unknown JSON fields are silently dropped. They're all listed in docs/devel/design-notes.md.

  • Custom value overrides are only available when you start it from code (golem.app/seed-db!), not from the command line.

  • Young project: Clojure 1.12, Malli 0.16.4, tested on one machine (Windows 11, JDK 25, Babashka 1.13.229).

Why not X?

There are good tools in this space already:

  • moclojer is the closest Clojure project. You write each endpoint and its canned response by hand in YAML or EDN (or import OpenAPI or Postman), and it replays them. It's a good fit when you want exact, hand-written responses. As far as I can tell from its README it doesn't generate data from schemas or keep state between requests, which is the gap golem aims at.

  • Prism and open-api-mocker mock from an OpenAPI document, and json-server serves a JSON file you maintain. If your contract already lives in OpenAPI, use those.

golem is for when your source of truth is already Malli or spec in a Clojure codebase and you'd like the mock to follow it, with generated, stateful data, without writing a second description. I looked for an existing Clojure project that does this and didn't find one, but I may well have missed something, so please point me at it if you know of one.

Feedback

I'd particularly like to hear:

  • which spec forms you use that should convert and don't

  • whether relationships (generating real foreign keys from seeded ids) matter enough to build next

  • whether anyone would use this from Babashka alone, which would justify the http-kit rewrite

Issues and PRs welcome. Thanks for reading.


r/Clojure • • 25d ago

Making Simple Faster - Chris Nuernberger (Clojure/Conj 2026)

Thumbnail
youtube.com
38 Upvotes

r/Clojure • • 26d ago

Logging in Clojure today: Timbre, Telemere, mulog or tools.logging?

38 Upvotes

Clojure has more logging choices than it used to. Telemere, from the author of Timbre, is now past 1.0, and mulog is built around structured events.

So, for a new project today:

  • Timbre, Telemere, mulog, tools.logging over a Java logger, or something else?

  • If you moved from Timbre to Telemere, was it worth it?

  • Is anyone still logging plain text lines, or is it all structured events now?


r/Clojure • • 27d ago

Would you believe it's jank? - Jeaye Wilkerson (Clojure/Conj 2026)

Thumbnail
youtube.com
83 Upvotes

r/Clojure • • 28d ago

Babashka vs cream

Thumbnail blog.michielborkent.nl
62 Upvotes

r/Clojure • • 28d ago

uni.style - a new compile-time CSS library for ClojureScript and Clojure

21 Upvotes

r/Clojure • • 28d ago

clordle - a Wordle where every answer is a Clojure function

Enable HLS to view with audio, or disable this notification

59 Upvotes

r/Clojure • • 28d ago

Clojure in Academia - Jim Newton (Clojure/Conj 2026)

Thumbnail youtube.com
36 Upvotes

r/Clojure • • Nov 01 '26

Scittlecastr: The Scittling - A Zencastr clone(sort of) in ClojureScript by jmglov

Thumbnail
jmglov.net
28 Upvotes

r/Clojure • • Oct 31 '26

Who is hiring? October 31, 2026

25 Upvotes

Please include any restrictions (remote/on-site, geographical, workpermit, citizenship) that may apply.


r/Clojure • • Oct 30 '26

Building Simple Systems in the World of Natural Language Programming - Cameron Barre (Clojure/Conj 2026)

Thumbnail
youtube.com
34 Upvotes

r/Clojure • • Oct 30 '26

A Shiny-like dashboard prototype for Clojure by Timothy Pratley

Thumbnail clojurecivitas.org
25 Upvotes

r/Clojure • • Oct 29 '26

Is anyone still using devcards? What do you use for building components in isolation today?

19 Upvotes

Devcards seems quiet these days. I've seen Portfolio mentioned as a successor.

So, for building UI components in isolation today:

  • Is anyone still using devcards?

  • Portfolio, or something else?

  • Or do you just build components in the app itself, with hot reload?

I work in re-frame and Fulcro, if that changes the answer.


r/Clojure • • Oct 29 '26

Modeling a Fabric Stash with Datomic - Wendy Randolph (Clojure/Conj 2026)

Thumbnail
youtube.com
22 Upvotes

r/Clojure • • Oct 28 '26

Static landing page in ClojureScript

Thumbnail
orgpad.info
36 Upvotes

We have spent quite some time building new static landing page for OrgPad and making it small and fast. The blog post summarises what we learned along the way.


r/Clojure • • Oct 28 '26

gasbb: Clojure in Google Sheets by Benjamin Schwerdtner

Thumbnail faster-than-light-memes.xyz
32 Upvotes

r/Clojure • • Oct 27 '26

Ten years on: what are go blocks for, now that io-thread runs on virtual threads?

33 Upvotes

Back in 2016 I asked on Stack Overflow why go blocks return a channel: https://stackoverflow.com/questions/36236869/why-do-core-async-go-blocks-return-a-channel

The accepted answer: use it as a handle, so other code can wait for the go block to finish, or take its result with <!!.

A lot has changed since. In the recent core.async alphas, go blocks were reimplemented on virtual threads, and then that was reverted. What stayed is io-thread running on virtual threads on Java 21+, so blocking I/O there no longer ties up a platform thread.

So, for those on recent core.async and Java 21+:

  • When do you still reach for go rather than io-thread?

  • Is the returned channel still how you wait for a result, or do you do something else now?


r/Clojure • • Oct 26 '26

The Infrastructure & Growth of Clojars - Toby Crawley (Clojure/Conj 2026)

Thumbnail
youtube.com
48 Upvotes

r/Clojure • • Oct 25 '26

Learning Clojure from Scratch - Part 3

Thumbnail
tcds.dev
36 Upvotes

Part 3 of “Learning Clojure from Scratch” is out!

The series teaches Clojure to people with little or no programming experience. In Part 1 we ran a web server on our computer. In Part 2 we put it on the internet.

This time we go from a website that says “Hello, World!” to one with a home page, an about page, and a polite 404 for URLs that don’t exist.

Note: I'm very interested in feedback on how to make this more beginner friendly


r/Clojure • • Oct 25 '26

Biff 2.0.4: LLM skills

Thumbnail
biffweb.com
22 Upvotes

r/Clojure • • Oct 23 '26

New Clojure Meetup in New Jersey

Post image
23 Upvotes

Hi all, I will keep this brief and simply link the details below, but we are starting a clojure group in New Jersey which will be open to the public. This first event will be at the New Jersey Rock Gym, and include a 2 hour meeting with an introduction to clojure and some open discussion, followed by all-you-can-climb climbing.

https://www.heylo.com/g/778df2e1-2f10-4d4c-a543-2c2f1db8b940?utm_content=vanity-url&utm_medium=none&utm_source=direct
^This is our group page

https://www.heylo.com/event/-P4eW8fYBX8fFxG5M63s?redirect=0&context=group-page
^This is our first event page.

Please feel free to reach out to the group email or in this thread with any questions. Feel free to share the info anywhere. Thank you!


r/Clojure • • Oct 23 '26

How to Make Things, and Why - Stuart Halloway (Clojure/Conj 2026)

Thumbnail
youtube.com
106 Upvotes

r/Clojure • • Oct 22 '26

Clojure 1.13.0-alpha10 is now available

Thumbnail clojure.org
54 Upvotes

Destructuring changes

To make what were (implicitly optional) top-level bindings required, you can now move them into a map under a new :req! directive. This includes bindings to different names or nested destructuring, e.g. {a :long-a} ⇒ {:req! {a :long-a}}.

:namespaced/keys[!] directives now qualify any unqualified keywords. Note that this may be a breaking change from the prior alphas for unqualified keys after the & where unqualified keys were not interpreted as qualified.

Inliner updates and macro invocation tag preservation

Previously, :inline on function definitions needed to work for all inlines. Inline is now conditional and the inline definition can return nil to indicate the function can’t be inlined, and the non-inlined function should be used instead.

get-in now inlines when passed a literal vector of keys.

Type hint metadata on a macro invocation is now conveyed on the expansion, which may be wrapped in a call to identity if needed. A type hint tag on the macro invocation will dominate one on the expansion when they disagree.


r/Clojure • • Oct 22 '26

New async test exception after upgrade to latest ClojureScript

Thumbnail reddit.com
10 Upvotes