Hello, I think you can include in each endpoint the `produces()` method to specify the content type, see doc [1]. Specular to that, there is the consumes() if you need that too.
Pasquale. [1] https://camel.apache.org/components/4.14.x/rest-component.html#_endpoint_query_option_produces On Tue, Oct 14, 2025 at 11:31 AM Laurin Niemeyer <[email protected]> wrote: > Hi all, > > I’m using Camel’s Rest DSL (with the servlet component) and generating an > OpenAPI specification via camel-openapi-java-starter > > In one of my routes, I’d like to have *different content types for > different response codes* in the generated OpenAPI spec — specifically: > > - > > 201 → application/json > - > > 400 → application/problem+json > > Here’s a simplified version of my setup: > > restConfiguration() > .component("servlet") > .bindingMode(RestBindingMode.json) > .dataFormatProperty("contentTypeHeader", "false") > .apiContextPath("/openapi"); > > And my route: > > rest("/v1/public-announcements") > .post() > .id("create-public-announcement") > .type(CreatePublicAnnouncementRequest.class) > .responseMessage().code(201).message("Created") > > .responseModel(CreateIncidentResponse.class).endResponseMessage() > .responseMessage().code(400).message("Bad Request") > .responseModel(ZoneApiErrorMessage.class).endResponseMessage() > .to("direct:createPublicAnnouncement"); > > This works fine at runtime — the HTTP responses have the correct > Content-Type headers — > but in the generated OpenAPI spec, both 201 and 400 responses are listed > with: > > "content": { > "application/json": { ... }} > > Is there a way in the Rest DSL or via OpenAPI configuration to override the > response content type per response (e.g. make the 400 response use > application/problem+json)? > > Thanks in advance for any pointers! > — Laurin Niemeyer >
