Fix Quarkus OpenAPI Not Generating
In this tutorial, you'll learn about Fix Quarkus OpenAPI Not Generating. We cover key concepts, practical examples, and best practices.
The Problem
OpenAPI specification is not generated or endpoints are missing from Swagger UI.
Quick Fix
Add OpenAPI dependency
Wrong:
<!-- No openapi -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>
Output:
No API docs
Right:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>
Output:
OpenAPI enabled
Use @OpenAPI annotations
Wrong:
@Path("/products")
public class ProductResource { } // No API docs
Output:
Missing documentation
Right:
@Path("/products")
@Operation(summary = "Get all products")
@APIResponse(responseCode = "200", description = "List of products")
@GET
public Response getAll() { }
Output:
Endpoint documented
Configure Swagger UI
Wrong:
# No swagger config
quarkus.swagger-ui.always-include=true
Output:
Only in dev mode
Right:
quarkus.swagger-ui.always-include=true
quarkus.smallrye-openapi.path=/openapi
Output:
Swagger UI in all modes
Prevention
- Add quarkus-smallrye-openapi dependency
- Use @Operation and @APIResponse annotations
- Set quarkus.swagger-ui.always-include=true for production
Common Mistakes with openapi
- Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
- Non-exhaustive pattern matches that compile with warnings then crash at runtime
- Misunderstanding that
Stringis[Char]with poor performance for large text operations
These mistakes appear frequently in real-world QUARKUS code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
This quick fix is part of the DodaTech Spring & JVM ecosystem series. Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro