Add Support for Jackson 3 (#742)

This change adds Jackson 3 support and aligns package naming in the existing Jackson 2 module.

Specific changes:
* Deprecated classes for removal in `io.modelcontextprotocol.json.jackson`/`io.modelcontextprotocol.json.schema.jackson`
* Copied the above to `io.modelcontextprotocol.json.jackson2`/`io.modelcontextprotocol.json.schema.jackson2` in non-deprecated form.
* Added tests for the default McpJsonMapper and JsonSchemaValidator
This commit is contained in:
Filip Hrisafov 2026-01-26 11:43:35 +01:00 • committed by GitHub
commit 2456a0e433
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,6 +10,7 @@ import static net.javacrumbs.jsonunit.assertj.JsonAssertions.json;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
@ -18,7 +19,7 @@ import java.util.Map;
import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.databind.exc.InvalidTypeIdException;
import tools.jackson.databind.exc.InvalidTypeIdException;
import io.modelcontextprotocol.spec.McpSchema.TextResourceContents;
import net.javacrumbs.jsonunit.core.Option;
@ -58,7 +59,9 @@ public class McpSchemaTests {
void testContentDeserializationWrongType() throws Exception {
assertThatThrownBy(() -> JSON_MAPPER.readValue("""
{"type":"WRONG","text":"XXX"}""", McpSchema.TextContent.class))
{"type":"WRONG","text":"XXX"}""", McpSchema.TextContent.class)).isInstanceOf(IOException.class)
.hasMessage("Failed to read value")
.cause()
.isInstanceOf(InvalidTypeIdException.class)
.hasMessageContaining(
"Could not resolve type id 'WRONG' as a subtype of `io.modelcontextprotocol.spec.McpSchema$TextContent`: known type ids = [audio, image, resource, resource_link, text]");