Skip to content

Fix Micronaut OpenAPI Docs Not Generating

DodaTech Updated 2026-06-24 1 min read

In this tutorial, you'll learn about Fix Micronaut OpenAPI Docs Not Generating. We cover key concepts, practical examples, and best practices.

The Problem

OpenAPI documentation is not generated or endpoints are missing from Swagger UI.

Quick Fix

Add OpenAPI dependency

Wrong:

<!-- No openapi -->

Output:

No endpoint docs

Right:

<dependency>
  <groupId>io.micronaut</groupId>
  <artifactId>micronaut-openapi</artifactId>
</dependency>

Output:

OpenAPI enabled

Use @OpenAPI annotations

Wrong:

@Controller("/api")
public class ProductController { }

Output:

No docs generated

Right:

@Controller("/api")
@OpenAPI(parameters = {@OpenAPIParameter(name = "Authorization", in = ParameterIn.HEADER)})
public class ProductController { }

Output:

API documented

Configure Swagger UI

Wrong:

# No swagger config
micronaut.router.static-resources.swagger.paths=classpath:META-INF/swagger

Output:

No UI

Right:

micronaut:
  router:
    static-resources:
      swagger:
        paths: classpath:META-INF/swagger
        mapping: /swagger/**

Output:

Swagger UI available

Prevention

  • Add micronaut-openapi dependency
  • Annotate controllers with @OpenAPI annotations
  • Configure static resources for Swagger UI

Common Mistakes with openapi

  1. Using return to exit a function early instead of wrapping a pure value in the monad
  2. Mixing let bindings with <- bindings in do notation, producing type errors
  3. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors

These mistakes appear frequently in real-world MICRONAUT 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

### Where is the OpenAPI spec available?

At /swagger/openapi.yml or /swagger-ui by default.

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