A scaffolding generator from Swagger files in Gerbil Scheme.
  • Scheme 99.6%
  • Makefile 0.4%
Find a file
2026-02-05 12:29:51 -07:00
build.ss updates 2026-02-04 19:50:01 -07:00
CLAUDE.md updates 2026-02-04 19:50:01 -07:00
codegen-test.ss Add human readable output 2026-02-05 12:29:51 -07:00
codegen.ss Add human readable output 2026-02-05 12:29:51 -07:00
gerbil.pkg updates 2026-02-04 19:50:01 -07:00
main.ss updates 2026-02-04 19:50:01 -07:00
Makefile updates 2026-02-04 19:50:01 -07:00
manifest.ss Add human readable output 2026-02-05 12:29:51 -07:00
parser-test.ss add updates. it works with jira swagger! 2026-02-04 20:18:25 -07:00
parser.ss add updates. it works with jira swagger! 2026-02-04 20:18:25 -07:00
README.md updates 2026-02-04 19:50:01 -07:00
scaffold.ss updates 2026-02-04 19:50:01 -07:00
util-test.ss add updates. it works with jira swagger! 2026-02-04 20:18:25 -07:00
util.ss add updates. it works with jira swagger! 2026-02-04 20:18:25 -07:00

gerbil-swagger

A Gerbil Scheme code generator that reads OpenAPI 2.0/3.0 JSON specs and produces a complete, compilable Gerbil project with CLI subcommands for each API operation.

Build

make build

Requires patchelf for OpenSSL rpath fixup on Linux.

Usage

swagger-codegen generate SPEC_FILE [options]

Options

Option Description
--output DIR -o Output directory (default: derived from spec title)
--package NAME -p Package name (default: derived from spec title)
--force -f Overwrite existing files

Example

swagger-codegen generate petstore.json -o ./petstore -p petstore --force
cd petstore
make build
./petstore-client help

Generated Project Structure

output-dir/
  gerbil.pkg        # package declaration
  build.ss          # build script with exe target
  Makefile           # build/clean/test targets with patchelf
  config.ss          # base-url, auth parameters
  types.ss           # defstruct per schema + JSON converters
  util.ss            # URL builder, response checker
  client.ss          # one function per API operation
  main.ss            # CLI with subcommands per operation
  client-test.ss     # test skeleton
  README.md          # generated docs

Features

  • Supports OpenAPI 2.0 (Swagger) and 3.0 specs
  • Generates keyword arguments for query/header/body parameters
  • Path parameters become positional arguments
  • Auth support: Bearer token, API key, Basic auth
  • Each subcommand includes --base-url, --token, --api-key options
  • Type structs with ->json and json-> converters
  • Eager $ref resolution with cycle detection

Project Structure (Generator)

gerbil-swagger/
  gerbil.pkg         # (package: swagger)
  build.ss           # build script
  Makefile            # build with patchelf
  util.ss             # name conversion, code emission helpers
  parser.ss           # OpenAPI spec parser (2.0 + 3.0)
  codegen.ss          # generates all output project files
  scaffold.ss         # writes generated files to disk
  main.ss             # CLI entry point
  util-test.ss        # tests (26 checks)
  parser-test.ss      # tests (38 checks)
  codegen-test.ss     # tests (40 checks)

Tests

gerbil test ./...

104 checks across 3 test suites.