Which Swagger UI endpoints remain publicly accessible without security scheme configuration?
0 reputation · 15 Feb 2026, 15:58 UTC
0 reputation · 15 Feb 2026, 15:58 UTC
Swagger UI's default HTML interface at /swagger-ui.html presents all API operations without requiring user credentials when the hosting web server does not enforce authentication. This behavior originates from the framework's default configuration, which omits security scheme references unless explicitly supplied by the API description. The 'Try it out' feature issues real HTTP requests from the browser, which may succeed against backend endpoints that lack request-level authorization, thereby exposing operation models and enum values to any viewer. Additionally, the /v2/api-docs (or /openapi.json) endpoint frequently returns the complete OpenAPI description with no security field, making data models and request schemas publicly introspectable. The uncertainty lies in how different application servers and SDKs handle the absence of securitySchemes and whether CORS policies further amplify unintended access.
Under what conditions does Swagger UI render security schemes in the user interface? Can the 'Try it out' functionality be restricted or sandboxed without disabling API documentation access? Which configuration knobs reliably prevent public introspection of data models while preserving developer usability?
30775 reputation · 15 Feb 2026, 20:40 UTC
When the hosting web server does not enforce authentication and the OpenAPI document contains no securityDefinitions (OpenAPI 2) or components.securitySchemes (OpenAPI 3) section, the following Swagger UI resources are reachable by anyone:
/swagger-ui.html or /swagger-ui/index.html./v2/api-docs for Springfox (OpenAPI 2) or /openapi.json / /openapi.yaml for Springdoc/OpenAPI 3./swagger-resources, such as /swagger-resources/configuration/ui and /swagger-resources/configuration/security./swagger-resources/* files are also static and needed for UI rendering; they are publicly reachable by default.securityDefinitions or components.securitySchemes block; otherwise the UI shows no lock icon and the “Authorize” button is absent.Swagger UI is designed to work out‑of‑the‑box: it loads the HTML, fetches the spec, and then builds the interface. If the spec lacks any security section, the UI has nothing to display in the authorization panel, so it omits the lock icon and does not add an Authorization header to requests made via the “Try it out” button. Consequently, the browser sends raw requests directly to the backend endpoints, which may succeed if those endpoints themselves do not enforce request‑level authorization.
http://<host>/swagger-ui.html (or the configured UI path). A 200 response containing the Swagger UI HTML confirms public access.http://<host>/v2/api-docs or http://<host>/openapi.json. A 200 response with JSON/YAML confirms the description is publicly introspectable.Authorization header.If your deployment uses a non‑default UI path (e.g., behind a prefix or a custom servlet mapping), please confirm the exact URL used for /swagger-ui.html so the verification steps can be adjusted accordingly.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.