How to specify api docs url for swagger ui in spring boot open api v3?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
With Spring Boot and springdoc-openapi, Swagger UI does not generate your API description on its own. It loads an OpenAPI document from a URL, so the real configuration question is how to control the JSON endpoint and how to tell the UI which endpoint to fetch.
Separate the docs endpoint from the UI path
There are two related but different settings:
- '
springdoc.api-docs.pathchanges where Spring publishes the OpenAPI JSON' - '
springdoc.swagger-ui.pathchanges where the Swagger UI page itself is served'
For example:
With that configuration, the JSON document moves to /api-docs, while the browser UI is served at /docs.
Tell Swagger UI which docs URL to load
If you want explicit control over the document URL used by the UI, set springdoc.swagger-ui.url:
This is useful when:
- the API docs endpoint is non-default
- a reverse proxy changes the path layout
- the OpenAPI document is served from another location
In simple setups, Springdoc can often infer the correct URL, but adding the property removes ambiguity and makes the configuration easier to reason about later.
Example Spring Boot setup
A minimal application might look like this:
With the earlier properties, you would open /docs in the browser and Swagger UI would request /api-docs for the OpenAPI description.
Multiple OpenAPI documents
If you need Swagger UI to present more than one spec, use the indexed urls configuration instead of a single url:
This creates a selector inside Swagger UI so the user can switch between documents. It is a common pattern when one application exposes both public and administrative APIs.
configUrl versus url
You may also see springdoc.swagger-ui.configUrl. That property points Swagger UI to a configuration document rather than directly to an OpenAPI JSON file.
For the usual case of "tell Swagger UI which API docs URL to load," springdoc.swagger-ui.url is the simpler and more direct property. Reach for configUrl only when you specifically need that extra indirection.
Watch for security and proxy effects
If the UI loads but shows no operations, the docs endpoint may still be blocked by security rules, a reverse proxy, or a custom context path. When that happens, the UI page is working but the JSON request fails underneath. Checking the browser network tab is often the fastest way to confirm whether the configured docs URL returns 200, 401, or 404. That distinction usually tells you whether the problem is path mapping or access control.
Common Pitfalls
- Changing
springdoc.swagger-ui.pathand expecting the OpenAPI JSON endpoint to move too. - Setting a custom docs path but forgetting that reverse proxies, security rules, or context paths may affect the effective URL.
- Using
configUrlwhenurlis the simpler setting for a single spec. - Assuming the UI is broken when the real issue is that the configured docs endpoint returns
404or401.
Summary
- '
springdoc.api-docs.pathcontrols where the OpenAPI JSON is served.' - '
springdoc.swagger-ui.pathcontrols where the UI page is served.' - '
springdoc.swagger-ui.urltells the UI which API docs URL to load.' - Use
urlsinstead ofurlwhen you need multiple documents in the same UI.
Related reading
- How to specify Proxy Pass in kubernetes
- How to specify static IP address for Kubernetes load balancer?
- How to stop consuming message from kafka and stop calling REST API call of another service in case of failure
- How to store best models checkpoints, not only newest 5, in Tensorflow Object Detection API?
- How to specify external location for image store in Spring Boot 2.0 web app?
- How to specify function types for void not Void methods in Java8?
- How To Stream Chunked Response With Spring Boot RestController
- How to synchronously load a csv file into memory before handling HTTP requests

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.