Async API Integration #1952
Replies: 2 comments 5 replies
-
AsyncApi seems to be an evolution of OpenSpec. It could be interesting to support it but I don’t know what is the cost and the effort to support it. actually, Ts.ED generate directly a oas and jsonschema. If the asyncApi is an extension of oas, it could really easy to integrate it. |
Beta Was this translation helpful? Give feedback.
-
Hello @JoeHillyard After a long moment to learn and understand correctly the Async API spec, I'm happy to said you, I'm working on a future implementation. You can see the draft PR: The The base is here, it should support multiple channels (aka multiple socket.io rooms). The next step is to work on the new Unlike the old package which generated its own metadata, the new package will take over the entire architecture of the metadata collected via The goal is to be able to declare both a Rest controller and a Websocket controller as follows: class PetCategory {
@Required()
@Groups("!partial", "!create", "!update")
id: string;
@Required()
@Example("doggie")
name: string;
}
enum PetStatus {
AVAILABLE = "available",
PENDING = "pending",
SOLD = "sold"
}
class Pet {
@Required()
@Groups("!partial", "!create", "!update")
id: string;
@Required()
@Example("doggie")
name: string;
@Property()
category: PetCategory;
@CollectionOf(String)
tags: string[];
@Enum(PetStatus)
status: PetStatus;
}
@Controller("/")
@Name("PetStore")
class PetController {
@Use("/")
middleware(@PathParams("id") id: string) {}
@Get("/:id")
@Publish("pet.get")
@Subscribe("pet.get")
@Returns(200, Pet).Description("Returns a pet")
@Returns(404)
get(@PathParams("id") id: string) {
return null;
}
@Get("/")
@Publish("pet.getAll")
@Subscribe("pet.getAll")
@Returns(200, Array).Of(Pet).Description("Returns all pets")
getAll() {
return [];
}
@Patch("/:id")
@Publish("pet.patch")
@Subscribe("pet.updated")
@Returns(200, Pet).Description("Returns a pet")
@Returns(404)
@Description("Patch a pet")
patch(@PathParams("id") id: string, @BodyParams() @Partial() partial: Pet) {
return null;
}
@Post("/:id")
@Publish("pet.update")
@Subscribe("pet.created")
@Returns(200, Pet).Description("Returns a pet")
@Returns(404)
@Description("Update a pet")
post(@BodyParams() @Groups("update") pet: Pet) {
return null;
}
@Put("/")
@Publish("pet.create")
@Subscribe("pet.updated")
@Returns(201, Pet)
@Returns(404)
@Description("Create a pet")
put(@BodyParams() @Groups("create") pet: Pet) {
return null;
}
@Delete("/:id")
@Publish("pet.delete")
@Subscribe("pet.deleted")
@Returns(204)
@Returns(404)
@Description("Delete a pet")
delete(@PathParams("id") id: string) {
return null;
}
} it's a huge challenge but I'm sure that this way of doing things will be a real success with the devs when they want to exploit the code from a Rest controller to the websocket. But that doesn't mean that we can't make a dedicated WS controller to have more flexibility. I also plan to support the async hook ( In other words, an injectable Service developed for a Web server, for the CLI or for SocketIO should be able to function in the same way as long as the code does not call on instructions specific to each environment. I hope this news will enjoy you! |
Beta Was this translation helpful? Give feedback.
-
Recently I have noticed a lot of progression with the Async API Specification and the community behind it - while OAS is a well matured staple, there is a lot of momentum towards event-driven architecture & message based solutions including WebSockets, Kafka and other message brokers.
My motivation behind this would be to have a unified API across multiple protocols that can be fronted with an aggregated view (Just an example - that repo is a bit dated)
I'm interested to hear your thoughts on the matter and whether its a viable implementation etc.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions