Class RestConfigurationProperties

java.lang.Object
org.apache.camel.spi.RestConfiguration
org.apache.camel.main.RestConfigurationProperties
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.camel.spi.BootstrapCloseable

@Configurer(extended=true) public class RestConfigurationProperties extends org.apache.camel.spi.RestConfiguration implements org.apache.camel.spi.BootstrapCloseable
Global configuration for Rest DSL.
  • Constructor Details

  • Method Details

    • end

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • withComponent

      public RestConfigurationProperties withComponent(String component)
      The Camel Rest component to use for the REST transport (consumer), such as netty-http, jetty, servlet, undertow. If no component has been explicit configured, then Camel will lookup if there is a Camel component that integrates with the Rest DSL, or if a org.apache.camel.spi.RestConsumerFactory is registered in the registry. If either one is found, then that is being used.
    • withApiComponent

      public RestConfigurationProperties withApiComponent(String apiComponent)
      The name of the Camel component to use as the REST API (such as swagger)
    • withProducerComponent

      public RestConfigurationProperties withProducerComponent(String producerComponent)
      Sets the name of the Camel component to use as the REST producer
    • withScheme

      public RestConfigurationProperties withScheme(String scheme)
      The scheme to use for exposing the REST service. Usually http or https is supported.

      The default value is http

    • withHost

      public RestConfigurationProperties withHost(String host)
      The hostname to use for exposing the REST service.
    • withApiHost

      public RestConfigurationProperties withApiHost(String apiHost)
      To use a specific hostname for the API documentation (such as swagger or openapi)

      This can be used to override the generated host with this configured hostname

    • withUseXForwardHeaders

      public RestConfigurationProperties withUseXForwardHeaders(boolean useXForwardHeaders)
      Whether to use X-Forward headers to set host etc. for OpenApi. This may be needed in special cases involving reverse-proxy and networking going from HTTP to HTTPS etc. Then the proxy can send X-Forward headers (X-Forwarded-Proto) that influences the host names in the OpenAPI schema that camel-openapi-java generates from Rest DSL routes.
    • withPort

      public RestConfigurationProperties withPort(int port)
      The port number to use for exposing the REST service. Notice if you use servlet component then the port number configured here does not apply, as the port number in use is the actual port number the servlet component is using. eg if using Apache Tomcat its the tomcat http port, if using Apache Karaf its the HTTP service in Karaf that uses port 8181 by default etc. Though in those situations setting the port number here, allows tooling and JMX to know the port number, so its recommended to set the port number to the number that the servlet engine uses.
    • withProducerApiDoc

      public RestConfigurationProperties withProducerApiDoc(String producerApiDoc)
      Sets the location of the api document (swagger api) the REST producer will use to validate the REST uri and query parameters are valid accordingly to the api document. This requires adding camel-openapi-java to the classpath, and any miss configuration will let Camel fail on startup and report the error(s).

      The location of the api document is loaded from classpath by default, but you can use file: or http: to refer to resources to load from file or http url.

    • withContextPath

      public RestConfigurationProperties withContextPath(String contextPath)
      Sets a leading context-path the REST services will be using.

      This can be used when using components such as camel-servlet where the deployed web application is deployed using a context-path. Or for components such as camel-jetty or camel-netty-http that includes a HTTP server.

    • withApiContextPath

      public RestConfigurationProperties withApiContextPath(String apiContextPath)
      Sets a leading API context-path the REST API services will be using.

      This can be used when using components such as camel-servlet where the deployed web application is deployed using a context-path.

    • withApiContextRouteId

      public RestConfigurationProperties withApiContextRouteId(String apiContextRouteId)
      Sets the route id to use for the route that services the REST API.

      The route will by default use an auto assigned route id.

    • withApiVendorExtension

      public RestConfigurationProperties withApiVendorExtension(boolean apiVendorExtension)
      Whether vendor extension is enabled in the Rest APIs. If enabled then Camel will include additional information as vendor extension (eg keys starting with x-) such as route ids, class names etc. Not all 3rd party API gateways and tools supports vendor-extensions when importing your API docs.
    • withHostNameResolver

      public RestConfigurationProperties withHostNameResolver(String hostNameResolver)
      If no hostname has been explicit configured, then this resolver is used to compute the hostname the REST service will be using. The possible values are: allLocalIp, localIp, localHostName
    • withBindingMode

      public RestConfigurationProperties withBindingMode(String bindingMode)
      Sets the binding mode to use.

      The possible values are: auto, off, json, xml, json_xml The default value is off

    • withBindingPackageScan

      public RestConfigurationProperties withBindingPackageScan(String bindingPackageScan)
      Package name to use as base (offset) for classpath scanning of POJO classes are located when using binding mode is enabled for JSon or XML. Multiple package names can be separated by comma.
    • withSkipBindingOnErrorCode

      public RestConfigurationProperties withSkipBindingOnErrorCode(boolean skipBindingOnErrorCode)
      Whether to skip binding on output if there is a custom HTTP error code header. This allows to build custom error messages that do not bind to json / xml etc, as success messages otherwise will do.
    • withClientRequestValidation

      public RestConfigurationProperties withClientRequestValidation(boolean clientRequestValidation)
      Whether to enable validation of the client request to check: 1) Content-Type header matches what the Rest DSL consumes; returns HTTP Status 415 if validation error. 2) Accept header matches what the Rest DSL produces; returns HTTP Status 406 if validation error. 3) Missing required data (query parameters, HTTP headers, body); returns HTTP Status 400 if validation error. 4) Parsing error of the message body (JSon, XML or Auto binding mode must be enabled); returns HTTP Status 400 if validation error.
    • withEnableCORS

      public RestConfigurationProperties withEnableCORS(boolean enableCORS)
      Whether to enable CORS headers in the HTTP response.

      The default value is false.

    • withInlineRoutes

      public RestConfigurationProperties withInlineRoutes(boolean inlineRoutes)
      Inline routes in rest-dsl which are linked using direct endpoints. By default, each service in Rest DSL is an individual route, meaning that you would have at least two routes per service (rest-dsl, and the route linked from rest-dsl). Enabling this allows Camel to optimize and inline this as a single route, however this requires to use direct endpoints, which must be unique per service. This option is default false.
    • withJsonDataFormat

      public RestConfigurationProperties withJsonDataFormat(String jsonDataFormat)
      Name of specific json data format to use. By default jackson will be used. Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance.
    • withXmlDataFormat

      public RestConfigurationProperties withXmlDataFormat(String xmlDataFormat)
      Name of specific XML data format to use. By default jaxb will be used. Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance.
    • withComponentProperty

      public RestConfigurationProperties withComponentProperty(String key, Object value)
      Adds a component property
    • withEndpointProperty

      public RestConfigurationProperties withEndpointProperty(String key, Object value)
      Adds a endpoint property
    • withConsumerProperty

      public RestConfigurationProperties withConsumerProperty(String key, Object value)
      Adds a consumer property
    • withDataFormatProperty

      public RestConfigurationProperties withDataFormatProperty(String key, Object value)
      Adds a data format property
    • withApiProperty

      public RestConfigurationProperties withApiProperty(String key, Object value)
      Adds a api property
    • withCorsHeader

      public RestConfigurationProperties withCorsHeader(String key, String value)
      Adds a CORS header property