Skip to content

mateus-silva-dev/DocFlow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  A smart, automated way to document your Spring Boot APIs.


๐Ÿ“š Table of Contents


๐Ÿ”ง Compatibility

Component Supported Version
Java 17+
Spring Boot 3.4.0+

โœ… Tested on Spring Boot 3.4.x, 3.5.x and 4.0.0.

โŒ Versions prior to Spring Boot 3.4.0 are not supported.


๐Ÿš€ Introduction

DocFlow is a SpringDoc OpenAPI support library that simplifies endpoint documentation by automating summaries and descriptions and standardizing error schemes. With native support for internationalization (i18n), DocFlow allows your API to communicate with the world in multiple languages without any extra effort.

DocFlow eliminates the need to write repetitive text in OpenAPI annotations. Through automatic inferences and custom annotations, you keep your code clean and your Swagger documentation professional, following industry best practices.


Why DocFlow?

DocFlow was created to solve three common problems in Spring Boot APIs:

  • Excessive Swagger/OpenAPI boilerplate
  • Repetitive HTTP response documentation
  • Lack of standardized documentation across projects

By leveraging conventions and automation, DocFlow allows developers to focus on business logic instead of documentation maintenance.


๐Ÿ’ฅ Problem & ๐ŸŒฑ The Solution

Have you ever felt like youโ€™re writing more Swagger annotations than business logic? Excessive OpenAPI configuration wastes time and undermines the readability of your Java code. The common workaround of creating an interface just to โ€œhideโ€ the annotations from the controller is a stopgap that creates another problem: an explosion of duplicate files in your project.

โŒ Before (Standard Swagger/OpenAPI)

Excessive boilerplate, cluttered endpoints, and poor readability.

โœจ After (With DocFlow)

Clean code, zero boilerplate, and automatic documentation based on conventions.


๐ŸŽฏ Features

  • Reduced Swagger Boilerplate: Say goodbye to endless annotations cluttering your controllers.
  • Automatic OpenAPI Documentation: Generates full, compliant OpenAPI specs seamlessly.
  • Smart Security Inference: Automatically reads Spring Security annotations (e.g., @PreAuthorize) to secure endpoints.
  • Zero-Config JWT Auth: Instantly configures Bearer token authentication in Swagger UI without manual schemas.
  • Smart HTTP Response Inference: Automatically detects and maps your endpoint response types.
  • Automatic 200 / 204 Detection: Smart recognition of content return vs. empty success statuses.
  • Convention-Based Descriptions: Generates clear, human-readable endpoint documentation by default.
  • Spring Boot Auto-Configuration: Plug-and-play setup with zero manual bean configuration required.
  • Flexible YAML Configuration: Easily customize global behaviors and metadata via application.yml.
  • OpenAPI Schema Customization: Fully extend, override, or tweak generated schemas when needed.

๐Ÿ› ๏ธ Installation

1. Add Dependency

Add the DocFlow starter to your project configuration:

Maven

<dependency>
    <groupId>io.github.docflow-lib</groupId>
    <artifactId>docflow-spring-boot-starter</artifactId>
    <version>1.0.0</version>
</dependency>

Gradle

implementation 'io.github.docflow-lib:docflow-spring-boot-starter:1.0.0'

2. Configuration

โš™๏ธ Configuration Properties

Property Description
docflow.title OpenAPI title
docflow.description OpenAPI description
docflow.version API version
docflow.default-error-schema Global error response DTO
docflow.security.enabled Activate the security module (Spring Security).
docflow.security.scheme-name Text that appears on the Swagger button

Configure your project properties by adjusting the paths and packages to match your own project structure. Choose your preferred format below:

Option A: Using application.yml

springdoc:
  swagger-ui:
    path: /swagger-ui.html # Your custom Swagger UI URL path
  api-docs:
    path: /v3/api-docs     # Your custom OpenAPI JSON path
  packages-to-scan: com.yourcompany.yourproject.controller # Package where your controllers are located
  remove-broken-reference-definitions: false

docflow:
  title: "Your API Title"
  description: "Your API Description"
  version: "1.0.0"
  default-error-schema: com.yourcompany.yourproject.exception.StandardError # Path to your global error DTO

Option B: Using application.properties

# SpringDoc Setup
springdoc.swagger-ui.path=/swagger-ui.html
springdoc.api-docs.path=/v3/api-docs
springdoc.packages-to-scan=com.yourcompany.yourproject.controller
springdoc.remove-broken-reference-definitions=false

# DocFlow Setup
docflow.title=Your API Title
docflow.description=Your API Description
docflow.version=1.0.0
docflow.default-error-schema=com.yourcompany.yourproject.exception.StandardError

๐Ÿš€ Sample Projects

To help you get started quickly, we provide complete, functional, and verified sample applications for both build tools. You can explore the source code to see DocFlow in action:

Build Tool Project Link Key Features Demonstrated
Maven ๐Ÿ› ๏ธ docflow-maven-sample Spring Boot 3.4.0+, Spring Security, Automated Swagger OpenAPI generation
Gradle ๐Ÿ˜ docflow-gradle-sample Multi-platform build integration, Zero-Config documentation routing

How to run the samples:

  1. Clone this repository.
  2. Navigate to the desired sample folder (examples/docflow-maven-sample or examples/docflow-gradle-sample).
  3. Run the application:
    • For Maven: mvn spring-boot:run
    • For Gradle: ./gradlew bootRun
  4. Access the interactive documentation at: Click here or http://localhost:8080/swagger-ui.html

Quick Start

Docflow offers two flexible ways to document your methods: automatic and manual.

1. Automatic Mode

In this mode, you just need to enter the annotation. Docflow automatically generates the information based on the method name.

Code:

@RestController
@RequestMapping("/users")
@ApiDocController // <- DocFlow Annotations
public class UserController {

    @PostMapping
    @ApiDocPost // <- DocFlow Annotations
    public ResponseEntity<UserResponse> createNewUser(@RequestBody UserCreateDTO request) {
        return ResponseEntity.status(HttpStatus.CREATED).body(service.create(request));
    }
}

Result:

2. Manual Mode

If you need more details or a customized description, you can enter the information directly in the note.

Code:

@RestController
@RequestMapping("/users")
@ApiDocController(
        tagName = "Users",                              // Optional
        tagDescription = "User management endpoints"    // Optional
)
public class UserController {

    @PostMapping
    @ApiDocPost(
            summary = "Create a new user",                                              // Optional
            description = "Registers a new user in the system with basic permissions."  // Optional
    )
    public ResponseEntity<UserResponse> createNewUser(@RequestBody UserCreateDTO request) {
        return ResponseEntity.status(HttpStatus.CREATED).body(service.create(request));
    }
}

Result:


๐Ÿท๏ธ Annotations & Supported HTTP Status Codes

Note HTTP Method Standard HTTP Codes Status Description
@ApiDocGet GET 200, 401, 403, 404, 500 Success (OK), Unauthorized, Forbidden, Not Found, Internal Error.
@ApiDocPost POST 201, 400, 401, 403, 409, 422, 500 Created, Invalid Request, Unauthorized, Forbidden, Conflict, Unprocessable Entity, Internal Error.
@ApiDocPut / @ApiDocPatch PUT / PATCH 200/204, 400, 401, 403, 404, 422, 500 Success/No Content, Invalid Request, Unauthorized, Forbidden, Not Found, Unprocessable Entity, Internal Error.
@ApiDocDelete DELETE 204, 401, 403, 404, 500 No Content, Unauthorized, Forbidden, Not Found, Internal Error.

๐Ÿ“‘ Quick Annotation Guide

Annotation Where to apply? When to use?
@ApiDocController On the Controller class In classes annotated with @RestController or @Controller.
@ApiDocGet On the method In HTTP GET methods (@GetMapping).
@ApiDocPost On the method In HTTP POST methods (@PostMapping).
@ApiDocPut On the method In HTTP PUT methods (@PutMapping).
@ApiDocPatch On the method In HTTP PATCH methods (@PatchMapping).
@ApiDocDelete On the method In HTTP DELETE methods (@DeleteMapping).

๐Ÿ”’ Smart Security (Smart JWT Authentication)

DocFlow features a security inference engine that draws the padlocks in Swagger and creates the Login button automatically, without cluttering your code with verbose OpenAPI annotations.

Just turn on security in your application.yml/.properties. The library natively configures the Bearer Token (JWT) format:

1. With the module active

configuration .yml:

docflow:
  security:
    enabled: true
    scheme-name: "API Authentication"   # Optional: Text that appears on the Swagger button

configuration .properties:

docflow.security.enabled=true
docflow.security.scheme-name=API Authentication     # Optional: Text that appears on the Swagger button

Code:

// ๐Ÿ”“ Free Route: DocFlow notices the lack of annotations and leaves the documentation public.
@GetMapping
public List<User> list() { ... }

// ๐Ÿ”’ Protected Route: DocFlow detects @PreAuthorize and places the padlock automatically!
@PostMapping
@PreAuthorize("hasRole('ADMIN')")
public User create() { ... }

Result:

scheme-name:

2. With the module disabled

configuration .yml:

docflow:
  security:
    enabled: false
    scheme-name: "API Authentication"   # Optional: Text that appears on the Swagger button

configuration .properties:

docflow.security.enabled=false
docflow.security.scheme-name=API Authentication     # Optional: Text that appears on the Swagger button

Code:

// ๐Ÿ”“ Free Route: DocFlow notices the lack of annotations and leaves the documentation public.
@GetMapping
public List<User> list() { ... }

// ๐Ÿ”’ Protected Route: DocFlow detects @PreAuthorize and places the padlock automatically!
@PostMapping
@PreAuthorize("hasRole('ADMIN')")
public User create() { ... }

Result:


๐ŸŒ Internationalization (i18n)

One of DocFlow's most powerful features is its native multi-language support. The documentation dynamically adapts based on the user's browser language context.

By default, if a language is not specified or supported, it fallbacks to English.

Supported Languages & Swagger Preview

Language Flag Status Preview
English Default English Preview
Portuguese Supported Portuguese Preview
Spanish Supported Spanish Preview
Language Flag Status Preview
French Supported French Preview
German Supported German Preview
Chinese (Simplified) Supported Chinese Preview

No extra configuration is required. DocFlow automatically detects the Accept-Language headers and translates the standard error descriptions on the fly.


๐Ÿ—บ๏ธ Roadmap


๐Ÿš€ Version 1.0.0 โ€” Initial Release (Released)

๐Ÿ’Ž Core & Automation

Feature / Task Status
Simplified OpenAPI annotations โœ…
@ApiDocController support โœ…
Automatic summary generation โœ…
Automatic description generation โœ…
Convention-over-configuration โœ…
Automatic HTTP response doc โœ…
Smart Security inference โœ…
Zero-Config JWT Auth โœ…

๐Ÿง  Smart Response & Compatibility

Feature / Task Status
Auto 200, 201, 204 detection โœ…
Return type inspection โœ…
Support: DTO & List<T> โœ…
Support: Page<T> & Slice<T> โœ…
Support: Optional<T> & Map โœ…
Support: String, URI & Void โœ…

โš™๏ธ Configuration & i18n

Feature / Task Status
YAML & Properties support โœ…
OpenAPI metadata configuration โœ…
Configurable default error schema โœ…
Automatic browser locale detection โœ…
Support: EN, PT, ES, FR, DE, CN โœ…
Maven example project โœ…
Gradle example project โœ…

โšก Version 1.1.0 โ€” DX, OpenAPI & i18n Expansion

๐Ÿ› ๏ธ DX & Refinements

Feature / Task Status
Improved README documentation โณ
More customization examples โณ

๐Ÿ” OpenAPI Improvements

Feature / Task Status
Additional customization hooks โณ
Custom response description overrides โณ
Better generated descriptions โณ

๐ŸŒ i18n Expansion

Feature / Task Status
Support: Italian (IT) โณ
Support: Japanese (JP) โณ
Support: Korean (KR) โณ
Support: Russian (RU) โณ

๐Ÿ”ฎ Version 2.0.0 โ€” The Convention Era

๐Ÿค– Convention-Based Docs

Feature / Task Status
Full doc without annotations ๐Ÿ“…
Spring Mapping inference ๐Ÿ“…
Controller tag auto-generation ๐Ÿ“…
Endpoint summary improvements ๐Ÿ“…

๐ŸŽ›๏ธ Configuration & Ecosystem

Feature / Task Status
Global response customization ๐Ÿ“…
Custom conventions support ๐Ÿ“…
Kotlin language support ๐Ÿ“…
Expanded Spring ecosystem support ๐Ÿ“…

๐Ÿ“œ License


โญ Support

If DocFlow helps your project, consider giving it a star on GitHub.


โœ๏ธ Author

Mateus Silva

About

A smart, automated way to document your Spring Boot APIs.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages