• Stars
    star
    312
  • Rank 134,133 (Top 3 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created almost 4 years ago
  • Updated 13 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A library for generating typed models based on inputs such as AsyncAPI, OpenAPI, and JSON Schema documents with high customization

AsyncAPI Modelina blackbox pipeline status Coverage Status Project Status: Active – The project has reached a stable, usable state and is being actively developed. Maintenance score Npm latest version License last commit Discussions Website Playground All Contributors

Your one-stop tool for generating accurate and well-tested models for representing the message payloads. Use it as a tool in your development workflow, or a library in a larger integrations, entirely in your control.


Installing Modelina

Run this command to install Modelina in your project:

npm install @asyncapi/modelina

AsyncAPI CLI

If you have the AsyncAPI CLI installed (ONLY support AsyncAPI inputs), you can run the following command to use Modelina:

asyncapi generate models <language> ./asyncapi.json

What Does Modelina Do?

Modelina put YOU in control of your data models, here is how...

Modelina lets you generate data models from many types of inputs
const asyncapi = ...
const jsonschema = ...
const openapi = ... 
const metamodel = ... 
...
const models = await generator.generate(
  asyncapi | jsonschema | openapi | metamodel
);
Use the same inputs across a range of different generators
const generator = new TypeScriptGenerator();
const generator = new CsharpGenerator();
const generator = new JavaGenerator();
const generator = new RustGenerator();
...
const models = await generator.generate(input);
Easily let you interact with the generated models.
  • Want to show the generated models on a website? Sure!
  • Want to generate the models into files? Sure!
  • Want to combine all the models into one single file? Sure!

Whatever interaction you need, you can create.

const models = await generator.generate(input);
for (const model in models) { 
  const generatedCode = generatedModel.result;
  const dependencies = generatedModel.dependencies;
  const modeltype = generatedModel.model.type;
  const modelName = generatedModel.modelName;
  ...
}
Easily modify how models are constrained into the output
const generator = new TypeScriptGenerator({
  constraints: {
    modelName: ({modelName}) => {
      // Implement your own constraining logic
      return modelName;
    }
  }
});
Seamlessly layer additional or replacement code on top of each other to customize the models to your use-case
const generator = new TypeScriptGenerator({
  presets: [
    {
      class: {
        additionalContent({ content }) {
          return `${content}
public myCustomFunction(): string {
  return 'A custom function for each class';
}`;
        },
      }
    }
  ]
});
const models = await generator.generate(input);
Seamlessly lets you combine multiple layers of additional or replacement code
const myCustomFunction1 = {
  class: {
    additionalContent({ content }) {
      return `${content}
public myCustomFunction(): string {
return 'A custom function for each class';
}`;
    },
  }
};
const myCustomFunction2 = {...};
const generator = new TypeScriptGenerator({
  presets: [
    myCustomFunction1,
    myCustomFunction2
  ]
});
const models = await generator.generate(input);

Features

The following table provides a short summary of available features for supported output languages. To see the complete feature list for each language, please click the individual links for each language.

Supported inputs
AsyncAPI We support the following AsyncAPI versions: 2.0.0 -> 2.6.0, which generates models for all the defined message payloads. It supports the following schemaFormats AsyncAPI Schema object, JSON Schema draft 7, AVRO 1.9, RAML 1.0 data type, and OpenAPI 3.0 Schema.
JSON Schema We support the following JSON Schema versions: Draft-4, Draft-6 and Draft-7
OpenAPI We support the following OpenAPI versions: Swagger 2.0 and OpenAPI 3.0, which generates models for all the defined request and response payloads.
TypeScript We currently support TypeScript types as file input for model generation
Meta model This is the internal representation of a model for Modelina, it is what inputs gets converted to, and what generators are provided to generate code. Instead of relying on an input processor, you can create your own models from scratch and still take advantage on the generators and the features.

Supported outputs
Java Class and enum generation: generation of equals, hashCode, toString, Jackson annotation, custom indentation type and size, etc
TypeScript Class, interface and enum generation: generation of example code, un/marshal functions, custom indentation type and size, etc
C# Class and enum generation: generation of example code, serializer and deserializer functions, custom indentation type and size, etc
Go Struct and enum generation: custom indentation type and size, etc
JavaScript Class generation: custom indentation type and size, etc
Dart Class and enum generation: json_annotation
Rust Struct/tuple and enum generation: generation of `implement Default`, generate serde macros, custom indentation type and size, etc
Python Class and enum generation: custom indentation type and size, etc
Kotlin Class and enum generation: use of data classes where appropriate, custom indentation type and size, etc
C++ Class and enum generation: custom indentation type and size, etc
PHP Class and enum generation: custom indentation type and size, descriptions, etc

Roadmap

This is the roadmap that is currently in focus by the CODEOWNERS

Requirements

The following are a requirement in order to use Modelina.

Documentation

A feature in Modelina cannot exists without an example and documentation for it. You can find all the documentation here.

Examples

Do you need to know how to use the library in certain scenarios?

We have gathered all the examples in a separate folder and they can be found under the examples folder.

Versioning and maintenance

As of version 1, Modelina has a very strict set of changes we are allowed to do before it requires a major version change. In short, any changes that change the generated outcome are not allowed as it's a breaking change for the consumer of the generated models.

Here is a list of changes we are allowed to do that would not require a breaking change:

  • Adding new features (that do not change existing output), such as generators, presets, input processors, etc.
  • Change existing features, by providing options that default to current behavior. This could be a preset that adapts the output based on options, as long as the API of Modelina and the API of the generated models does not have any breaking changes.
  • Bug fixes where the generated code is otherwise unusable (syntax errors, etc).

Breaking changes are allowed and expected at a frequent rate, of course where it makes sense we will try to bundle multiple changes together.

We of course will do our best to uphold this, but mistakes can happen, and if you notice any breaking changes please let us know!

Because of the number of the limited number of champions, only the most recent major version will be maintained.

Major versions are currently happening at a 3-month cadence (in a similar fashion as the AsyncAPI specification), this will happen in January, April, June, and September.

Development

We try to make it as easy for you as possible to set up your development environment to contribute to Modelina. You can find the development documentation here.

Contributing

Without contributions, Modelina would not exist, it's a community project we build together to create the best possible building blocks, and we do this through champions.

We have made quite a comprehensive contribution guide to give you a lending hand in how different features and changes are introduced.

If no documentation helps you, here is how you can reach out to get help:

Contributors

Thanks go out to these wonderful people (emoji key):

Maciej UrbaΕ„czyk
Maciej UrbaΕ„czyk

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

πŸ› πŸ‘€ πŸ€”
Sergio Moya
Sergio Moya

πŸ› πŸ’» ⚠️ πŸ“– πŸ‘€
Jonas Lagoni
Jonas Lagoni

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

πŸ‘€ πŸ› πŸ’»
Arjun Garg
Arjun Garg

πŸ’»
Fran MΓ©ndez
Fran MΓ©ndez

πŸ‘€
Kanwal Singh
Kanwal Singh

πŸ’»
Alejandra Quetzalli
Alejandra Quetzalli

πŸ‘€ πŸ“–
MD SAIF  HUSAIN
MD SAIF HUSAIN

πŸ’‘ ⚠️ πŸ“– πŸ’»
Sudipto Ghosh
Sudipto Ghosh

πŸ’‘ ⚠️ πŸ“–
panwauu
panwauu

πŸ’» ⚠️ πŸ’‘ πŸ“– πŸ›
Stefan E. Mayer
Stefan E. Mayer

πŸ›
Talmiz Ahmed
Talmiz Ahmed

πŸ“– ⚠️ πŸ’‘
Marco
Marco

πŸ›
quadrrem
quadrrem

πŸ’» ⚠️
Kamil Janeček
Kamil Janeček

⚠️ πŸ› πŸ’»
mahakporwal02
mahakporwal02

πŸ’‘ ⚠️ πŸ“– πŸ’»
Debajyoti Halder
Debajyoti Halder

πŸ’» ⚠️ πŸ“– πŸ’‘ 🚧
Ritik Rawal
Ritik Rawal

πŸ“– πŸ’» ⚠️ πŸ’‘
Ishan
Ishan

πŸ’» ⚠️
Samriddhi
Samriddhi

πŸ’» ⚠️ πŸ“– πŸ’‘ 🚧
GΓ‘bor Magyar
GΓ‘bor Magyar

πŸ’» ⚠️ πŸ“– πŸ’‘
ibernabeudev
ibernabeudev

πŸ’» ⚠️ πŸ’‘ πŸ“–
Arkadiusz SΕ‚owikowski
Arkadiusz SΕ‚owikowski

πŸ’» ⚠️ πŸ’‘ πŸ“–
Willem Gillis
Willem Gillis

πŸ’» ⚠️ πŸ›
rmasarovic
rmasarovic

πŸ’» πŸ“– ⚠️ πŸ’‘
Owais Hasnath Ahmed
Owais Hasnath Ahmed

πŸ’» ⚠️ πŸ“–
PanMan
PanMan

πŸ“–
artur-ciocanu
artur-ciocanu

πŸ’» πŸ›
Cyprian Gracz
Cyprian Gracz

πŸ’» ⚠️ πŸ›
Leigh Johnson
Leigh Johnson

πŸ’» ⚠️ πŸ’‘ πŸ“– 🚧 πŸ‘€
Nitin Tejuja
Nitin Tejuja

⚠️ πŸ’‘
Kenneth Aasan
Kenneth Aasan

πŸ’» ⚠️ 🚧 πŸ“–
Amit Kumar Sharma
Amit Kumar Sharma

⚠️ πŸ“– πŸ’‘
Andrey Zaytsev
Andrey Zaytsev

πŸ’» πŸ’‘ πŸ“– ⚠️
Tenshi Codes
Tenshi Codes

πŸš‡
Yushi OMOTE
Yushi OMOTE

πŸ› πŸ’»
Zbigniew Malcherczyk
Zbigniew Malcherczyk

πŸ› πŸš‡ πŸ’» πŸ’‘ ⚠️ πŸ‘€
200Puls
200Puls

πŸ’» ⚠️
Anay Sarkar
Anay Sarkar

πŸ’‘ πŸ’» ⚠️
Louis Xhaferi
Louis Xhaferi

πŸ’»
Sambhav Gupta
Sambhav Gupta

πŸ“– πŸ‘€ 🎨 πŸ’» πŸ›
Abhay Garg
Abhay Garg

πŸ’» πŸ’‘ ⚠️ πŸ“–
henrikjon
henrikjon

πŸ’» ⚠️ πŸ“– πŸ’‘
Mohammad Yasir
Mohammad Yasir

πŸ’»
Savio Dias
Savio Dias

πŸ’» πŸš‡ πŸ›
Ishaan Shah
Ishaan Shah

πŸ’»
Shreyas0410
Shreyas0410

πŸ’»
beku-epitome
beku-epitome

πŸ’» πŸ‘€ ⚠️
Joshua Michael Daly
Joshua Michael Daly

πŸ›
Daniel KJ
Daniel KJ

πŸ’» ⚠️ πŸ’‘ πŸ‘€
Bhavik Agarwal
Bhavik Agarwal

🎨
Rishi
Rishi

πŸ’» 🎨
Rohith Boppey
Rohith Boppey

πŸ’» 🎨
Ashish Padhy
Ashish Padhy

πŸ’» ⚠️ πŸš‡

This project follows the all-contributors specification. Contributions of any kind are welcome!

More Repositories

1

spec

The AsyncAPI specification allows you to create machine-readable definitions of your asynchronous APIs.
JavaScript
4,215
star
2

generator

Use your AsyncAPI definition to generate literally anything. Markdown documentation, Node.js code, HTML documentation, anything!
JavaScript
758
star
3

website

AsyncAPI specification website
TypeScript
453
star
4

cli

CLI to work with your AsyncAPI files. You can validate them and in the future use a generator and even bootstrap a new file. Contributions are welcomed!
TypeScript
184
star
5

asyncapi-react

React component for rendering documentation from your specification in real-time in the browser. It also provides a WebComponent and bundle for Angular and Vue
TypeScript
174
star
6

studio

Visually design your AsyncAPI files and event-driven architecture.
TypeScript
167
star
7

saunter

Saunter is a code-first AsyncAPI documentation generator for dotnet.
C#
145
star
8

parser-js

AsyncAPI parser for Javascript (browser-compatible too).
TypeScript
116
star
9

community

AsyncAPI community-related stuff.
98
star
10

glee

Glee β€” The AsyncAPI framework that will make you smile again :)
TypeScript
88
star
11

bindings

AsyncAPI bindings specifications
71
star
12

jasyncapi

/jay-sync-api/ is a Java code-first tool for AsyncAPI specification
Kotlin
67
star
13

java-spring-template

Java Spring template for the AsyncAPI Generator
Java
66
star
14

html-template

HTML template for AsyncAPI Generator. Use it to generate a static docs. It is using AsyncAPI React component under the hood.
JavaScript
63
star
15

parser-go

It parses AsyncAPI documents.
Go
55
star
16

spec-json-schemas

AsyncAPI schema versions
JavaScript
54
star
17

github-action-for-cli

GitHub Action with generator, validator, converter and others - all in one for your AsyncAPI documents with AsyncAPI CLI as backbone
Shell
46
star
18

go-watermill-template

Go template for the AsyncAPI Generator using Watermill module
JavaScript
46
star
19

nodejs-template

This template generates a server using your AsyncAPI document. It supports multiple different protocols, like Kafka or MQTT. It is designed in the way that generated code is a library and with it's API you can start the server, send messages or register a middleware for listening incoming messages. Runtime message validation included.
JavaScript
40
star
20

java-spring-cloud-stream-template

Java Spring Cloud Stream template for the AsyncAPI Generator
JavaScript
31
star
21

avro-schema-parser

An AsyncAPI schema parser for Avro 1.x schemas.
TypeScript
31
star
22

bundler

Combine multiple AsyncAPI specification files into one.
TypeScript
30
star
23

.github

Location of all reusable community health files
29
star
24

vs-asyncapi-preview

VSCode AsyncAPI Preview Extension
TypeScript
28
star
25

server-api

Server API providing official AsyncAPI tools
TypeScript
26
star
26

markdown-template

Markdown template for the AsyncAPI Generator
JavaScript
26
star
27

diff

Diff is a library that compares two AsyncAPI Documents and provides information about the differences by pointing out explicitly information like breaking changes.
TypeScript
26
star
28

python-paho-template

Python Paho template for the AsyncAPI generator
JavaScript
25
star
29

nodejs-ws-template

Node.js WebSockets template for the AsyncAPI Generator. It showcases how from a single AsyncAPI document you can generate a server and a client at the same time.
JavaScript
23
star
30

conference-website

Website for the AsyncAPI online conference
JavaScript
23
star
31

ts-nats-template

Node.js/Typescript template for NATS
JavaScript
21
star
32

converter-go

Convert AsyncAPI documents from older to newer versions with Golang
Go
20
star
33

generator-react-sdk

Generator React SDK enabling the AsyncAPI generator to support React as the rendering engine for templates.
TypeScript
19
star
34

dotnet-nats-template

.NET template for NATS
JavaScript
18
star
35

converter-js

Convert to or migrate between AsyncAPI versions with the converter
TypeScript
18
star
36

template-for-generator-templates

This is a GitHub repository template for generator templates to make it much easier to start writing your own generator template.
JavaScript
18
star
37

simulator

Asynchronous traffic simulation application using async-api
TypeScript
16
star
38

EDAVisualiser

View your system, events, applications through different perspectives
TypeScript
15
star
39

optimizer

AsyncAPI offers many different ways to reuse certain parts of the document like messages or schemas definitions or references to external files, not to even mention the traits. There is a need for a tool that can be plugged into any workflows and optimize documents that are generated from code, but not only.
TypeScript
14
star
40

tck

(WIP) Test Compatibility Suite for AsyncAPI
Java
13
star
41

chatbot

The project's aim is to develop a chatbot that can help people create spec documents without knowing the specification.To get started with, the bot will consume the spec, JSON schema and serves the user as an expert. So based on a set of questions and answers it will generate an AsyncApi spec document according to the use cases.
JavaScript
12
star
42

openapi-schema-parser

An AsyncAPI schema parser for OpenAPI 3.0.x and Swagger 2.x schemas.
TypeScript
12
star
43

extensions-catalog

Catalog of extensions for AsyncAPI specification
11
star
44

shape-up-process

This repo contains pitches and the current cycle bets. More info about the Shape Up process: https://basecamp.com/shapeup
JavaScript
11
star
45

java-template

Java template for the AsyncAPI Generator
JavaScript
10
star
46

jasyncapi-idea-plugin

/jay-sync-api/-idea-plugin is a IDEA plugin for AsyncAPI specification
Kotlin
10
star
47

dotnet-rabbitmq-template

This template is for generating a .NET C# wrapper for the RabbitMQ client based on your AsyncAPI document.
JavaScript
10
star
48

brand

AsyncAPI brand guidelines and strategy
8
star
49

parser-api

Global API definition for all AsyncAPI Parser implementations.
8
star
50

problem

Library that implements the Problem interface. Reference https://www.rfc-editor.org/rfc/rfc7807
TypeScript
7
star
51

php-template

PHP Template for AsyncAPI generator
PHP
7
star
52

training

All about trainings, workshops, courses, etc.
6
star
53

raml-dt-schema-parser

AsyncAPI schema parser for RAML data types
TypeScript
5
star
54

enterprise-patterns

Enterprise patterns using AsyncAPI
4
star
55

protobuf-schema-parser

Schema parser for Protobuf compatible with AsyncAPI JS Parser
TypeScript
4
star
56

template-for-go-projects

This is a repository template for golang projects
Makefile
2
star
57

generator-filters

Library with reusable generator filters that you can use in your templates
JavaScript
2
star
58

generator-hooks

Library with reusable generator hooks that you can use in your templates
JavaScript
1
star