Open deepdil-sp opened 9 months ago
You can override in openapi.service.js fetchServicesWithActions method and filter services/actions:
const Openapi = require("moleculer-auto-openapi");
module.exports = {
name: 'openapi',
mixins: [Openapi],
methods: {
async fetchServicesWithActions() {
const services = await this.broker.call("$node.services", {
withActions: true,
onlyLocal: this.settings.onlyLocal,
});
// TODO
// your filters and etc...
return services;
},
}
}
You can create 2 web service - private and public. And set collectOnlyFromWebServices: [apiPublic
] in openapi scheme. Example:
apiPublic.service.js
const ApiGateway = require("moleculer-web");
module.exports = {
name: `apiPublic`,
mixins: [ApiGateway],
settings: {
port: 2000,
routes: [
{
path: '/api/public',
aliases: {
'POST /login': 'auth.login',
},
},
// moleculer-auto-openapi routes
{
path: '/api/openapi',
aliases: {
'GET /openapi.json': 'openapi.generateDocs', // swagger scheme
'GET /ui': 'openapi.ui', // ui
'GET /assets/:file': 'openapi.assets', // js/css files
},
},
],
},
};
apiPrivate.service.js
const ApiGateway = require("moleculer-web");
module.exports = {
name: `apiPrivate`,
mixins: [ApiGateway],
settings: {
port: 2001,
routes: [
{
path: '/api/private',
aliases: {
'POST /login': 'admin.login',
},
},
],
},
};
openapi.service.js
const Openapi = require("moleculer-auto-openapi");
module.exports = {
name: 'openapi',
mixins: [Openapi],
settings: {
// show route only from apiPublic web service
collectOnlyFromWebServices: [`apiPublic`],
},
}
how to exclude some folders, some files from openapi. i dont want to include db folders service and openapi.service files @grinat @intech @jodysimpson @krifamed @randomnerd