nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: networknt/json-schema-validator
Pull request #156 (2019-05-29 15:00:06)

Fix 24-hour validation error
Related issue: https://github.com/networknt/json-schema-validator/issues/155

Changed the time pattern from 12-hour pattern to 24-hour pattern


Patch:
diff --git a/src/main/java/com/networknt/schema/DateTimeValidator.java b/src/main/java/com/networknt/schema/DateTimeValidator.java
index 179de39..3b7d920 100644
--- a/src/main/java/com/networknt/schema/DateTimeValidator.java
+++ b/src/main/java/com/networknt/schema/DateTimeValidator.java
@@ -103,7 +103,7 @@ public class DateTimeValidator extends BaseJsonValidator implements JsonValidato
             minute = matcher.group(6);
             second = matcher.group(7);
             dateTime.append('T').append(hour).append(':').append(minute).append(':').append(second);
-            pattern.append("'T'hh:mm:ss");
+            pattern.append("'T'HH:mm:ss");
             if (matcher.group(8) != null) {
                 // Normalize milliseconds to 3-length digit
                 milliseconds = matcher.group(8);


Test patch:
diff --git a/src/test/resources/tests/optional/format.json b/src/test/resources/tests/optional/format.json
index 99d1746..82bfd7e 100644
--- a/src/test/resources/tests/optional/format.json
+++ b/src/test/resources/tests/optional/format.json
@@ -8,6 +8,21 @@
                 "data": "1963-06-19T08:30:06.283185Z",
                 "valid": true
             },
+            {
+                "description": "a valid date-time string",
+                "data": "2019-07-24T00:00:01-04:00",
+                "valid": true
+            },
+            {
+                "description": "an invalid date-time string",
+                "data": "2019-07-24T24:00:01-04:00",
+                "valid": false
+            },
+            {
+                "description": "an invalid date-time string",
+                "data": "2019-07-24T25/:00:01-04:00",
+                "valid": false
+            },
             {
                 "description": "an invalid date-time string",
                 "data": "06/19/1963 08:30:06 PST",
@@ -59,9 +74,9 @@
                 "valid": false
             },
             {
-                "description": "an invalid date-time string",
+                "description": "a valid date-time string",
                 "data": "2019-02-28T13:30:06Z",
-                "valid": false
+                "valid": true
             },
             {
                 "description": "an invalid date-time string",
Repository: networknt/json-schema-validator
Pull request #417 (2021-07-01 16:08:55)

Fix for StackOverFlowErrors occurring in case of circular $ref validators
Fixes https://github.com/networknt/json-schema-validator/issues/416 my marking each JsonSchema as being initialized


Patch:
diff --git a/src/main/java/com/networknt/schema/JsonSchema.java b/src/main/java/com/networknt/schema/JsonSchema.java
index b036f03..1050c95 100644
--- a/src/main/java/com/networknt/schema/JsonSchema.java
+++ b/src/main/java/com/networknt/schema/JsonSchema.java
@@ -47,6 +47,7 @@ public class JsonSchema extends BaseJsonValidator {
     private final String idKeyword;
     private final ValidationContext validationContext;
     private WalkListenerRunner keywordWalkListenerRunner;
+    private boolean validatorsLoaded = false;
 
     /**
      * This is the current uri of this schema. This uri could refer to the uri of this schema's file
@@ -423,8 +424,11 @@ public class JsonSchema extends BaseJsonValidator {
      * instances of the validators.</p>
      */
     public void initializeValidators() {
-        for (final JsonValidator validator : getValidators().values()) {
-            validator.preloadJsonSchema();
+        if (!validatorsLoaded) {
+            validatorsLoaded = true;
+            for (final JsonValidator validator : getValidators().values()) {
+                validator.preloadJsonSchema();
+            }
         }
     }
 }


Test patch:
diff --git a/src/test/java/com/networknt/schema/Issue406Test.java b/src/test/java/com/networknt/schema/Issue406Test.java
index b677bf4..c44aab1 100644
--- a/src/test/java/com/networknt/schema/Issue406Test.java
+++ b/src/test/java/com/networknt/schema/Issue406Test.java
@@ -9,6 +9,8 @@ import org.junit.function.ThrowingRunnable;
 
 public class Issue406Test {
     protected static final String INVALID_$REF_SCHEMA = "{\"$ref\":\"urn:unresolved\"}";
+    protected static final String CIRCULAR_$REF_SCHEMA = "{\"$ref\":\"#/nestedSchema\","
+            + "\"nestedSchema\":{\"$ref\":\"#/nestedSchema\"}}";
 
     @Test
     public void testPreloadingNotHappening() {
@@ -31,4 +33,11 @@ public class Issue406Test {
                                 }
                             });
     }
+
+    @Test
+    public void testPreloadingHappeningForCircularDependency() {
+        final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7);
+        final JsonSchema schema = factory.getSchema(CIRCULAR_$REF_SCHEMA);
+        schema.initializeValidators();
+    }
 }
Repository: networknt/json-schema-validator
Pull request #480 (2021-11-10 09:30:36)

issue-478 : Time format validation supports milliseconds
PR changes regex pattern for time to "^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?$"


Patch:
diff --git a/src/main/java/com/networknt/schema/JsonMetaSchema.java b/src/main/java/com/networknt/schema/JsonMetaSchema.java
index 1f3a356..2bef733 100644
--- a/src/main/java/com/networknt/schema/JsonMetaSchema.java
+++ b/src/main/java/com/networknt/schema/JsonMetaSchema.java
@@ -40,7 +40,7 @@ public class JsonMetaSchema {
 
     // this section contains formats that is common for all specification versions.
     static {
-        COMMON_BUILTIN_FORMATS.add(pattern("time", "^\\d{2}:\\d{2}:\\d{2}$"));
+        COMMON_BUILTIN_FORMATS.add(pattern("time", "^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?$"));
         COMMON_BUILTIN_FORMATS.add(pattern("ip-address",
                 "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"));
         COMMON_BUILTIN_FORMATS.add(pattern("ipv4",


Test patch:
diff --git a/src/test/java/com/networknt/schema/JsonMetaSchemaTest.java b/src/test/java/com/networknt/schema/JsonMetaSchemaTest.java
new file mode 100644
index 0000000..e8da4de
--- /dev/null
+++ b/src/test/java/com/networknt/schema/JsonMetaSchemaTest.java
@@ -0,0 +1,27 @@
+package com.networknt.schema;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class JsonMetaSchemaTest {
+
+	@Test
+	void timeFormatValidation() {
+		Format timeFormat = null;
+		for (Format commonBuiltinFormat : JsonMetaSchema.COMMON_BUILTIN_FORMATS) {
+			if ("time".equals(commonBuiltinFormat.getName())) {
+				timeFormat = commonBuiltinFormat;
+			}
+		}
+		if (timeFormat == null) {
+			throw new IllegalArgumentException("time format not found");
+		}
+
+		assertTrue(timeFormat.matches("14:16:23"));
+		assertTrue(timeFormat.matches("14:16:23.123456"));
+		assertFalse(timeFormat.matches("14:16:23."));
+
+	}
+
+}
\ No newline at end of file