nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: swagger-api/swagger-parser
Pull request #1110 (2019-05-29 23:11:31)

fix for Parameter.allowReserved is always null - issue #1108


Patch:
diff --git a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java
index 5455714e..92274410 100644
--- a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java
+++ b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java
@@ -1568,6 +1568,11 @@ public class OpenAPIDeserializer {
             parameter.setExample(example);
         }
 
+        Boolean allowReserved = getBoolean("allowReserved", obj, false, location, result);
+        if (allowReserved != null) {
+            parameter.setAllowReserved(allowReserved);
+        }
+
         ObjectNode contentNode = getObject("content",obj,false,location,result);
         if(contentNode!= null) {
             parameter.setContent(getContent(contentNode, String.format("%s.%s", location, "content"), result));


Test patch:
diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java
index bae26181..e4181471 100644
--- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java
+++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java
@@ -65,6 +65,15 @@ public class OpenAPIV3ParserTest {
     protected int serverPort = getDynamicPort();
     protected WireMockServer wireMockServer;
 
+
+    @Test
+    public void testIssue1108() {
+        OpenAPIV3Parser parser = new OpenAPIV3Parser();
+        OpenAPI openAPI = parser.read("issue-1108.yaml");
+        assertNotNull(openAPI);
+        assertNotNull(openAPI.getPaths().get("/pets").getGet().getParameters().get(0).getAllowReserved());
+    }
+
     @Test
     public void testRemoteParameterIssue1094(@Injectable final List<AuthorizationValue> auths) throws Exception{
 
diff --git a/modules/swagger-parser-v3/src/test/resources/issue-1108.yaml b/modules/swagger-parser-v3/src/test/resources/issue-1108.yaml
new file mode 100644
index 00000000..03a13f8c
--- /dev/null
+++ b/modules/swagger-parser-v3/src/test/resources/issue-1108.yaml
@@ -0,0 +1,22 @@
+openapi: "3.0.0"
+info:
+  version: 1.0.0
+  title: Swagger petstore
+  license:
+    name: MIT
+servers:
+  - url: http://petstore.swagger.io/v1
+paths:
+  /pets:
+    get:
+      summary: List all pets
+      operationId: listpets
+      tags:
+        - pets
+      parameters:
+        - name: limit
+          in: query
+          allowReserved: false
+      responses:
+        '200':
+          description: A paged array of pets
\ No newline at end of file
Repository: swagger-api/swagger-parser
Pull request #1130 (2019-06-18 22:52:28)

Fixes issue #1129


Patch:
diff --git a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java
index 92274410..259a6281 100644
--- a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java
+++ b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java
@@ -2242,6 +2242,8 @@ public class OpenAPIDeserializer {
             for (JsonNode n : enumArray) {
                 if (n.isNumber()) {
                     schema.addEnumItemObject(n.numberValue());
+                } else if (n.isBoolean()) {
+                    schema.addEnumItemObject(n.booleanValue());
                 } else if (n.isValueNode()) {
                     try {
                         schema.addEnumItemObject( getDecodedObject( schema, n.asText(null)));


Test patch:
diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/OpenAPIDeserializerTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/OpenAPIDeserializerTest.java
index 5e5a10e1..960499d8 100644
--- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/OpenAPIDeserializerTest.java
+++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/OpenAPIDeserializerTest.java
@@ -878,6 +878,8 @@ public class OpenAPIDeserializerTest {
                 "                    $ref: '#/components/schemas/IntegerEnum'\n" +
                 "                  ne:\n" +
                 "                    $ref: '#/components/schemas/NumberEnum'\n" +
+                "                  be:\n" +
+                "                    $ref: '#/components/schemas/BooleanEnum'\n" +
                 "components:\n" +
                 "  schemas:\n" +
                 "    StringEnum:\n" +
@@ -886,6 +888,10 @@ public class OpenAPIDeserializerTest {
                 "      enum:\n" +
                 "        - First\n" +
                 "        - Second\n" +
+                "    BooleanEnum:\n" +
+                "      enum:\n" +
+                "        - true \n" +
+                "        - false \n" +
                 "    IntegerEnum:\n" +
                 "      type: integer\n" +
                 "      default: 1\n" +
@@ -934,6 +940,13 @@ public class OpenAPIDeserializerTest {
         assertEquals(new BigDecimal("1.6161"), numberValues.get(2));
         assertEquals(new BigDecimal("3.14"), numberValues.get(3));
         assertEquals(numberImpl.getDefault(), new BigDecimal("3.14"));
+        
+        Schema booleanModel = resolved.getComponents().getSchemas().get("BooleanEnum");
+        assertEquals("boolean", booleanModel.getType());
+        List<Object> booleanValues = booleanModel.getEnum();
+        assertEquals(2, booleanValues.size());
+        assertEquals(Boolean.TRUE, booleanValues.get(0));
+        assertEquals(Boolean.FALSE, booleanValues.get(1));
     }
 
     @Test
Repository: swagger-api/swagger-parser
Pull request #1295 (2020-01-08 23:33:02)

Inside a content, include the mediaType in the location string.
Issue: https://github.com/swagger-api/swagger-parser/issues/1274


Patch:
diff --git a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java
index 4b29b87e..7c35482e 100644
--- a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java
+++ b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java
@@ -955,7 +955,7 @@ public class OpenAPIDeserializer {
 
         Set<String> keys = getKeys(node);
         for(String key : keys) {
-            MediaType mediaType = getMediaType((ObjectNode) node.get(key), location, result);
+            MediaType mediaType = getMediaType((ObjectNode) node.get(key), String.format("%s.'%s'", location, key), result);
             if (mediaType != null) {
                 content.addMediaType(key, mediaType);
             }


Test patch:
diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/OpenAPIDeserializerTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/OpenAPIDeserializerTest.java
index b95a4d3a..5a00d604 100644
--- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/OpenAPIDeserializerTest.java
+++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/OpenAPIDeserializerTest.java
@@ -791,7 +791,7 @@ public class OpenAPIDeserializerTest {
 
         OpenAPIV3Parser parser = new OpenAPIV3Parser();
         SwaggerParseResult result = parser.readContents(yaml, null, null);
-        assertEquals(result.getMessages(), Arrays.asList("attribute paths.'/store/inventory'(post).requestBody.content.schema.items is missing"));
+        assertEquals(result.getMessages(), Arrays.asList("attribute paths.'/store/inventory'(post).requestBody.content.'application/json'.schema.items is missing"));
         
         OpenAPI openAPI = result.getOpenAPI();
Repository: swagger-api/swagger-parser
Pull request #1317 (2020-02-13 21:11:15)

fix for issue #1316: ContentType in Encoding Object should not be required.
fix for issue #1316

ContentType in Encoding Object should not be required.


Patch:
diff --git a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java
index 8938ce17..6990100c 100644
--- a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java
+++ b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java
@@ -1033,7 +1033,7 @@ public class OpenAPIDeserializer {
 
         Encoding encoding = new Encoding();
 
-        String value = getString("contentType", node, true, location, result);
+        String value = getString("contentType", node, false, location, result);
         encoding.setContentType(value);
 
         value = getString("style", node, false, location, result);


Test patch:
diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java
index 531083c0..8ba91688 100644
--- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java
+++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java
@@ -66,6 +66,19 @@ public class OpenAPIV3ParserTest {
     protected int serverPort = getDynamicPort();
     protected WireMockServer wireMockServer;
 
+    @Test
+    public void testIssue1316() {
+        OpenAPIV3Parser openApiParser = new OpenAPIV3Parser();
+        ParseOptions options = new ParseOptions();
+        options.setResolve(true);
+        SwaggerParseResult parseResult = openApiParser.readLocation("Issue1316.yaml", null, options);
+
+        OpenAPI openAPI = parseResult.getOpenAPI();
+        assertNotNull(openAPI);
+        assertTrue(parseResult.getMessages().size() == 0);
+
+    }
+
 
     @Test
     public void testFlattenComposedSchema() {
diff --git a/modules/swagger-parser-v3/src/test/resources/Issue1316.yaml b/modules/swagger-parser-v3/src/test/resources/Issue1316.yaml
new file mode 100644
index 00000000..845e22a3
--- /dev/null
+++ b/modules/swagger-parser-v3/src/test/resources/Issue1316.yaml
@@ -0,0 +1,25 @@
+---
+openapi: 3.0.1
+info:
+  title: Encoding Issue
+  version: 0.0.2
+paths:
+  "/uploads":
+    post:
+      tags:
+        - Uploads
+      requestBody:
+        content:
+          multipart/form-data:
+            schema:
+              type: object
+              properties:
+                file:
+                  type: string
+                  format: binary
+            encoding:
+              file:
+                style: form
+      responses:
+        '200':
+          description: Success
Repository: swagger-api/swagger-parser
Pull request #1625 (2021-11-10 19:48:41)

add JavaTimeModule to Jackson ObjectMapper
Relates to https://github.com/swagger-api/swagger-parser/issues/1524 - also consistent with swagger-core ObjectMapperFactory that adds JavaTimeModule by default.


Patch:
diff --git a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/ObjectMapperFactory.java b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/ObjectMapperFactory.java
index 1df3fdd5..e6bea970 100644
--- a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/ObjectMapperFactory.java
+++ b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/ObjectMapperFactory.java
@@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
 import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
 
 public class ObjectMapperFactory {
     public static ObjectMapper createJson() {
@@ -28,6 +29,7 @@ public class ObjectMapperFactory {
 
     private static ObjectMapper create(JsonFactory jsonFactory, boolean includePathDeserializer, boolean includeResponseDeserializer) {
         ObjectMapper mapper = new ObjectMapper(jsonFactory);
+        mapper.registerModule(new JavaTimeModule());
 
         mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
         mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);


Test patch:
diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/ObjectMapperTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/ObjectMapperTest.java
new file mode 100644
index 00000000..f16d46c7
--- /dev/null
+++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/ObjectMapperTest.java
@@ -0,0 +1,15 @@
+package io.swagger.v3.parser;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ObjectMapperTest {
+    @Test
+    public void testJavaTimeModule() {
+        ObjectMapper mapper = ObjectMapperFactory.createJson();
+        Assert.assertTrue("JavaTimeModule found?",
+                mapper.getRegisteredModuleIds().contains(new JavaTimeModule().getTypeId()));
+    }
+}
Repository: swagger-api/swagger-parser
Pull request #1710 (2022-04-20 17:41:57)

set validate internal ref option to true by default
set validate internal ref option to true by default


Patch:
diff --git a/modules/swagger-parser-core/src/main/java/io/swagger/v3/parser/core/models/ParseOptions.java b/modules/swagger-parser-core/src/main/java/io/swagger/v3/parser/core/models/ParseOptions.java
index b8cfacdb..65bb3e6b 100644
--- a/modules/swagger-parser-core/src/main/java/io/swagger/v3/parser/core/models/ParseOptions.java
+++ b/modules/swagger-parser-core/src/main/java/io/swagger/v3/parser/core/models/ParseOptions.java
@@ -10,7 +10,7 @@ public class ParseOptions {
     private boolean skipMatches;
     private boolean allowEmptyStrings = true;
     private boolean validateExternalRefs = false;
-    private boolean validateInternalRefs = false;
+    private boolean validateInternalRefs = true;
     private boolean legacyYamlDeserialization = false;
 
     public boolean isResolve() {


Test patch:
diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java
index 0609ea82..e1c5288d 100644
--- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java
+++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java
@@ -88,7 +88,6 @@ public class OpenAPIV3ParserTest {
     @Test
     public void testIssue1643_True() throws Exception{
         ParseOptions options = new ParseOptions();
-        options.setValidateInternalRefs(true);
         String issue1643 = "openapi: \"3.0.0\"\n" +
                 "info:\n" +
                 "  version: 1.0.0\n" +
@@ -132,6 +131,7 @@ public class OpenAPIV3ParserTest {
     @Test
     public void testIssue1643_False() throws Exception{
         ParseOptions options = new ParseOptions();
+        options.setValidateInternalRefs(false);
         String issue1643 = "openapi: \"3.0.0\"\n" +
                 "info:\n" +
                 "  version: 1.0.0\n" +
@@ -370,6 +370,7 @@ public class OpenAPIV3ParserTest {
         OpenAPIV3Parser parser = new OpenAPIV3Parser();
         ParseOptions options = new ParseOptions();
         options.setResolveFully(true);
+        options.setValidateInternalRefs(false);
 
         final SwaggerParseResult parseResult = parser.readLocation("src/test/resources/cant-read-deep-properties.yaml", null, options);
         assertEquals(parseResult.getMessages().size(), 0);
@@ -2552,6 +2553,7 @@ public class OpenAPIV3ParserTest {
     public void testIssue931() {
         ParseOptions options = new ParseOptions();
         options.setResolve(true);
+        options.setValidateInternalRefs(false);
         SwaggerParseResult result = new OpenAPIV3Parser().readLocation("Issue_931.json", null, options);
         assertNotNull(result.getOpenAPI());
         assertTrue(result.getMessages().size() > 0);