Result mapping
Standard
A ResponseEntity<> allows an endpoint implementation full control of the response.
Here is a super simple example:
public ResponseEntity<String> getFoo() {
return ResponseEntity.ok("foo");
}
To enable a result wrapper set the result mapping in the mapping YAML to a fully qualified java type.
map:
result: org.springframework.http.ResponseEntity
| The processor expects that it takes a single generic parameter. |
Depending on the number of defined response content types the parameter of the ResponseEntity<> will be either the java type or the unknown type.
| responses | ResponseEntity<> |
|---|---|
one |
|
multiple |
|
plain result type
since 2025.5
The standard result mapping requires a generic wrapper type, like ResponseEntity<>. To map a non-generic type as return type the result mapping accepts an arrow mapping:
plain ⇒ {target type}
which means, instead of the plain schema described in the OpenAPI response, use the target type as endpoint return type.
openapi-processor-mapping: v15
options:
package-name: io.openapiprocessor.generated
map:
paths:
/foo:
# new, mapping of plain replacement type
result: plain => org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody
Limit to Endpoint
The result mapping works as endpoint-specific mapping too. That way it is possible to use the ResponseEntity<> only on single endpoints.
So a mapping like this:
map:
/foo:
result: org.springframework.http.ResponseEntity
will only wrap the result of the endpoint /foo.
In case of global type mapping
map:
result: org.springframework.http.ResponseEntity
that should not apply to a specific endpoint it is possible to clear the global mapping by setting result to plain:
map:
result: org.springframework.http.ResponseEntity
paths:
/foo:
# clear the top level "result" property, "plain" means no wrapper
result: plain