Loading…
Loading…
Apply field name casing overrides for an API operation. Set a default casing mode (e.g., camelCase) and define per-field overrides using SOAP XPath
The FieldCasingApplyService provides a mechanism for API publishers to control the casing of field names in API responses for a specific operation. This allows for transforming field names from a backend source, such as a SOAP service, into a consistent and conventional format for API consumers.
Configuration is applied at the operation level and supports both a global casing mode and granular, per-field overrides identified by their SOAP XPath.
The service exposes a single method, apply, which takes an operation's ID, a global casing mode, and a list of per-field overrides. The process is transactional and updates the operation's mapping configuration in the database. The runtime system then uses this configuration to transform response field names, following a resolution chain of per-field override → operation-level mode → system default → original source name.
The apply method executes the following sequence:
operationOverride mode is normalized. It is trimmed of whitespace, and if not null or empty, it is matched case-insensitively against a set of canonical modes. If a match is found, the canonical form is used. If no match is found, an error is thrown.operationId. It then validates that the operation's parent service version is in a mutable state (status is "draft" and it is not active). If the version is active or not a draft, changes are rejected to preserve the integrity of active API versions.s2r_operation_mapping table.fieldOverrides is merged into the existing map.
soapXPath is used as the key.name is null or an empty string, the entry for that soapXPath is removed from the map. This allows for clearing a specific override.name is provided, it is validated to ensure it is a valid field name before being added to or updated in the map.s2r_operation_mapping table for the specified operation.ApplyResult object is returned, containing the final configured state.The following diagram illustrates the logical flow of the apply method:
flowchart TD
subgraph FieldCasingApplyService
A[Call apply()] --> B{Normalize Mode};
B --> C[Load Operation Metadata];
C --> D{Is Service Version Mutable?};
D -- No --> E[Throw S2R-ADM-0410];
D -- Yes --> F[Read Existing Field Overrides];
F --> G[Merge New Field Overrides];
G --> H{Validate Field Names};
H -- Invalid --> I[Throw S2R-VAL-0499];
H -- Valid --> J[Update Operation Mapping in Database];
J --> K{Update Successful?};
K -- No --> L[Throw S2R-ADM-0404];
K -- Yes --> M[Return ApplyResult];
end
style E fill:#f99,stroke:#333,stroke-width:2px
style I fill:#f99,stroke:#333,stroke-width:2px
style L fill:#f99,stroke:#333,stroke-width:2pxIMPORTANT
This operation can only be performed on service versions that are in a draft state and are not active. Attempting to modify an active or non-draft version will result in a mapping-immutable error.
The service provides a single public method, apply.
applyApplies a global casing mode and a set of per-field name overrides to an operation.
ApplyResult apply(UUID operationId, String operationOverride, List<FieldEntry> fieldOverrides)
| Name | Type | Required | Description |
|---|---|---|---|
operationId | UUID | Yes | The unique identifier for the operation to modify. |
operationOverride | String | No | The global casing mode to apply to all fields in the operation's response that do not have a specific override. If null or empty, no operation-level override is set. The value is matched case-insensitively against a list of valid modes. The source does not specify the list of VALID_MODES. |
fieldOverrides | List<FieldEntry> | No | A list of FieldEntry objects for per-field casing overrides. If null, the existing per-field overrides are not changed (unless operationOverride is also being set). |
Returns an ApplyResult object upon successful update.
| Field | Type | Description |
|---|---|---|
operationId | UUID | The ID of the operation that was updated. |
operationKey | String | A non-unique, human-readable key for the operation. |
operationOverride | String | The canonical, normalized casing mode that was applied. |
responseFieldCasing | Map<String, String> | The complete, merged map of per-field overrides (soapXPath to name). |
FieldEntry Data StructureThe fieldOverrides parameter is a list of FieldEntry objects, each defining a single field override.
| Field | Type | Required | Description |
|---|---|---|---|
soapXPath | String | Yes | The XPath expression identifying the field in the source SOAP message. This is the key for the override. Null or blank soapXPath values in the list are ignored. |
name | String | No | The desired field name in the API response. If null or an empty string, any existing override for the given soapXPath will be removed. The name must start with a letter or underscore and contain only alphanumeric characters, hyphens, or underscores. The source does not specify the maximum length (MAX_NAME_LENGTH). |
While the source does not provide a complete, runnable example, the following illustrates the conceptual usage based on the service's logic.
To set a global camelCase mode for an operation and simultaneously define a custom name for a specific field, you would invoke apply like this:
operationId: a1b2c3d4-e5f6-7890-1234-567890abcdefoperationOverride: "camelCase"fieldOverrides: A list containing one FieldEntry with:
soapXPath: //data/Transaction/USER_IDname: transactionUserIdTo later clear the override for USER_ID without affecting the global mode, you would make another call with:
operationId: a1b2c3d4-e5f6-7890-1234-567890abcdefoperationOverride: null (or the current value if you don't want to change it)fieldOverrides: A list containing one FieldEntry with:
soapXPath: //data/Transaction/USER_IDname: nullThis removes the //data/Transaction/USER_ID key from the stored override map, causing it to fall back to the camelCase rule defined by operationOverride.
When a call to the apply method fails, it throws an ApplyValidationException containing a machine-readable code and a descriptive message.
| Code | Message Prefix | Cause |
|---|---|---|
S2R-VAL-0499 | invalid-field-casing-mode | The operationOverride string is not one of the allowed values. The source does not list the valid modes. |
S2R-VAL-0499 | invalid-field-casing-name | A name in one of the FieldEntry objects is invalid. It must be non-empty, start with a letter or underscore, and contain only alphanumeric characters, -, or _. The length must not exceed a system-defined maximum. |
S2R-VAL-0499 | invalid-field-casing-map | An internal error occurred while serializing the merged field override map to JSON. |
S2R-ADM-0404 | operation-not-found | The provided operationId does not exist. |
S2R-ADM-0404 | no-active-operation-mapping | The operationId is valid, but no active mapping record was found to update. This can indicate a data inconsistency or an issue with the operation's setup. |
S2R-ADM-0410 | mapping-immutable | The operation belongs to a service version that is not in a draft state or is currently active. Configuration for active or non-draft versions cannot be modified. |