Skip to content
oldsheeep3Public

About

Write an API once in .comat; get types, validation, clients and servers in eight languages

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

150 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Comatype

English | 日本語

Note

Comatype is in beta (0.0.x). The language, the CLI and the generated code may still change in incompatible ways.

Total downloads:

npm npm (JavaScript) PyPI crates.io RubyGems

Monthly downloads (crates.io and RubyGems do not publish a monthly count):

npm npm (JavaScript) PyPI

Write your API once in .comat files. Comatype generates types, validation, clients and servers for ten languages from them.

// comatfiles/user/[id]/put.comat  →  PUT /user/:id
import UserData from ../../../types/UserData.comat

params {
    id: uuidv4,
}

body UserData

s200 UserData
s404 ApiError

The language, the CLI and the generated code are specified in SPEC.md. A runnable sample project is in usage/.

Languages

TypeScript JavaScript Go Python Rust Java Kotlin Ruby Swift C# Dart: planned

TypeScript, JavaScript, Go, Python, Rust, Java, Kotlin, Swift, Ruby and C# — each as a client and as a server (Dart is planned). A client generated by Comatype is tested end to end against a server generated by Comatype, in every language.

Language Runtime package Status
TypeScript @comatype/typescript (npm) published (see the package README)
JavaScript @comatype/javascript (npm) not published yet (see the package README)
Go github.com/oldsheeep3/comatype/packages/go published (see the package README)
Python comatype (PyPI) published (see the package README)
Rust comatype (crates.io) published (see the package README)
Java / Kotlin net.sheeplab.comatype:comatype, :comatype-ktx (Maven Central) published (see the package README)
Ruby comatype (RubyGems) published (see the package README)
Swift packages/swift in this repository only
C# Comatype (NuGet) not published yet (see the package README)

The command line

# install a prebuilt binary (macOS, Linux; on Windows use the zip on the release page)
curl -fsSL https://raw.githubusercontent.com/oldsheeep3/comatype/main/install.sh | sh
# or build it from source:  cargo install --git https://github.com/oldsheeep3/comatype comatype-cli

comatype check                    # check every .comat file
comatype generate                 # generate code for the targets in comatype.config.json
comatype endpoints -g             # list endpoints, grouped by wrapper chain
comatype format comatfiles --fix  # rewrite file names to the recommended layout
comatype to-openapi -o openapi.yml

The configuration file is comatype.config.json; its JSON Schema is schema/comatype.config.schema.json (the VS Code extension applies it automatically).

Repository layout

Path Contents
crates/ Parser, checker, generators, OpenAPI conversion, language server and the CLI (Rust)
packages/ Runtimes that generated code depends on (c client, s server)
editors/vscode/ VS Code extension: highlighting, diagnostics, go to definition, completion
docs/ The website (Next.js static export; English at /, Japanese at /ja-jp/)
usage/ Sample project with generated code for every language
scripts/ Generated-code checks and end-to-end scripts

Development

cargo test
pnpm install
pnpm --dir docs dev               # http://localhost:5173
pnpm --dir docs check             # typecheck, build, test

./scripts/e2e-client.sh           # TypeScript
./scripts/e2e-js.sh               # JavaScript (needs Node 20+)
./scripts/e2e-go.sh
./scripts/e2e-python.sh           # needs a root .venv
./scripts/e2e-rust.sh
./scripts/e2e-java.sh             # needs JDK 21+
./scripts/e2e-kotlin.sh           # needs a JDK and kotlinc
./scripts/e2e-swift.sh            # needs Swift 5.9+
./scripts/e2e-ruby.sh             # needs Ruby 3.1+
./scripts/e2e-csharp.sh           # needs .NET 8+

Branches: main is the release, develop is the next version, hotfix is for urgent patches. Releasing is described in RELEASING.md.

License

MIT

About

Write an API once in .comat; get types, validation, clients and servers in eight languages

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages