Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support to hide tags, endpoints and/or operations from the UI #913

Open
peterhoogendijk opened this issue Nov 6, 2024 · 1 comment
Open

Comments

@peterhoogendijk
Copy link

peterhoogendijk commented Nov 6, 2024

I'm looking for a way to hide a complete tag, an endpoint, or an endpoint method from the generated api-doc (so also from swagger-ui). The implemented endpoints paths and methods should still be available in the api itself. Looking in the docs, the @hidden annotation seems to offer this functionality, but decorators are not allowed in the scripts I'm implementing.

If there already is an option to do this in express-openapi, please document this and optionally provide an example in the test suite. If this is not yet supported by express-openapi, please consider implementing this option.

@jsau-
Copy link
Contributor

jsau- commented Nov 6, 2024

So from memory the way I've achieved this before is adding a custom property, e.g. x-hidden, to a specific endpoint, and then using the securityFilter function to filter out any endpoints on apiDoc which have that property set.

Very very basic pseudocode below (apologies, don't remember the specific structure of apiDoc off the top of my head). Can give a more concrete example later if you're still wanting some help! 👍

e.g.

Endpoint:

POST.apiDoc = {
   /* ... */
   description: ‘…’,
   operationId: ‘…’,
   ‘x-hidden’: true,
};

Initializing the OpenAPI service:

initialize({
  /* ... */
  promiseMode: true,
  securityFilter: async (req, res) => {
    req.apiDoc = somehowMutateThisToHideWhatYouWant();
    res.status(200).json(req.apiDoc);
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants