JHipster’s Built‑in OpenAPI Support: Automate API Docs and Keep Them In Sync
JHipster’s built‑in OpenAPI support automatically generates live API docs. This blog walks through setting it up, verifying the JSON endpoint, customizing metadata, and securing the docs in production.
09 Aug 2026, 22:54 UTC

Why Automatic API Docs Matter in JHipster
When a JHipster project is scaffolded with the swagger or openapi option, the generator wires up Springdoc OpenAPI. The result is a live /v3/api-docs JSON endpoint and a Swagger UI that reflects every @RestController and repository paging parameter without any manual edits.
What JHipster Adds Under the Hood
- Dependency:
org.springdoc:springdoc-openapi-starter-webmvc-ui(Springdoc 2.x in JHipster 7.10+). - Configuration bean that exposes
/v3/api-docsand serves Swagger UI at/swagger-ui/index.html.- Earlier JHipster versions use
/swagger-ui.html.
- Earlier JHipster versions use
- Automatic inclusion of all controller methods, request/response classes, and Spring Data paging parameters.
- YAML overrides:
jhipster.ymlorapplication.ymlcan setopenapi.title,openapi.description,openapi.version, and security schemes.
Concrete Step‑by‑Step Example
- Generate a project
jhipster --blueprints swagger --force # or add the option during interactive setupWhen prompted for an option, choose
swagger(oropenapi) to add the dependency automatically. - Run the app
./mvnw spring-boot:runRequires Maven 3.6+ and Java 17+ (the default JHipster stack).
- Verify the JSON schema
curl http://localhost:8080/v3/api-docs | head -n 20You should see a JSON document starting with
{"openapi":"3.1.0", "info":{...}}. If the endpoint returns 404, check that Spring Security isn’t blocking it. - Open the Swagger UI
open http://localhost:8080/swagger-ui/index.htmlAll generated entities (e.g.,
User,Post) appear as operations. Adding a new field to an entity and regenerating it withjhipster entityautomatically updates the UI on the next refresh. - Override metadata
# In src/main/resources/config/application.yml jhipster: swagger: title: "My App API" description: "Public API for the My App service" version: "2.0"Restart the app to see the changes reflected in the JSON and UI.
Trade‑Offs and Practical Limitations
- Endpoint exposure in production:
/v3/api-docsis public by default. If your service contains internal endpoints, secure it with Spring Security:spring: security: oauth2: resourceserver: jwt: issuer-uri: https://auth.example.comor add a custom
SecurityFilterChainthat permits only authenticated users. - Path differences: 2.x Springdoc uses
/swagger-ui/index.html; 1.x used/swagger-ui.html. Adjust your documentation links accordingly if you upgrade. - Large schemas: Complex projects can generate huge JSON files that slow the UI. Consider enabling
springdoc.api-docs.groupsto split the spec.
Actionable Checklist for Your Project
- Include the OpenAPI option when creating or updating a JHipster app.
- Verify
/v3/api-docsis reachable during development. - Secure the endpoint in
application-prod.ymlif the app is exposed to the internet. - Use
jhipster entityto regenerate entities; the docs update automatically. - Document custom security schemes in
jhipster.ymlto keep the spec accurate.
Conclusion
JHipster’s OpenAPI integration turns API documentation from a static artifact into a live reflection of your code. With minimal configuration, you get a browsable UI, a consumable JSON spec, and automatic updates whenever you change an entity. The main caveat is ensuring the docs endpoint is appropriately secured for production deployments.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.