Closed paulsherwinang closed 5 years ago
Hi @paulsherwinang,
it's a great news! Currently there is no swagger/openapi module for Moleculer API Gateway. I plan to create one in the future, but I have no enough time at present.
By the way, I plan to create a swagger mixin for API Gateway which collects the docs
properties from action definition and generate the swagger specs from them like fastify-swagger module.
module.exports = {
name: "posts",
actions: {
list: {
docs: {
description: "Returns all posts that the logged in user has access to",
responses: {
"200": {
description: "List of posts",
content: {
"application/json": {
schema: {...}
}
}
}
}
}
handler(ctx) {...}
}
}
}
This would be a great feature. For an MVP simply publishing the OpenAPI json file would be a massive help. I would suggest having a look at how PostgREST (http://postgrest.org/en/v5.1/) implements this. It seems like the easiest way to get a quick win on this issue.
OpenAPI 3 mixin for moleculer-web is coming in a separated repo
@icebob where can I follow the the OpenAPI mixin for molecular-web please?
It's in progress. Here is a WIP
I tried on one of the projects. Very uncomfortable. Description openapi is more business application logic. I see a less flexible tool for autogenerating documentation. It should take the most information from the written code and be accompanied only by comments.
I see, I'm thinking on to generate schema from validation schema but somehow need to define responses & components too. I'm open to suggestions.
Another approach would be generating moleculerjs services based on Swagger
Any news on this?
I think this should be re-opened. This, or some way to easily describe the communication contracts of services and their actions. It might be a better idea to use asyncapi at the molecular framework level, and have a middle ware in this repo to translate that into open api.
microservice frameworks like this are incredible when the projects and teams are small. But when you have hundreds of services and a few dozen people building, understanding the interface is incredibly difficult and hard to reason about. Worse, it usually requires some intimate knowledge of the inner workings of the frameworks to be able to do something similar your self.
@icebob see above
I understand you, but this is not a mandatory functionality, it's an extra thing and can be implemented externally, no need any changes in the Moleculer Core library. The Moleculer service schemas and action definitions are well structured and easily can be processed and are available via broker's registry.
I mean anybody can write a service schema to OpenAPI converter mixin/middleware and publish it on NPM. It can be a good starting point for everybody: https://github.com/icebob/kantab/blob/master/backend/libs/openapi-generator.js
Btw, in the near feature I will not have time to work on extra modules, I'm focusing now on the new major core releases.
Hi guys,
In my company, we are strongly considering using Moleculer as its a great framework for microservices. We used to come from Loopback and one of the most useful things they have is the component explorer (https://www.npmjs.com/package/loopback-component-explorer). This uses swagger built in for Loopback
Would there be any alternatives for Moleculer web and its services apis?
Any tips and leads would be greatly appreciated!