Validate the request schema
Every request-bearing operation gets a JSON schema insrc/main/resources/<operation>-schema-validation.json, applied at the very start of the route:
kamelet:json-validation-exception-handler catches the resulting JsonValidationException and returns a Grand Central-shaped error response.
Convert an OpenAPI spec to JSON Schema
To generate a JSON Schema file from an OpenAPI spec, follow these steps:-
Install the conversion tool:
-
Run the following command to generate a JSON Schema for all schemas in the OpenAPI spec:
-
In the generated schema file, prefix a
/at the beginning of all reference paths in$refvalues. Example: Change"$ref": "#definitions/Address"to"$ref": "#/definitions/Address".
JOLT for REST/JSON connectors
JOLT is a JSON-to-JSON declarative transformation language. Use it to map the Grand Central canonical request and response shape to the vendor shape and back. The most common route call takes a JSON String in and out:XSLT for SOAP/XML connectors
XSLT 3.0 produces the SOAP envelope on the request side and reshapes the SOAP response into the Grand Central canonical JSON-friendly XML on the response side. Route call:- Always declare the vendor namespace at the top (
xmlns:ns="..."). XPath without the prefix matches nothing. - Use
omit-xml-declaration="yes"on the rootxsl:outputso the route can pipe the XML cleanly intodirect:xmlToJson. - To force a JSON array on a single element, emit a paired empty-and-populated element (for example,
<amounts/><amounts>...</amounts>). TheRemoveNullOrEmptyJsonSerializerconfigured on the JSON marshaller drops the empty placeholder, leaving an array. - Wrap optional sections in
xsl:ifto avoid emitting empty objects.
Dynamic field translation through properties
For straight value-to-value substitutions (for example, mapping a vendor code likeSAV to a Grand Central value like savings-account), avoid embedding if/else logic inside JOLT or XSLT. The SDK ships two helpers that pull the mappings straight from application.properties. The helpers keep transformation files focused on structure, remove a major source of duplication across operations, and make every value mapping visible in one place.
Pick the helper bean call that matches the body type:
fieldsToBeReplaced property and its related entries from the connector’s properties, then apply the substitutions in place.
Simple mapping uses one field per row with comma-separated field names:
@ as the delimiter:
| Camel-K runtime | Minimum grandcentral-bom version |
|---|---|
| Pre-2.6 | 2.2.119 |
| 2.6 | 2.3.17 |
JSON and XML marshaling for SOAP
Define two helper routes once and reuse them across every SOAP operation:RemoveNullOrEmptyJsonSerializer strips nulls and empty strings or objects on serialization. The serializer makes the array trick in XSLT work and keeps response payloads tidy.
After every direct:xmlToJson, run the type-coercion processor to fix string-to-number/boolean coercion from Jackson’s XML deserializer:
typeConversion.skipAttributes property to decide which fields stay strings, typically identifiers.
Input validation with PredicatesValidatingProcessor
Use this for header or format validation that should produce a Grand Central error response on failure.Common GrandCentralUtil inline helpers
A handful ofbean(...) calls come up over and over: