Auto generates a fully typed OpenAPI spec from any .dar file.
The Canton JSON Ledger API has every contract using the same blank endpoints:
POST /v1/create
Body: {} - no field names, no types, nothing
DAML Cast reads your compiled .dar file and turns it into this:
POST /Agreement/MultiPartyAgreement/create
Body: {
proposer: string (daml-party)
signatories: array of party
requiredParties: array of party
terms: string
}
Paste that into Swagger UI or feed it into openapi-generator to get a typed SDK in TypeScript, Python, Java automatically.
- Node.js v18+
- Daml SDK:
curl -sSL https://get.digitalasset.com/install/install.sh | sh - A
.darfile
dpm damlc inspect-dar --json your-contract.dar > inspect.json
unzip -p your-contract.dar "*/YourModule.daml"The second command prints the Daml source templates, fields, choices.
cd DAML_cast
npm installnode cast.js
Output: openapi.yaml
cat openapi.yaml | pbcopyPaste into https://editor.swagger.io ...and you'll see all your endpoints rendered with types.
| Daml | JSON Schema | Notes |
|---|---|---|
Text |
string |
|
Party |
string |
Full ID e.g. Alice::122084... |
ContractId<T> |
string |
The long hex IDs from the ledger |
and more...
This prototype was built against a Sample .dar file present in the root dir test-agreement-1.3.0.dar, Feel free to alter the components based on your .dar needs and choices.
- Template:
MultiPartyAgreement - Fields:
proposer,signatories,requiredParties,terms - Choices:
AddParty(non-consuming)Close(consuming)
- Package ID:
01da4dba66c232540ae7d1214cc22e32dc89c9f36c114c7f1dec959ce81b66ac
Generated 4 endpoints, 4 schemas, zero errors in Swagger.