Hello,

I have a question regarding the rest-openapi component and would appreciate
your input if you have a moment.

In my setup, I have an OpenAPI specification defining a REST service that
accepts binary data in Protobuf or Avro formats and also json and xml.
However, the binary data is consistently read by the DefaultHttpBinding
class with an encoding applied, which results in data corruption.

Here's a snippet from the OpenAPI spec:


post:
  summary: Create an order
  operationId: createOrder
  parameters:
    - name: transactionId
      in: header
      required: true
      schema:
        type: string
        format: uuid
    - name: requestId
      in: header
      required: true
      schema:
        type: string
        format: uuid

  requestBody:
    description: Order to add
    required: true
    content:
      application/json:
        schema:
          $ref: '#/components/schemas/Order'
      application/xml:
        schema:
          $ref: '#/components/schemas/Order'
      application/x-protobuf:
        schema:
          $ref: '#/components/schemas/Order'
      application/avro:
        schema:
          $ref: '#/components/schemas/Order'

To read the data directly from HttpServletRequest.getInputStream() without
encoding,  I modified the routeConfigurer.configure method with the
following configuration,
allowing it to read the input stream as-is. However, this introduces a new
issue: JSON and XML data now require additional encoding.


PlatformHttpEndpoint endpoint =
getContext().getEndpoint("platform-http:///?matchOnUriPrefix=true";,
PlatformHttpEndpoint.class);
endpoint.setUseStreaming(true);



Is there a way to handle all four formats consistently within the same REST
DSL configuration?
Or would it be necessary to modify the
org.apache.camel.http.common.DefaultHttpBinding.parseBody method to handle
binary formats
like application/x-protobuf, application/avro, and application/octet-stream
separately?

Thank you for your time and assistance.

Regards
Ege Karaosmanoglu

Reply via email to