Zero-setup SDK generator wrapping OpenAPI Generator
Project description
swain_cli
swain_cli is a zero-setup CLI around OpenAPI Generator. It downloads a pinned OpenAPI Generator JAR plus a trimmed Temurin JRE on demand and caches everything per user so you can build SDKs consistently without installing Java yourself.
Highlights
- Generate SDKs for multiple languages with a single command or an interactive wizard
- Ship exactly what you test with OpenAPI Generator
7.6.0pinned inside the toolchain - Launch the embedded OpenJDK 21 runtime automatically (or opt into your own
java) - Keep dependencies light (Typer, httpx, questionary, platformdirs, keyring, pooch) so
pipx, CI, and ephemeral environments stay happy - Inspect and manage the embedded engine with helper commands (
engine,doctor,list-generators) - Preview what will happen before you run it (
gen --dry-run,gen --plan-onlywith text/JSON output) - Persist defaults in a TOML config file and reuse named generation profiles (
config,profiles,gen --profile) - Opt into schema caching and post-generation hooks when you need them (
--schema-cache-ttl,--run-hooks)
Installation
Binary (no Python required)
- macOS/Linux:
curl -fsSL https://raw.githubusercontent.com/takifouhal/swain_cli/HEAD/scripts/install.sh | bash
- Windows (PowerShell):
iwr -useb https://raw.githubusercontent.com/takifouhal/swain_cli/HEAD/scripts/install.ps1 | iex
The single-file binary bundles a Python runtime, so no system Python is needed. On first run, swain_cli downloads a trimmed Temurin JRE plus the pinned OpenAPI Generator JAR and caches them.
Notes:
- Linux arm64 is supported (built via emulated runner).
- Windows on ARM uses the x86_64 binary and runs under emulation.
- Installers verify SHA-256 checksums when available; set
SWAIN_CLI_INSTALL_REQUIRE_CHECKSUM=1to require them.
Homebrew (macOS + Linux)
We publish the same single-file binaries through a lightweight tap so you can manage upgrades via Homebrew.
brew tap takifouhal/swain_cli https://github.com/takifouhal/swain_cli
brew install takifouhal/swain_cli/swain_cli
Homebrew installs the PyInstaller binary, so no additional Python dependencies are required. Upgrade with brew upgrade takifouhal/swain_cli/swain_cli.
pip/pipx (requires Python 3.8+)
pipx install swain_cli
Installing with pipx keeps swain_cli isolated; alternatively run pip install swain_cli in a virtual environment.
Quick start
# Prime the embedded runtime so the first real run is instant
swain_cli engine install-jre
# Create a config file (optional)
swain_cli config init
# Explore generators and craft a command via guided prompts
swain_cli interactive
# List all generators (delegates to the pinned OpenAPI Generator)
swain_cli list-generators
# Generate Python and TypeScript clients into ./sdks/<generator>
swain_cli gen -i ./openapi.yaml -l python -l typescript -o ./sdks \
-p packageName=my_api_client -p packageVersion=0.3.0
# Preview the resolved plan without downloading/fetching anything
swain_cli gen --plan-only -i ./openapi.yaml -l python -o ./sdks
swain_cli streams generator output directly so you see progress in real time.
Generating SDKs
swain_cli genaccepts every OpenAPI Generator flag you already know (-c,-t,-p, etc.) and repeatable-l/--langoptions.- By default the CLI talks to
https://api.swain.technologyfor Swain discovery and downloads the CrudSQL dynamic swagger fromhttps://api.swain.technology/api/crud. Override with--swain-base-url(platform) and/or--crudsql-url(CrudSQL), or point to a local spec via-i/--schema. Example local backend:swain_cli interactive --swain-base-url http://localhost:8080(infers CrudSQL ashttp://localhost:8080/api/crud). - When generating from a downloaded dynamic swagger,
swain_clipatches the schema base URL (Swaggerhost/schemes/basePathor OpenAPIservers) so generated SDKs default to the same host/path you pointed the CLI at. - Swain project integration: provide
--swain-project-idand--swain-connection-idto resolve the deployed connection swagger automatically after authenticating. Discover IDs withswain_cli projectsandswain_cli connections. The CLI will find the active build, fetch its/api/dynamic_swagger, and feed it to the generator. - JVM tuning: runs start with
-Xms2g -Xmx10g -XX:+UseG1GC. If the build still runs out of memory the CLI retries at-Xmx14g. Supply extra options with--java-opt(repeatable) or exportSWAIN_CLI_JAVA_OPTS. - Docs/tests are disabled by default via
--global-property=apiDocs=false,apiTests=false,modelDocs=false,modelTests=false; override with your own--generator-argwhen you need them. - Operation examples are skipped by default (
--skip-operation-example) to avoid OpenAPI Generator blowing up on circular schemas; pass your own generator arg to opt back in if you really need them. - To match modern OAS defaults the CLI automatically adds
-p disallowAdditionalPropertiesIfNotPresent=false. Opt into stricter behaviour with-p disallowAdditionalPropertiesIfNotPresent=trueor a generator config file. - The
typescriptshortcut maps totypescript-axios; requesttypescript-fetchexplicitly when you need that runtime. - Plan output:
--plan-onlyis side-effect free (no network / no downloads).--dry-runcan resolve schemas (may fetch/auth) but does not invoke the generator.- Use
--plan-format json --prettyfor machine-readable plans.
- Schema caching: pass
--schema-cache-ttl 10m(or2h) to cache fetched schemas; disable with--no-schema-cache. - Hooks (dangerous): pass
--run-hooksto enable--post-hookcommands and any hooks configured in a profile.
Command reference
swain_cli interactive— guided prompts to build aswain_cli gencommand (use--no-runto only print).swain_cli list-generators— enumerate all generators provided by the pinned OpenAPI Generator JAR. Add--engine systemto validate a local Java installation instead.swain_cli doctor— print environment information, cache paths, installed JREs, and JAR availability (--format jsonfor automation/support bundles).swain_cli auth— manage credentials for hosted Swain services (login,logout,status,refresh).swain_cli config— manage the TOML config file (path,init,show).swain_cli profiles— inspect named generation profiles from the config file (list,show).swain_cli projects— list Swain projects (non-interactive; JSON by default).swain_cli connections— list Swain connections by--project-id/--connection-id(non-interactive; JSON by default).swain_cli schema— fetch a Swain connection schema by--connection-id(prints to stdout, or write with--out).swain_cli engine <action>— inspect, clean, and manage the embedded runtime (status,paths,clean,prune-jars,install-jre,update-jar).swain_cli plugins list— list installed plugins (entry points group:swain_cli.plugins).swain_cli self-update— replace the running binary with a newer release (binary installs only).
Run swain_cli --help or swain_cli <command> --help for full usage.
Authentication
Use the auth subcommands to prepare credentials before generating SDKs against hosted Swain projects.
swain_cli auth login— authenticate via username/password (POST /api/auth/loginon the v2 backend, with a legacy/auth/loginfallback). Access and refresh tokens are stored in the system keyring.- Refresh tokens are stored for future use; use
swain_cli auth refreshto refresh manually. - For ephemeral automation, set
SWAIN_CLI_AUTH_TOKEN(takes precedence over the keyring). - For CI systems that prefer file-based secrets, set
SWAIN_CLI_AUTH_TOKEN_FILEto a file containing the token. swain_cli auth status— inspect the active token source and storage location.swain_cli auth logout— clear the stored token.- The interactive wizard checks for a token before listing projects and will prompt you to sign in if missing.
Engine modes and caching
- Embedded engine (default) — the first run downloads a platform-specific Temurin JRE and caches it alongside the pinned OpenAPI Generator JAR under
~/.cache/swain_cli(Linux),~/Library/Caches/swain_cli(macOS), or%LOCALAPPDATA%\swain_cli\cache(Windows). Override withSWAIN_CLI_CACHE_DIR. - Custom asset base (advanced) — set
SWAIN_CLI_ASSET_BASEto override where embedded JRE archives are downloaded from. - System engine — add
--engine system(or exportSWAIN_CLI_ENGINE=system) to run with whateverjavais already onPATH. - Offline use — prime the cache via
swain_cli engine install-jreandswain_cli engine update-jar --version 7.6.0(or runswain_cli list-generatorsonce) or copy an existing cache directory between machines. - Integrity checks — downloads are verified by checksum by default. Set
SWAIN_CLI_VERIFY_SIGNATURES=1to additionally verify GPG signatures for release assets when available (requiresgpg). This also defaultsswain_cli self-updateto signature verification.
Running in CI
- Install the package (
pipx install swain_cliorpip install swain_cli). - Pre-install the embedded runtime during setup:
swain_cli engine install-jre. - Cache the swain_cli cache directory between jobs to reuse downloads.
- Invoke
swain_cli genwith your schema and desired generators; capture./sdks(or your chosen output path) as build artefacts. - Optional: run
swain_cli gen --plan-only ...as a fast “configuration validation” step.
Swain discovery helpers for automation:
swain_cli projects --format jsonswain_cli connections --project-id 123 --format jsonswain_cli schema --connection-id 456 --out openapi.json
YAML patching (optional)
Schema patching works for JSON out of the box. If you need to patch YAML specs, install the extra:
pipx install "swain_cli[yaml]"
Container image (CI)
We publish a container image with the embedded toolchain pre-warmed (JRE + pinned generator jar). Run:
docker run --rm ghcr.io/<owner>/swain_cli --help
Troubleshooting
- Download failures — check proxy/firewall configuration, or download the JRE asset manually from the GitHub release and place it under the cache path from
swain_cli doctor. - Missing generators — run
swain_cli list-generators --engine systemto validate your local Java installation or after updating the JAR withengine update-jar. - Cache cleanup — delete the directory printed by
swain_cli doctorto force a clean fetch of the runtime and JAR. - OutOfMemoryError — the CLI already retries with a larger heap. For massive specs raise the ceiling with repeatable
--java-opt -Xmx16gor setSWAIN_CLI_JAVA_OPTS.
Contributing
- Create a virtual environment (
python -m venv .venv) and activate it. - Install the project with dev + lint extras:
pip install -e .[dev,lint]. - Run the CLI locally via
python -m swain_cli --help,python -m swain_cli.cli --help, or theswain_clientry point. - Run checks:
./scripts/check.sh(macOS/Linux) orpowershell -File scripts/check.ps1(Windows).
Maintainers
- Trigger the
build-jreworkflow (workflow dispatch) to build trimmed JRE archives for Linux (x86_64 + arm64), macOS (Intel + Apple Silicon), and Windows. Provide an optionalrelease_tagto publish directly to ajre-<version>release. - Use
python scripts/sync-jre-checksums.py combined-checksums.txt --writeto updateswain_cli/constants.py(theJRE_ASSETSmapping) and updateASSET_BASE(or setSWAIN_CLI_ASSET_BASE) if you move assets to a new release tag. - Tag releases (
git tag vX.Y.Z) once assets are ready. The full release runbook lives indocs/RELEASING.md.
Third-party notices
- OpenAPI Generator (Apache 2.0)
- Eclipse Temurin OpenJDK (GPLv2 with Classpath Exception)
License
swain_cli is released under the Apache 2.0 license. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swain_cli-0.3.16.tar.gz.
File metadata
- Download URL: swain_cli-0.3.16.tar.gz
- Upload date:
- Size: 129.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a290286e37438cc59fb6bda529da59afa42ebf51489fe57fb1fc6a7cc69ffe6
|
|
| MD5 |
14a7e033e64a940dfde0bc41744c88f0
|
|
| BLAKE2b-256 |
7e2d97a59395d8102ba71bc1de768e1183e67ef4ea90f0f9da1aad1c957fbc39
|
Provenance
The following attestation bundles were made for swain_cli-0.3.16.tar.gz:
Publisher:
release.yml on takifouhal/swain_cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
swain_cli-0.3.16.tar.gz -
Subject digest:
0a290286e37438cc59fb6bda529da59afa42ebf51489fe57fb1fc6a7cc69ffe6 - Sigstore transparency entry: 1512213520
- Sigstore integration time:
-
Permalink:
takifouhal/swain_cli@81cd34de0d55c6d28e1809dcbbc21ec73d68b257 -
Branch / Tag:
refs/tags/v0.3.16 - Owner: https://github.com/takifouhal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@81cd34de0d55c6d28e1809dcbbc21ec73d68b257 -
Trigger Event:
push
-
Statement type:
File details
Details for the file swain_cli-0.3.16-py3-none-any.whl.
File metadata
- Download URL: swain_cli-0.3.16-py3-none-any.whl
- Upload date:
- Size: 86.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18ac44df8617e7696b2c159cdd4bdb6b95e906581f65a073d83746d250f28eca
|
|
| MD5 |
352626c22e2805ab466c3a273fce11a2
|
|
| BLAKE2b-256 |
2cf764130983896fefd0b6388e6fab3e9a2eacb1c58831de2cccf2c4cde97344
|
Provenance
The following attestation bundles were made for swain_cli-0.3.16-py3-none-any.whl:
Publisher:
release.yml on takifouhal/swain_cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
swain_cli-0.3.16-py3-none-any.whl -
Subject digest:
18ac44df8617e7696b2c159cdd4bdb6b95e906581f65a073d83746d250f28eca - Sigstore transparency entry: 1512213705
- Sigstore integration time:
-
Permalink:
takifouhal/swain_cli@81cd34de0d55c6d28e1809dcbbc21ec73d68b257 -
Branch / Tag:
refs/tags/v0.3.16 - Owner: https://github.com/takifouhal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@81cd34de0d55c6d28e1809dcbbc21ec73d68b257 -
Trigger Event:
push
-
Statement type: