Recently we released OpenAPI Generator v7.0.0 and we’ve added the mapping features
in the Crystal client generator.
To give it a try, please install openapi-generator via NPM package manager or brew (Java 11 required). If you don’t have JAVA 11 installed, please use docker instead.
To generate a Crystal API client for Petstore spec, please run the following:
Reviving this thread because the Crystal client generator just got a substantial overhaul.
I’ve opened PR #24070 — [Crystal] idiomatic API redesign (targeting 7.24.0, currently in review). It reworks the generated output from the original flat, Ruby-ported shape into something that actually feels like Crystal — and fixes a pile of constructs that simply didn’t compile or crashed at runtime on real specs.
What the generated client looks like now:
# Before — global singleton, prefixed methods, http_info twins
api = Petstore::PetApi.new
pets, status, headers = api.find_pets_by_status_with_http_info(["available"])
# After — per-instance client, namespaced sub-clients routed from the path, typed Response(T)
client = Petstore::Client.new(host: "petstore.swagger.io")
pets = client.pet.find_by_status(status: ["available"]).value
Highlights:
Namespaced sub-clients (client.collections.points.search(...)) instead of one XApi class per tag with prefixed methods.
One generic request path — each operation is a short declarative call returning a typed Response(T); no more _with_http_info duplicates (~38 lines of boilerplate per op → a few).
Native multi-instance — each Client owns its own Connection/Configuration (no global singleton).
Real fixes: runtime oneOf/anyOf crashes, named-enum deserialisation, allOf inheritance with discriminators, multipart file upload, cookie params, non-JSON/binary responses, opt-in logging.
Models are leaner: one declarative validates macro replaces the per-model EnumAttributeValidator hierarchy; anyOf/oneOf become real union wrappers; named enums become transparent aliases.
It’s not synthetic — the new output already ships in production. The generator powers a real Qdrant stack in Crystal:
qdrant-api.cr — the low-level REST client, generated by this generator from Qdrant’s full OpenAPI spec (~320 models, anyOf unions, named enums).
qdrant-client.cr — an idiomatic RAG-oriented wrapper, tested in CI against a real Qdrant container.
mnemodoc — a self-hosted, local-first MCP server for semantic doc search (your data stays on your machine) that uses it as its vector store.
Several of the bugs fixed here were surfaced precisely by generating against that full spec, not by the test fixtures. Both samples (petstore and a new crystal-qdrant) compile and crystal spec runs green.
Feedback from Crystal folks would be very welcome on the PR — especially on the generated API ergonomics.