Package org.forgerock.openig.mcp.jsonrpc
Class JsonRpcPayload
java.lang.Object
org.forgerock.openig.mcp.jsonrpc.JsonRpcPayload
- Direct Known Subclasses:
JsonRpcRequest,JsonRpcResponse
Validates JSON-RPC 2.0 content.
Since this validator is primarily intended to be used in an MCP context it has several limitations:
- it does not accept batch requests
- it does not accept null valued IDs in requests.
- it does not accept system extensions methods (those starting with "rpc.")
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JsonValueThe lazy JSON value representation of the payload.protected final com.fasterxml.jackson.databind.JsonNodeThe JSON-RPC payload. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJsonRpcPayload(com.fasterxml.jackson.databind.JsonNode payload) Constructs a new JsonRpcMessage, with no validation.protectedJsonRpcPayload(com.fasterxml.jackson.databind.JsonNode payload, McpSchemas.NamedJsonSchema validationSchema) Constructs a new JsonRpcMessage. -
Method Summary
Modifier and TypeMethodDescriptionReturns the JSON-RPC message as JSON.toJsonRpcMessage(Entity entity) Reads the given entity to a JSON-RPC message.voidvalidate(McpSchemas.NamedJsonSchema schema, JsonRpcResponse.JsonRpcError.JsonRpcErrorCode errorCode) Validates this JSON-RPC message against the given schema.
-
Field Details
-
payload
protected final com.fasterxml.jackson.databind.JsonNode payloadThe JSON-RPC payload. -
lazyJsonValue
The lazy JSON value representation of the payload.
-
-
Constructor Details
-
JsonRpcPayload
protected JsonRpcPayload(com.fasterxml.jackson.databind.JsonNode payload, McpSchemas.NamedJsonSchema validationSchema) throws JsonRpcValidationException Constructs a new JsonRpcMessage.- Parameters:
payload- the JSON-RPC payloadvalidationSchema- the schema to validate against- Throws:
JsonRpcValidationException
-
JsonRpcPayload
protected JsonRpcPayload(com.fasterxml.jackson.databind.JsonNode payload) Constructs a new JsonRpcMessage, with no validation. For internal use only.- Parameters:
payload- the JSON-RPC payload
-
-
Method Details
-
asJsonValue
Returns the JSON-RPC message as JSON.- Returns:
- the JSON-RPC message as JSON
-
validate
public void validate(McpSchemas.NamedJsonSchema schema, JsonRpcResponse.JsonRpcError.JsonRpcErrorCode errorCode) throws JsonRpcValidationException Validates this JSON-RPC message against the given schema.- Parameters:
schema- the schema to validate againsterrorCode- the error code to use in case of validation failure- Throws:
JsonRpcValidationException- if the validation fails
-
toJsonRpcMessage
Reads the given entity to a JSON-RPC message. Fails with aJsonRpcValidationExceptionif the entity does not contain a valid JSON-RPC message.- Parameters:
entity- the entity to read- Returns:
- a promise resolving to the JSON-RPC message
-