https://github.com/the-codegen-project/cli
Your one stop boilerplate killer for any standard!
https://github.com/the-codegen-project/cli
amqp asyncapi event-source generator kafka mqtt nats openapi openapi-generator openapi3 the-codegen-project typescript
Last synced: 3 days ago
JSON representation
Your one stop boilerplate killer for any standard!
- Host: GitHub
- URL: https://github.com/the-codegen-project/cli
- Owner: the-codegen-project
- License: apache-2.0
- Created: 2024-04-15T19:01:11.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2026-01-18T14:42:01.000Z (10 days ago)
- Last Synced: 2026-01-18T20:57:48.395Z (10 days ago)
- Topics: amqp, asyncapi, event-source, generator, kafka, mqtt, nats, openapi, openapi-generator, openapi3, the-codegen-project, typescript
- Language: TypeScript
- Homepage: https://the-codegen-project.org/
- Size: 74.4 MB
- Stars: 32
- Watchers: 1
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Contributing: docs/contributing.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README

β‘οΈThe Codegen Projectβ‘οΈ
[](https://github.com/the-codegen-project/cli/blob/master/LICENSE)
[](https://www.npmjs.com/package/@the-codegen-project/cli)









)
)
[](#contributors-)
Generate payload models, parameters, headers, messages, communication support functions, and much more...
[Read the Docs](https://the-codegen-project.org/docs/) | [View Demos](./examples/README.md)
# Core Features
- π Generate [payloads](https://the-codegen-project.org/docs/generators/payloads), [headers](https://the-codegen-project.org/docs/generators/headers), [parameters](https://the-codegen-project.org/docs/generators/parameters), [protocol helpers](https://the-codegen-project.org/docs/generators/channels), [full clients](https://the-codegen-project.org/docs/generators/client), [models](https://the-codegen-project.org/docs/generators/models), [simple types](https://the-codegen-project.org/docs/generators/types), or all of the above from your [AsyncAPI v2 and v3](https://the-codegen-project.org/docs/inputs/asyncapi)
- π Generate [payloads](https://the-codegen-project.org/docs/generators/payloads), [headers](https://the-codegen-project.org/docs/generators/headers), [parameters](https://the-codegen-project.org/docs/generators/parameters), [models](https://the-codegen-project.org/docs/generators/models), [simple types](https://the-codegen-project.org/docs/generators/types), or all of the above from your [Swagger 2.0, or OpenAPI 3.0, and 3.1](https://the-codegen-project.org/docs/inputs/openapi)
- π Generate [models](https://the-codegen-project.org/docs/generators/models) or [completely customize it](https://the-codegen-project.org/docs/generators/custom) for [JSON Schema Draft-4, Draft-6 and Draft-7](https://the-codegen-project.org/docs/inputs/jsonschema)
- π Every generator fully customizable to fit your hearts desire
- π Integrate it into any project (Demos in [Next.JS](./examples/typescript-nextjs), [TypeScript Libraries](./examples/typescript-library))
- π
[Create custom generators to your use-case](https://the-codegen-project.org/docs/generators/custom)
- ποΈ Protocol agnostic generator ([NATS](https://the-codegen-project.org/docs/protocols/nats), [Kafka](https://the-codegen-project.org/docs/protocols/kafka), [MQTT](https://the-codegen-project.org/docs/protocols/mqtt), [AMQP](https://the-codegen-project.org/docs/protocols/amqp), [event-source](https://the-codegen-project.org/docs/protocols/eventsource), [HTTP Client](https://the-codegen-project.org/docs/protocols/http_client), [WebSocket](https://the-codegen-project.org/docs/protocols/websocket), read the [docs](https://the-codegen-project.org/docs#protocols) for the full list and information)
- β And much more...
# How it works
The Codegen Project is a generator that is built to live alongside your projects to help you save time in the development phase, ensuring you spend as much time on the business logic as possible. It works by using your configuration file to know what it needs to generate.
Each input has different generators and [all of them can be customized](https://the-codegen-project.org/docs/generators), or you can build your own generator [right in the configuration file](https://the-codegen-project.org/docs/generators/custom).
```ts
export default {
inputType: 'asyncapi',
inputPath: './asyncapi.json',
language: 'typescript',
generators: [
{
preset: 'payloads',
outputPath: './src/payloads',
serializationType: 'json',
},
...
]
};
```
In this example, the generator will read the AsyncAPI document located in same directory as the configuration file, and generate TypeScript models for all the payload including code to serialize the models to JSON.
# π Sponsors
CodeForge
Automated SDK generation platform built on The Codegen Project
---
# Getting started
Its simple, [install the CLI](#install) into your project or machine, [setup the Codegen configuration file](#initialize) to include all the code your heart desire, customize it, and generate it at build time or whenever you feel like it.
## Install
Installing the CLI can be done inside a project or within your system.
Package manager
MacOS x64
MacOS arm64
Windows x64
Windows x32
Linux (Debian)
Linux (Others)
#### NPM
```sh
npm install --save-dev @the-codegen-project/cli
npm install -g @the-codegen-project/cli
```
#### Yarn
```sh
yarn add @the-codegen-project/cli
```
#### Pnpm
```sh
pnpm add @the-codegen-project/cli
```
#### Bun
```sh
bun add @the-codegen-project/cli
```
#### Download
```sh
curl -OL https://github.com/the-codegen-project/cli/releases/latest/download/codegen.x64.pkg
```
#### Install
```sh
sudo installer -pkg codegen.x64.pkg -target /
```
#### Download
```sh
curl -OL https://github.com/the-codegen-project/cli/releases/latest/download/codegen.arm64.pkg
```
#### Install
```sh
sudo installer -pkg codegen.arm64.pkg -target /
```
#### Download
```sh
curl -OL https://github.com/the-codegen-project/cli/releases/latest/download/codegen.deb
```
#### Install
```sh
sudo apt install ./codegen.deb
```
#### Download
```sh
curl -OL https://github.com/the-codegen-project/cli/releases/latest/download/codegen.tar.gz
```
#### Install
```sh
tar -xzf codegen.tar.gz
```
#### Symlink
```sh
ln -s /bin/codegen /usr/local/bin/codegen
```
You can find all the possible commands in [the usage documentation](https://the-codegen-project.org/docs/usage).
## Initialize
Add a configuration file, either manually or through the CLI;
```sh
codegen init
```
[](./assets/videos/initialize.gif)
[Customize it to your heart's desire!](https://the-codegen-project.org/docs/generators)
## Generate
With your configuration file in hand, time to generate the code and use it! This can be done manually or integrate into your build process. Checkout [all the examples](./examples/) for inspiration on how to do it.
### Basic Generation
```sh
# Generate code once
codegen generate
# Generate with specific config file
codegen generate ./my-config.js
```
### Watch Mode (Development)
For development workflows, use watch mode to automatically regenerate code when your input files change:
```sh
# Watch for changes in the input file specified in your config
codegen generate --watch
# Watch for changes in a specific file or directory
codegen generate --watch --watchPath ./asyncapi
# Short form
codegen generate -w -p ./schemas/
```
Watch mode is perfect for development environments where you want your generated code to stay in sync with your API specifications as you make changes.
# π Goals
Besides the [milestones](https://github.com/the-codegen-project/cli/milestones), we have certain goals that we want to reach for various reasons;
- [ ] β Reach 50 stars - So we can publish the CLI on Brew and Chocolatey
- [X] π 3 Published resources (blog post, video, etc)
# π Resources
People who have been so kind to write or talk about The Codegen Project;
- [AsyncAPI - Simplifying Channels Into One](https://the-codegen-project.org/blog/asyncapi-client-generator/)
- [AsyncAPI - Protocol-Specific Messaging Functions](https://the-codegen-project.org/blog/asyncapi-channel-generator/)
- [AsyncAPI - Dynamic Channel Routing Made Type-Safe](https://the-codegen-project.org/blog/asyncapi-parameters-generator/)
- [AsyncAPI - Type safety Never Publish to Wrong Channels Again](https://the-codegen-project.org/blog/asyncapi-types-generator/)
- [AsyncAPI - Type-Safe Headers](https://the-codegen-project.org/blog/asyncapi-headers-generator/)
- [AsyncAPI - Stop wasting time on payloads](https://the-codegen-project.org/blog/asyncapi-payload-generator)
- [The Codegen Project - 1 Months of Progress](https://the-codegen-project.org/blog/update-2)
- [The Codegen Project - AsyncAPI Extensions](https://the-codegen-project.org/blog/asyncapi-customizing-outputs)
- [The Codegen Project - 5 Months of Progress](https://the-codegen-project.org/blog/update-1)
# Telemetry
The Codegen Project CLI collects **anonymous** usage data to help us understand how the tool is being used and make data-driven improvements. We take your privacy seriously:
- β
**What we collect**: Command usage, generator types, input source types (not actual paths), error categories
- β **What we DON'T collect**: File paths, file contents, personal information, project names
**To disable telemetry**:
```bash
codegen telemetry disable
```
Or set an environment variable:
```bash
export CODEGEN_TELEMETRY_DISABLED=1
# or
export DO_NOT_TRACK=1
```
[Learn more about telemetry β](https://the-codegen-project.org/docs/telemetry)
# Contribution Guidelines
We have made quite a [comprehensive contribution guide](https://the-codegen-project.org/docs/contributing) to give you a lending hand in how the project is structured and how to contribute to it.
## Contributors
Thanks go out to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

Jonas Lagoni
π π» π π€ π§ π¬ β οΈ π

Lagoni
π π§ π π
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!

