File tree Expand file tree Collapse file tree
mcp-core/src/main/java/io/modelcontextprotocol/spec
mcp-json-jackson2/src/main/java/io/modelcontextprotocol/json/schema/jackson2
mcp-json-jackson3/src/main/java/io/modelcontextprotocol/json/schema/jackson3 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111 * defines a method to validate structured content based on the provided output schema.
1212 *
1313 * @author Christian Tzolov
14+ * @deprecated Use {@link io.modelcontextprotocol.json.schema.JsonSchemaValidator}
1415 */
16+ @ Deprecated
1517public interface JsonSchemaValidator {
1618
1719 /**
Original file line number Diff line number Diff line change 33 */
44package io .modelcontextprotocol .json .schema .jackson2 ;
55
6- import java .io .IOException ;
7- import java .io .InputStream ;
86import java .util .List ;
97import java .util .Map ;
108import java .util .concurrent .ConcurrentHashMap ;
119
10+ import com .networknt .schema .SchemaLocation ;
1211import io .modelcontextprotocol .util .Assert ;
1312import org .slf4j .Logger ;
1413import org .slf4j .LoggerFactory ;
@@ -52,23 +51,8 @@ public DefaultJsonSchemaValidator(ObjectMapper objectMapper) {
5251 this .objectMapper = objectMapper ;
5352 this .schemaFactory = SchemaRegistry .withDefaultDialect (Dialects .getDraft202012 ());
5453 this .schemaCache = new ConcurrentHashMap <>();
55- this .metaSchema202012 = loadMetaSchema ();
56- }
57-
58- private Schema loadMetaSchema () {
59- try (InputStream stream = getClass ().getClassLoader ().getResourceAsStream ("draft/2020-12/schema" )) {
60- if (stream == null ) {
61- logger .warn (
62- "JSON Schema 2020-12 meta-schema not found on classpath; schema conformance checking disabled" );
63- return null ;
64- }
65- return this .schemaFactory .getSchema (stream );
66- }
67- catch (IOException e ) {
68- logger .warn ("Failed to load JSON Schema 2020-12 meta-schema: {}; schema conformance checking disabled" ,
69- e .getMessage ());
70- return null ;
71- }
54+ this .metaSchema202012 = schemaFactory
55+ .getSchema (SchemaLocation .of ("https://json-schema.org/draft/2020-12/schema" ));
7256 }
7357
7458 @ Override
Original file line number Diff line number Diff line change 33 */
44package io .modelcontextprotocol .json .schema .jackson3 ;
55
6- import java .io .IOException ;
7- import java .io .InputStream ;
86import java .util .List ;
97import java .util .Map ;
108import java .util .concurrent .ConcurrentHashMap ;
119
1210import com .networknt .schema .Schema ;
11+ import com .networknt .schema .SchemaLocation ;
1312import com .networknt .schema .SchemaRegistry ;
1413import com .networknt .schema .Error ;
1514import com .networknt .schema .dialect .Dialects ;
@@ -51,23 +50,8 @@ public DefaultJsonSchemaValidator(JsonMapper jsonMapper) {
5150 this .jsonMapper = jsonMapper ;
5251 this .schemaFactory = SchemaRegistry .withDefaultDialect (Dialects .getDraft202012 ());
5352 this .schemaCache = new ConcurrentHashMap <>();
54- this .metaSchema202012 = loadMetaSchema ();
55- }
56-
57- private Schema loadMetaSchema () {
58- try (InputStream stream = getClass ().getClassLoader ().getResourceAsStream ("draft/2020-12/schema" )) {
59- if (stream == null ) {
60- logger .warn (
61- "JSON Schema 2020-12 meta-schema not found on classpath; schema conformance checking disabled" );
62- return null ;
63- }
64- return this .schemaFactory .getSchema (stream );
65- }
66- catch (IOException e ) {
67- logger .warn ("Failed to load JSON Schema 2020-12 meta-schema: {}; schema conformance checking disabled" ,
68- e .getMessage ());
69- return null ;
70- }
53+ this .metaSchema202012 = schemaFactory
54+ .getSchema (SchemaLocation .of ("https://json-schema.org/draft/2020-12/schema" ));
7155 }
7256
7357 @ Override
You can’t perform that action at this time.
0 commit comments