Apply Operation-Level Envelope Wrap Overrides
Apply an envelope wrap override to a specific API operation. This service updates the configuration for an operation if its service version is in a draft
Overview
The Envelope Wrap Apply Service provides a mechanism for API publishers to apply a specific envelope wrapping behavior to a single API operation. This setting overrides any system-level default wrap behavior for that specific operation. The service is designed for operation-level granularity; it does not support per-field overrides, as envelope wrapping is a body-level transformation.
This service acts as the designated writer for the envelope_wrap_override setting on an operation's mapping. The platform's runtime component consumes this setting as part of a resolution chain to determine the final wrap behavior, checking for an override in the following order: operation-level, system-level, and finally a default of 'raw'.
An override can only be applied to an operation belonging to a service version that is in a draft state. Operations within active service versions are immutable.
How it works
When an API publisher invokes the apply service, it performs a sequence of validation and persistence steps to update the operation's envelope wrap override.
sequenceDiagram
participant API Publisher
participant EnvelopeWrapApplyService
participant Database
API Publisher->>EnvelopeWrapApplyService: apply(operationId, operationOverride)
activate EnvelopeWrapApplyService
EnvelopeWrapApplyService->>EnvelopeWrapApplyService: Normalize override value
Note right of EnvelopeWrapApplyService: Handles nulls, trims whitespace, and<br/>matches case-insensitively against valid modes.
EnvelopeWrapApplyService->>Database: Query operation and service version metadata
activate Database
Database-->>EnvelopeWrapApplyService: Return operationKey, versionStatus, versionActive
deactivate Database
alt Operation not found
EnvelopeWrapApplyService-->>API Publisher: Throw ApplyValidationException (S2R-ADM-0404)
end
EnvelopeWrapApplyService->>EnvelopeWrapApplyService: Validate service version is mutable
Note right of EnvelopeWrapApplyService: Must be in 'draft' status and not active.
alt Version is immutable
EnvelopeWrapApplyService-->>API Publisher: Throw ApplyValidationException (S2R-ADM-0410)
end
EnvelopeWrapApplyService->>Database: UPDATE s2r_operation_mapping SET envelope_wrap_override
activate Database
Database-->>EnvelopeWrapApplyService: Return count of updated rows
deactivate Database
alt No active mapping found
EnvelopeWrapApplyService-->>API Publisher: Throw ApplyValidationException (S2R-ADM-0404)
end
EnvelopeWrapApplyService->>API Publisher: Return ApplyResult
deactivate EnvelopeWrapApplyServiceThe process is as follows:
- Normalization: The input
operationOverridestring is normalized. It is trimmed of whitespace and compared case-insensitively against a list of valid modes. If a valid mode is found, its canonical form is used. Passingnullor an empty string clears the override. If the input value is not a valid mode, the service throws an exception. - Metadata Retrieval: The service queries the database for metadata associated with the
operationId, including itsoperation_keyand the status of its parent service version. If the operation cannot be found, an exception is thrown. - Mutability Validation: The service checks if the operation's parent service version is mutable. An operation can only be modified if its service version has a status of
draftand is not active. If the version is active or has a different status, the service throws an exception. - Persistence: The service executes a SQL
UPDATEstatement to set theenvelope_wrap_overridevalue on thes2r_operation_mappingtable for the specifiedoperation_id. The update only targets active mappings (is_active = true). - Result: If the update is successful (i.e., exactly one row is updated), the service returns an
ApplyResultobject containing theoperationId,operationKey, and the normalized override value that was persisted. If no active mapping is found to update, an exception is thrown.
Service Method Reference
The service exposes a single method, apply.
apply
apply(UUID operationId, String operationOverride)
Applies or clears an envelope wrap override for a specific operation. The change is persisted to the s2r_operation_mapping table.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
operationId | UUID | Yes | The unique identifier for the operation to modify. |
operationOverride | String | No | The desired envelope wrap mode. Valid modes are matched case-insensitively (e.g., data-key-only). The source does not specify the complete list of valid modes. Providing null or an empty string will clear any existing override. |
IMPORTANT
An operation can only be modified if its parent service version is in a draft state. Attempting to modify an operation in an active service version will result in a mapping-immutable error.
Returns
On success, the method returns an ApplyResult object with the following fields:
| Field | Type | Description |
|---|---|---|
operationId | UUID | The unique identifier of the operation that was updated. |
operationKey | String | The key of the operation that was updated. |
operationOverride | String | The normalized, canonical override value that was stored. |
Throws
ApplyValidationException: Thrown if the input is invalid or the operation cannot be modified. See the Troubleshooting section for specific error codes and conditions.
Troubleshooting
When a call to the apply service fails, it throws an ApplyValidationException containing a machine-readable error code.
| Error Code | Trigger |
|---|---|
S2R-VAL-0499 | The operationOverride string is not one of the recognized valid modes. |
S2R-ADM-0404 | This code indicates a resource was not found. It can be triggered in two scenarios:<br>1. The provided operationId does not match any existing operation.<br>2. The operation exists, but it has no active mapping (is_active = true) in the s2r_operation_mapping table to update. |
S2R-ADM-0410 | The operation's parent service version is not in a mutable state. This occurs if the service version is active (is_active = true) or its status is not draft. The operation is considered immutable. |
