An open API service indexing awesome lists of open source software.

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!

Awesome Lists containing this project

README

          

![The Codegen Project banner](https://github.com/user-attachments/assets/5a839f64-8ed3-49fe-84e2-899cbd7d5027)

⚑️The Codegen Project⚑️

[![License](https://img.shields.io/github/license/the-codegen-project/cli)](https://github.com/the-codegen-project/cli/blob/master/LICENSE)
[![Npm latest version](https://img.shields.io/npm/v/@the-codegen-project/cli)](https://www.npmjs.com/package/@the-codegen-project/cli)
![NPM Downloads](https://img.shields.io/npm/dw/%40the-codegen-project%2Fcli)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/the-codegen-project/cli/.github%2Fworkflows%2Fruntime-testing.yml?label=runtime%20testing)
![GitHub last commit](https://img.shields.io/github/last-commit/the-codegen-project/cli)
![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.x64.pkg?label=MacOS)
![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.arm64.pkg?label=MacOS)
![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.x86.exe?label=Win)
![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.x64.exe?label=Win)
![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.tar.gz?label=Linux)
![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.deb?label=Linux)
![homebrew downloads](https://img.shields.io/homebrew/installs/dm/codegen?label=Brew%20(SOON))
![Chocolatey Downloads](https://img.shields.io/chocolatey/dt/codegen?label=Chocolatey%20(SOON))
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#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 ./assets/images/sponsors/CodeForge.png



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 and run codegen.x64.exe




Download and run codegen.x86.exe



#### 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
```

[![Initialize The Codegen Project](./assets/videos/initialize.gif)](./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
Jonas Lagoni

πŸ› πŸ’» πŸ“– πŸ€” 🚧 πŸ’¬ ⚠️ πŸ‘€
Lagoni
Lagoni

πŸ› 🚧 πŸ“† πŸ‘€

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