Closed
Description
This is from a large public sector project where we implement an api.
The open api yaml specifies different response types for response status 200 and 202 (either a search result or a notification that result is not yet available).
When generating rest controller interface for Spring, the openapi-processior blindly uses the model class for the 202 response.
I managed to get it somehow working by configuring the endpoint to use ResponseEntity
as return type, but that needs a pretty hacky workaround:
public ResponseEntity<FooAvailabilityResponse> fooSearchApplicationJson(String fooType, HttpServletRequest request, FooSearchQuery body) {
FooSearchResult result = FooSearchResult.builder().build();
ResponseEntity<FooSearchResult> responseEntity = ResponseEntity
.ok()
.contentType(MediaType.APPLICATION_JSON)
.body(result);
@SuppressWarnings({ "rawtypes", "unchecked" })
ResponseEntity<FooAvailabilityResponse> rawResponseEntity = (ResponseEntity)responseEntity;
return rawResponseEntity;
}
I created a small example project, see https://github.com/eekboom/openapi-processor-example
Metadata
Metadata
Assignees
Labels
No labels