3.8.0 • Published 9 months ago

@asyncapi/modelina v3.8.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
9 months ago

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
const asyncapi = ...
const jsonschema = ...
const openapi = ... 
const metamodel = ... 
...
const models = await generator.generate(
  asyncapi | jsonschema | openapi | metamodel
);
const generator = new TypeScriptGenerator();
const generator = new CsharpGenerator();
const generator = new JavaGenerator();
const generator = new RustGenerator();
...
const models = await generator.generate(input);
  • 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 = model.result;
  const dependencies = model.dependencies;
  const modeltype = model.type;
  const modelName = model.modelName;
  ...
}
const generator = new TypeScriptGenerator({
  constraints: {
    modelName: ({modelName}) => {
      // Implement your own constraining logic
      return modelName;
    }
  }
});
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);
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.

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):

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

3.8.0

9 months ago

4.0.0-next.63

9 months ago

4.0.0-next.62

9 months ago

4.0.0-next.60

10 months ago

4.0.0-next.61

10 months ago

4.0.0-next.51

1 year ago

4.0.0-next.52

1 year ago

4.0.0-next.50

1 year ago

4.0.0-next.55

12 months ago

4.0.0-next.56

11 months ago

4.0.0-next.53

1 year ago

4.0.0-next.54

1 year ago

4.0.0-next.59

11 months ago

4.0.0-next.57

11 months ago

4.0.0-next.58

11 months ago

4.0.0-next.40

1 year ago

4.0.0-next.41

1 year ago

4.0.0-next.44

1 year ago

4.0.0-next.45

1 year ago

4.0.0-next.42

1 year ago

4.0.0-next.43

1 year ago

4.0.0-next.48

1 year ago

4.0.0-next.49

1 year ago

4.0.0-next.46

1 year ago

4.0.0-next.47

1 year ago

3.7.0

12 months ago

3.6.0

1 year ago

3.5.3

1 year ago

3.5.2

1 year ago

3.5.1

1 year ago

3.5.0

1 year ago

4.0.0-next.37

1 year ago

4.0.0-next.38

1 year ago

4.0.0-next.36

1 year ago

4.0.0-next.39

1 year ago

4.0.0-next.30

1 year ago

4.0.0-next.33

1 year ago

4.0.0-next.34

1 year ago

4.0.0-next.31

1 year ago

4.0.0-next.32

1 year ago

4.0.0-next.35

1 year ago

4.0.0-next.29

1 year ago

3.4.9

1 year ago

4.0.0-next.28

1 year ago

3.4.8

1 year ago

3.4.7

1 year ago

4.0.0-next.27

1 year ago

4.0.0-next.26

1 year ago

4.0.0-next.24

1 year ago

4.0.0-next.25

1 year ago

3.4.6

1 year ago

4.0.0-next.22

1 year ago

4.0.0-next.23

1 year ago

4.0.0-next.21

1 year ago

4.0.0-next.20

1 year ago

4.0.0-next.19

1 year ago

4.0.0-next.18

1 year ago

3.4.4

1 year ago

3.4.3

1 year ago

3.4.5

1 year ago

4.0.0-next.15

1 year ago

4.0.0-next.16

1 year ago

4.0.0-next.17

1 year ago

4.0.0-next.14

1 year ago

3.4.2

1 year ago

4.0.0-next.13

1 year ago

3.4.1

1 year ago

4.0.0-next.11

1 year ago

4.0.0-next.12

1 year ago

4.0.0-next.10

1 year ago

4.0.0-next.9

1 year ago

4.0.0-next.8

1 year ago

4.0.0-next.7

1 year ago

4.0.0-next.6

1 year ago

4.0.0-next.5

1 year ago

3.4.0

1 year ago

3.3.4

1 year ago

3.3.3

1 year ago

4.0.0-next.4

1 year ago

3.3.1

1 year ago

3.3.2

1 year ago

3.3.0

1 year ago

3.2.3

1 year ago

4.0.0-next.3

1 year ago

4.0.0-next.2

1 year ago

3.2.2

1 year ago

4.0.0-next.1

1 year ago

3.2.1

1 year ago

3.2.0

1 year ago

3.1.0

1 year ago

3.0.0

1 year ago

3.0.0-next.15

1 year ago

3.0.0-next.14

1 year ago

2.1.2

1 year ago

2.1.3

1 year ago

3.0.0-next.13

2 years ago

3.0.0-next.12

2 years ago

3.0.0-next.11

2 years ago

3.0.0-next.10

2 years ago

3.0.0-next.9

2 years ago

2.1.1

2 years ago

3.0.0-next.8

2 years ago

2.1.0

2 years ago

2.0.14

2 years ago

2.0.13

2 years ago

2.0.11

2 years ago

2.0.12

2 years ago

2.0.10

2 years ago

2.0.9

2 years ago

2.0.8

2 years ago

2.0.7

2 years ago

3.0.0-next.7

2 years ago

2.0.6

2 years ago

3.0.0-next.2

2 years ago

3.0.0-next.1

2 years ago

3.0.0-next.4

2 years ago

3.0.0-next.3

2 years ago

3.0.0-next.6

2 years ago

3.0.0-next.5

2 years ago

2.0.3

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.2

2 years ago

2.0.0-next.20

2 years ago

2.0.0-next.21

2 years ago

2.0.0-next.22

2 years ago

2.0.0-next.23

2 years ago

2.0.0-next.24

2 years ago

2.0.0-next.25

2 years ago

2.0.0-next.15

2 years ago

2.0.0-next.16

2 years ago

2.0.0-next.17

2 years ago

2.0.0-next.18

2 years ago

2.0.0-next.19

2 years ago

1.8.10

2 years ago

1.8.11

2 years ago

1.8.12

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.9.1

2 years ago

1.9.0

2 years ago

1.8.9

2 years ago

1.8.8

2 years ago

1.8.7

2 years ago

1.8.2

2 years ago

1.8.1

2 years ago

1.8.0

2 years ago

1.7.1

2 years ago

1.8.6

2 years ago

1.8.5

2 years ago

1.8.4

2 years ago

1.8.3

2 years ago

1.6.1

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

2.0.0-next.8

2 years ago

2.0.0-next.9

2 years ago

2.0.0-next.7

2 years ago

2.0.0-next.10

2 years ago

2.0.0-next.11

2 years ago

2.0.0-next.12

2 years ago

2.0.0-next.13

2 years ago

1.4.0

2 years ago

2.0.0-next.14

2 years ago

1.7.0

2 years ago

1.3.3

2 years ago

2.0.0-next.6

2 years ago

1.2.0

2 years ago

1.2.1

2 years ago

2.0.0-next.4

2 years ago

2.0.0-next.5

2 years ago

2.0.0-next.2

2 years ago

2.0.0-next.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.0.0-next.43

2 years ago

1.0.0-next.42

2 years ago

1.0.0-next.41

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

2.0.0-next.1

2 years ago

0.59.9

3 years ago

1.0.0-next.39

3 years ago

1.0.0-next.38

3 years ago

1.0.0-next.33

3 years ago

1.0.0-next.32

3 years ago

1.0.0-next.31

3 years ago

1.0.0-next.30

3 years ago

1.0.0-next.37

3 years ago

1.0.0-next.36

3 years ago

1.0.0-next.35

3 years ago

1.0.0-next.34

3 years ago

1.0.0-next.40

3 years ago

1.0.0-next.29

3 years ago

1.0.0-next.28

3 years ago

1.0.0-next.27

3 years ago

1.0.0-next.22

3 years ago

1.0.0-next.21

3 years ago

1.0.0-next.20

3 years ago

1.0.0-next.26

3 years ago

1.0.0-next.25

3 years ago

1.0.0-next.24

3 years ago

1.0.0-next.23

3 years ago

0.59.8

3 years ago

1.0.0-next.19

3 years ago

1.0.0-next.18

3 years ago

1.0.0-next.17

3 years ago

1.0.0-next.16

3 years ago

1.0.0-next.11

3 years ago

1.0.0-next.10

3 years ago

1.0.0-next.15

3 years ago

1.0.0-next.14

3 years ago

1.0.0-next.13

3 years ago

1.0.0-next.12

3 years ago

1.0.0-next.9

3 years ago

0.59.6

3 years ago

0.59.7

3 years ago

1.0.0-next.4

3 years ago

1.0.0-next.5

3 years ago

1.0.0-next.6

3 years ago

1.0.0-next.7

3 years ago

1.0.0-next.8

3 years ago

0.59.2

3 years ago

0.59.3

3 years ago

0.59.1

3 years ago

0.59.4

3 years ago

0.59.5

3 years ago

0.40.0-next.1

3 years ago

1.0.0-next.1

3 years ago

1.0.0-next.2

3 years ago

1.0.0-next.3

3 years ago

0.39.9-next.1

3 years ago

0.59.0

3 years ago

0.56.5

3 years ago

0.56.6

3 years ago

0.56.4

3 years ago

0.57.0

3 years ago

0.58.0

3 years ago

0.55.2

3 years ago

0.55.0

3 years ago

0.55.1

3 years ago

0.51.0

3 years ago

0.56.3

3 years ago

0.56.1

3 years ago

0.56.2

3 years ago

0.56.0

3 years ago

0.52.0

3 years ago

0.53.0

3 years ago

0.54.0

3 years ago

0.50.0

3 years ago

0.39.10

4 years ago

0.39.11

4 years ago

0.43.0

4 years ago

0.41.0

4 years ago

0.48.0

3 years ago

0.46.0

3 years ago

0.46.1

3 years ago

0.44.0

4 years ago

0.42.2

4 years ago

0.42.0

4 years ago

0.40.2

4 years ago

0.42.1

4 years ago

0.40.0

4 years ago

0.40.1

4 years ago

0.39.9

4 years ago

0.39.8

4 years ago

0.49.0

3 years ago

0.47.0

3 years ago

0.45.0

3 years ago

0.39.7

4 years ago

0.39.6

4 years ago

0.39.5

4 years ago

0.39.1

4 years ago

0.39.4

4 years ago

0.39.3

4 years ago

0.39.2

4 years ago

0.38.0

4 years ago

0.36.0

4 years ago

0.34.0

4 years ago

0.32.1

4 years ago

0.32.0

4 years ago

0.39.0

4 years ago

0.37.0

4 years ago

0.35.0

4 years ago

0.33.0

4 years ago

0.31.3

4 years ago

0.31.2

4 years ago

0.31.1

4 years ago

0.31.0

4 years ago

0.30.1

4 years ago

0.30.0

4 years ago

0.29.4

4 years ago

0.29.3

4 years ago

0.29.2

4 years ago

0.29.0

4 years ago

0.28.5

4 years ago

0.29.1

4 years ago

0.28.4

4 years ago

0.28.3

4 years ago

0.28.1

4 years ago

0.28.2

4 years ago

0.27.2

4 years ago

0.28.0

4 years ago

0.27.1

4 years ago

0.27.5

4 years ago

0.27.4

4 years ago

0.27.3

4 years ago

0.27.0

4 years ago

0.26.0

4 years ago

0.25.0

4 years ago

0.24.0

4 years ago

0.23.3

4 years ago

0.23.2

4 years ago

0.23.1

4 years ago

0.23.0

4 years ago

0.22.0

4 years ago

0.21.2

4 years ago

0.21.0

4 years ago

0.20.1

4 years ago

0.21.1

4 years ago

0.20.0

4 years ago

0.19.0

4 years ago

0.18.0

4 years ago

0.16.0

4 years ago

0.17.0

4 years ago

0.15.0

4 years ago

0.14.0

4 years ago

0.14.1

4 years ago

0.13.0

4 years ago

0.12.0

4 years ago

0.10.0

4 years ago

0.11.0

4 years ago

0.10.1

4 years ago

0.9.0

4 years ago

0.8.2

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago