Hiding API Endpoints in Swagger (ASP.NET Core Pro Tip)

Hiding API Endpoints in Swagger
- When building APIs, not every endpoint is meant for public eyes
- Sometimes we have internal routes like admin or test APIs that should stay out of Swagger documentation.
- By default, Swagger lists all endpoints… but here’s a simple way to hide the ones you don’t want exposed. [ApiExplorerSettings(IgnoreApi = true)]
- Just add the code above to your API endpoint, and it will no longer appear in Swagger UI.
Important note:
- This doesn’t secure the endpoint — it only hides it from the docs. Always combine it with proper.
- Authentication
- Authorization
Why I Use This:
- Keeps Swagger docs clean and client-friendly
- Reduces confusion for external developers
- Shows only what’s truly relevant
- Makes API documentation easier to maintain