Swagger / OpenAPI

Rewrites OpenAPI JSON only when changes are made by analyzing RouterFunction and handler sources.


Functional endpoint mode

ApiAccountRouter.java
java
@Bean
public RouterFunction<ServerResponse> apiAccount(ApiAccountHandler handler) {
  return route()
      .nest(path("/api/account"), builder -> builder
          .nest(path("/search"), search -> search
              .GET("/get-detail/{accountName}", handler::getDetail)
              .GET("/get-list", handler::getList)))
      .build();
}

Combines nested paths, HTTP methods, and handler method references to configure endpoints. The handler parser infers the request body and response publisher type.

SwaggerJsonFileWatcher.Config

watchDirectory

default src/main/java

swaggerOutputFile

Default src/main/resources/static/swagger.json.

projectMode

Default FUNCTIONAL_ENDPOINT, optional MVC.

addDecompileJar / addDecompileJarClass

Source analysis of external jar types.

addSourceClasspath

Source/classpath for symbol resolution.

customTypeMapper

Receives Class and schema Map to apply custom schema.

Annotation to correct inference

java
@SelectedRequestParam(
    key = "pageSize",
    required = false,
    nullable = true,
    type = Integer.class
)
Integer pageSize = request.queryParam("pageSize").map(Integer::valueOf).orElse(null);

@SelectedResponseBody(type = MemberDetailResponse.class)
Mono<MemberDetailResponse> response = service.getDetail(accountName);

Write only if changed

If the generation result is the same as the existing JSON, it will not unnecessarily change the file timestamp. This is advantageous in reducing regeneration loops in a structure where the front watcher detects changes in the swagger file.

© 2026 Byeolnaerim. All rights reserved.IntroductionPrivacy Policy