A minimal Gleam project that uses an oaspec-generated client for the
Petstore OpenAPI spec at test/fixtures/petstore.yaml.
- Generating a client from an OpenAPI 3.x spec via
oaspec.yaml. - Importing the generated client and response types.
- Building a
ClientConfigwith a customsendfunction (here a stub that returns a canned JSON body — swap ingleam_httpc,mist, orwispfor real traffic). - Handling the typed response variants that oaspec generates for each operation.
From the repo root:
just example-petstoreOr manually:
# 1. Regenerate the client code (already committed — only needed if
# the spec or oaspec itself changed).
gleam run -- generate --config=examples/petstore_client/oaspec.yaml
# 2. Run the example.
cd examples/petstore_client
gleam runExpected output:
Got 2 pet(s):
- Fido (id=1)
- Whiskers (id=2)
examples/petstore_client/
gleam.toml — project manifest
oaspec.yaml — generator config (input: petstore.yaml)
src/api/ — generated client code (checked in)
src/petstore_client_example.gleam — the program you run
examples/server_adapter— a framework-free runnable example that bridges the generatedrouter.route/5to a canned request/response pair. Run it withjust example-server-adapter.
A security_client example is still to come; see Issue #26.