asyncapi / 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!
https://www.asyncapi.com/tools/cli
Apache License 2.0
188 stars 164 forks source link

Generate jsonbinpack support for TypeScript models #461

Closed jonaslagoni closed 1 year ago

jonaslagoni commented 1 year ago

Reason/Context

In Modelina for TypeScript, you can make it generate the models generate basic support for serializing to and from binary with https://github.com/sourcemeta/jsonbinpack, this should be possible through the CLI.

To do this I suggest we add a flag called tsJsonBinPack as a boolean. If true the generator should include the following options:

  presets: [
    {
      preset: TS_COMMON_PRESET,
      options: {
        marshalling: true
      }
    },
    TS_JSONBINPACK_PRESET
  ]

Which should be added here: https://github.com/asyncapi/cli/blob/438de0741e9ef29672b6e3af483b90e796903a7d/src/commands/generate/models.ts#L118 as the code example shows: https://github.com/asyncapi/modelina/blob/master/examples/typescript-generate-jsonbinpack/index.ts

These will be the generated results: https://github.com/asyncapi/modelina/blob/master/examples/typescript-generate-jsonbinpack/__snapshots__/index.spec.ts.snap

Remember to also add a test here: https://github.com/asyncapi/cli/blob/438de0741e9ef29672b6e3af483b90e796903a7d/test/commands/generate/models.test.ts#L39

Related documentation: https://github.com/asyncapi/modelina/blob/master/docs/languages/TypeScript.md#generate-models-with-jsonbinpack-support

Feel free to reach out if you have any questions or get stuck!

prayutsu commented 1 year ago

working on this issue.

asyncapi-bot commented 1 year ago

:tada: This issue has been resolved in version 0.35.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: