Spring Annotations

Apart from the basic build plugin configuration, openapi-processor-spring has an additional configuration to select the annotation style.

annotations

since 2026.3

Spring Boot provides two annotation families

  • the standard mapping annotations, i.e., @RequestMapping, @GetMapping and friends to define server side controllers

  • and the new exchange (HTTP service clients) annotations, i.e., @HttpExchange, @GetExchange and friends to define server side controllers and http clients based on the same interface.

openapi-processor-spring supports both kinds of annotations.

The @..Exchange support is new and has minimal usage; it may still produce wrong code. Please open an issue if you find something.

Switching between both annotation families is done in the mapping.yaml:

openapi-processor-spring: v1 (1)

options:
  package-name: io.openapiprocesser

  spring: (2)
    # default, i.e., mapping annotations
    #annotations: mapping
    # use exchange annotations
    annotations: exchange (3)

There are a few things that are important here:

1 the mapping identifier has changed. It is now expecting openapi-processor-spring instead of openapi-processor-mapping. The processor will still accept openapi-processor-mapping.

The new identifier is required to get proper editing support for the new option with the IntelliJ plugin.

2 a new Spring specific section in the options object.
3 the annotation family: mapping or exchange. With mapping being the default.

Here is a small example diff that shows which lines of the generated code would change when switching annotations from mapping to exchange.

 import generated.model.Foo;
 import generated.support.Generated;
 import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.service.annotation.PostExchange;

 @Generated(value = "openapi-processor-spring", version = "test")
 public interface Api {

     @ResponseStatus(HttpStatus.CREATED)
+    @PostExchange(url = "/foo", contentType = "application/json", accept = {"application/json"})
-    @PostMapping(path = "/foo", consumes = {"application/json"}, produces = {"application/json"})
     Foo postFoo(@RequestBody Foo body);

 }