Closed dekelev closed 4 years ago
Well there is also the possibility to ignore by tags.
The tag for a service can be set via docs property.
Another possibility would be to register the services you don't want to have in swagger before the use of feathers-swagger initialization.
I've tried that, but it also requires me to check if service.remote
is true in the mixin method in order to set the tag on the service.docs
. it also group tags in the UI, so all the services with tag internal
will be listed in a single list.
So I tested it not with feathers-distributed directly, but with a service that has a property remote set to true.
Service with remote set to true.
const seqtestService = new Seqtest(options, app);
seqtestService.remote = true;
app.use('/seqtest', seqtestService);
Adding a mixin that sets the internal tag for services with the remote property.
app.configure((app) => {
app.mixins.push((service) => {
if (service.remote === true) {
service.docs = {
tag: 'internal',
};
}
});
});
app.configure(swagger({
specs: {
info: {
title: 'Testing stuff with feathers',
version: '0.0.1',
},
},
openApiVersion: 3,
uiIndex: true,
ignore: {
tags: ['internal'],
},
//...
}));
And this worked out for me.
And tags that are not used by any added service, like the internal tag in that case, should not be added to the spec at all.
But for a future version, an additional function based option to ignore services can be added for sure.
Cool, setting internal
tag this way works great, though "additional function based option to ignore services" is definitely the prefered solution.
Thanks a lot for your help!
When working with remote services using the feathers-distributed lib, the
addService
method in feathers-swagger gets called for each service, local or remote.I want to exclude all the remote services from swagger. in order to do so, I've tried using the include/ignore options, but I don't have any services path list.
I've tried to add a similar
addService
method to the mixin, right before feathers-swaggeraddService
method, and collect paths to include/ignore, but the include/ignore array is cloned in feathers-swagger when the library is initialized.I've ended up replacing feathers-swagger
addService
mixin method with a proxy method that calls feathers-swaggeraddService
method only for local services, whenservice.remote
is false or undefined.Is there any better way to do this?