typespec icon indicating copy to clipboard operation
typespec copied to clipboard

POC TypeSpec to AsyncAPI

Open mikekistler opened this issue 2 years ago • 11 comments

AsyncAPI is a sister specification to OpenAPI for describing asynchronous (e.g. message queuing) APIs. AsyncAPI is gaining some traction in the industry and by producing an emitter for this we could demonstrate the flexibility and power of TypeSpec in another API domain.

mikekistler avatar Sep 21 '23 19:09 mikekistler

Backlog

allenjzhang avatar Sep 25 '23 18:09 allenjzhang

This feature would make TypeSpec a "do-all" tool for those writing OpenAPI and AsyncAPI specs. It's not uncommon to have both within a single system.

Adding my support for this feature! 👍

SnakeDoc avatar Apr 02 '24 18:04 SnakeDoc

I agree with the above. At Sportradar we use both OpenAPI and AsyncAPI with JSON Schema and would consider TypeSpec if AsyncAPI was supported.

kennethaasan avatar May 31 '24 13:05 kennethaasan

I'm considering using typespec, but at the moment I'm mostly working on event driven architectures. Support for the generation of specifications for asynchronous APIs and event schemas, such as AsyncAPI and cloudevents, would also be fantastic.

sandrolain avatar Jun 01 '24 16:06 sandrolain

Folks chiming in for AsyncAPI support, please feel free to link your AsyncAPI specs if they are public, it would be great to take a look!

bterlson avatar Jun 01 '24 16:06 bterlson

@SwissPost we designed hundreds of APIs (both REST and Streaming) using https://github.com/swisspost/apikana. Found TypeSpec very interesting but still missing the support for AsyncAPI

chiodonia avatar Jun 07 '24 10:06 chiodonia

Folks chiming in for AsyncAPI support, please feel free to link your AsyncAPI specs if they are public, it would be great to take a look!

I don't have a public spec to offer at the moment - however the AsyncAPI team does maintain example specs in their repos for testing, such as this - just note the v3 directory contains AsyncAPI 3.x spec examples.

You may also be interested in these two discussions: #141 and #151, which showcase some 3.x spec examples and expected outputs from the validation/bundling process.

SnakeDoc avatar Jun 07 '24 19:06 SnakeDoc

any updates on this @bterlson ?

creatorrr avatar Jul 09 '24 17:07 creatorrr

Nothing new to share, unfortunately. Keep chiming in with support, though!

bterlson avatar Jul 09 '24 18:07 bterlson

I'm chiming in with support! ;)

SnakeDoc avatar Jul 09 '24 18:07 SnakeDoc

There are official examples in https://github.com/asyncapi/spec/tree/master/examples, and you can view an example for nearly any version of the AsyncAPI Specification:

$ git tag

1.1.0
1.2.0
2.0.0
...
v2.0.0
v2.1.0
...
v2.4.0
v2.4.0-2022-04-release.1
...
v2.5.0-next-spec.5
v2.6.0
v3.0.0
v3.0.0-next-major-spec.1
...

There is also a separate repository, which provides all the JSON Schema documents for validating AsyncAPI documents. https://github.com/asyncapi/spec-json-schemas

aeworxet avatar Aug 19 '24 00:08 aeworxet

I'm waiting for support, I really need it

Kreash avatar Sep 07 '24 15:09 Kreash

Hi , we are also using both openapi and asyncapi ! asyncapi support in typespec would really make it a valid case to use typespec ! I'm chimming in with support @bterlson

LievenMasschelein-code avatar Sep 26 '24 09:09 LievenMasschelein-code

We would like to support AsyncAPI but representing AsyncAPI with TypeSpec is challenging and will take some time to figure out.

It would help us to know how you would use AsyncAPI in practice. @LievenMasschelein-code @Kreash @chiodonia @SnakeDoc @kennethaasan @sandrolain @aeworxet

mario-guerra avatar Sep 27 '24 17:09 mario-guerra

@mario-guerra

You can join AsyncAPI Slack Workspace and ask your questions in the channel

# 03_specification
4,403 members
All around the spec discussions. It is ok to ask for support here.

aeworxet avatar Sep 27 '24 18:09 aeworxet

@mario-guerra Pretty much exactly the same way we use OpenAPI - our AsyncAPI spec is our "source of truth" for describing how our services should interact within our EDA.

I would guess one of the reasons you are not receiving many public AsyncAPI specs to look at is EDA/Message Broker stuff is often used internally.

That said, @aeworxet is a significant contributor to the AsyncAPI project and is a tremendous asset to have available for questioning! 🚀

SnakeDoc avatar Sep 27 '24 18:09 SnakeDoc

Hi for us also , just alike @SnakeDoc mentions, we use in the same way we use Openapi. For us Asyncapi is the only source of truth for our internal domain events between our microservices, we are building some automation on top of Asyncapi to have data quality checks for events and messages ingested in our data lakehouse platform. Asyncapi is also used to add events schema's in our confluent cloud ( kafka) schema registry and then to enforce them.

LievenMasschelein-code avatar Sep 28 '24 06:09 LievenMasschelein-code

@aeworxet is a significant contributor to the AsyncAPI project and is a tremendous asset

😊

@fmvilas is the Founder of AsyncAPI, and @derberg is the Executive Director of AsyncAPI, so they are much more tremendous assets for asking questions. 🙂

aeworxet avatar Sep 28 '24 12:09 aeworxet

Hi, we at SwissPost have been developing https://github.com/swisspost/apikana which is similar to TypeSpec. Apikana has been used to design hundreds of REST and Stream APIs (Kafka and MQTT).

We are now willing to adopt asyncAPI for our stream APIs and are considering generating asyncAPI with Apikana. Since Apikana needs some investments we are also considering TypeSpec and are very interested in asyncAPI PoC.

From a stream API design point of view, we need to define the following asyncAPI elements:

  • Info with additional x- fields
  • Channels (topic name) with additional x- fields
  • Messages and payloads (Json schema)
  • Operations

I guess bindings, and other serialization formats (Protobuf,...) could be added later after the PoC.

AsyncAPI Servers and other elements are probably not relevant during the API design phase. The generated asyncAPI descriptors could be enriched with those elements when topics are deployed.

Andrea

chiodonia avatar Sep 30 '24 07:09 chiodonia

Yes, very interested in asyncapi support too! Especially ver 3.0,which is much clearer and richer than 2.x.

TertiumOrganum1 avatar Nov 04 '24 20:11 TertiumOrganum1

Can anyone at Microsoft give us a hint if this is being worked on? The demand for this feature is here! A little extra transparency about status and ETA would be much appreciated.

SnakeDoc avatar Dec 04 '24 20:12 SnakeDoc

it would be really nice to have AsyncAPI support!

vec715 avatar Apr 06 '25 23:04 vec715

@mario-guerra just writing to let you know that I'm available to help moving this forward. From understanding the spec inside out to getting in touch with implementers so they can tell a better story. Hit me on LinkedIn: https://www.linkedin.com/in/fmvilas.

fmvilas avatar Apr 19 '25 11:04 fmvilas

Bumping. Would like to see this 🙏

bZichett avatar Aug 29 '25 12:08 bZichett

[!NOTE] I am currently developing a TypeSpec AsyncAPI emitter prototype independently with the goal of potentially contributing it to this repository.

@fmvilas Quick question about AsyncAPI versioning capabilities:

Does AsyncAPI support native multi-version document generation like OpenAPI 3.x?

From my research, AsyncAPI has: ✅ info.version field ✅ deprecated: true flags ✅ Schema composition (allOf, oneOf)

But lacks: ❌ Multi-version document generation ❌ Built-in version evolution mechanisms ❌ Official version migration tooling

My plan: Generate separate AsyncAPI files per version (asyncapi.v1.yaml, asyncapi.v2.yaml) using TypeSpec's @added/@removed decorators.

Is this the right approach, or does AsyncAPI have native versioning I missed?

LarsArtmann avatar Aug 29 '25 17:08 LarsArtmann

Hi! Received an email with this link, but can't find this Lars's post here and it looks like this repo is still private. https://github.com/LarsArtmann/typespec-asyncapi

Any clarifications are welcome 😉

TertiumOrganum1 avatar Aug 30 '25 20:08 TertiumOrganum1

Hi,

I will release a Alpha v1 in hopefully the next 24h, but I am building it with the help of Claude Code, so it was a bit fast with the Comment. I made it public for you.

Best regards, Lars Artmann Managing Director at Artmann Holding GmbH and Artmann Technologies GmbH

Tel: +49 173 155 9729

On Sat, Aug 30, 2025 at 10:51 PM TertiumOrganum1 @.***> wrote:

TertiumOrganum1 left a comment (microsoft/typespec#2463) https://github.com/microsoft/typespec/issues/2463#issuecomment-3239534911

Hi! Received an email with this link, but can't find this Lars's post here and it looks like this repo is still private. https://github.com/LarsArtmann/typespec-asyncapi

Any clarifications are welcome 😉

— Reply to this email directly, view it on GitHub https://github.com/microsoft/typespec/issues/2463#issuecomment-3239534911, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFT6YDN7DPD2PKYFYXHEODD3QIFDNAVCNFSM6AAAAAA5CBSPQ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTEMZZGUZTIOJRGE . You are receiving this because you commented.Message ID: @.***>

LarsArtmann avatar Aug 30 '25 22:08 LarsArtmann

That's awesome, thanks!

вс, 31 авг. 2025 г., 01:27 Lars Artmann @.***>:

LarsArtmann left a comment (microsoft/typespec#2463) https://github.com/microsoft/typespec/issues/2463#issuecomment-3239581480 Hi,

I will release a Alpha v1 in hopefully the next 24h, but I am building it with the help of Claude Code, so it was a bit fast with the Comment. I made it public for you.

Best regards, Lars Artmann Managing Director at Artmann Holding GmbH and Artmann Technologies GmbH

Tel: +49 173 155 9729

On Sat, Aug 30, 2025 at 10:51 PM TertiumOrganum1 @.***> wrote:

TertiumOrganum1 left a comment (microsoft/typespec#2463) < https://github.com/microsoft/typespec/issues/2463#issuecomment-3239534911>

Hi! Received an email with this link, but can't find this Lars's post here and it looks like this repo is still private. https://github.com/LarsArtmann/typespec-asyncapi

Any clarifications are welcome 😉

— Reply to this email directly, view it on GitHub < https://github.com/microsoft/typespec/issues/2463#issuecomment-3239534911>,

or unsubscribe < https://github.com/notifications/unsubscribe-auth/AFT6YDN7DPD2PKYFYXHEODD3QIFDNAVCNFSM6AAAAAA5CBSPQ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTEMZZGUZTIOJRGE>

. You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/microsoft/typespec/issues/2463#issuecomment-3239581480, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMHJGKYNHW2ERSYRAAVIXWT3QIQNVAVCNFSM6AAAAAA5CBSPQ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTEMZZGU4DCNBYGA . You are receiving this because you commented.Message ID: @.***>

TertiumOrganum1 avatar Aug 30 '25 22:08 TertiumOrganum1

🎉 TypeSpec AsyncAPI Emitter - Alpha Release Available

I've implemented a working TypeSpec emitter for AsyncAPI 3.0 specifications, now available as @lars-artmann/typespec-asyncapi@alpha.

Current Status:

  • ✅ Core functionality working: @channel, @publish, @subscribe decorators
  • ✅ Complete TypeSpec model → AsyncAPI schema conversion
  • ✅ Complex types supported: union types → enums, nested objects, optional fields
  • ✅ AsyncAPI 3.0 specification compliance
  • ✅ 100+ tests passing with comprehensive validation

Installation & Usage:

npm install @lars-artmann/typespec-asyncapi@alpha

Working example at: https://github.com/LarsArtmann/typespec-asyncapi/blob/master/test-example-advanced.tsp

Alpha Limitations: Advanced decorators like @correlationId, @header not yet implemented, but core event-driven API generation works. Find more infos on: https://www.npmjs.com/package/@lars-artmann/typespec-asyncapi or the dedicated GitHub repo.

💬 Please provide me als much and as harsh feedback on the current implementation as possible!

LarsArtmann avatar Sep 03 '25 03:09 LarsArtmann

💬 Please provide me als much and as harsh feedback on the current implementation as possible!

The signal to noise ratio of claude is clearly way off. This is completely unusable.

CJSmith-0141 avatar Oct 04 '25 15:10 CJSmith-0141