Skip to content

Commit bbbabc3

Browse files
authored
Merge pull request #950 from swagger-api/revert-923-branch_test
Revert "Fix for issue 922"
2 parents 386162d + cc38988 commit bbbabc3

File tree

3 files changed

+7
-223
lines changed

3 files changed

+7
-223
lines changed

modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -766,11 +766,6 @@ public String getString(String key, ObjectNode node, boolean required, String lo
766766
return getString(key, node, required, location, result, null);
767767
}
768768

769-
public String getStringWithDefaultValueSet(String key, ObjectNode node, boolean required, String location, ParseResult result) {
770-
771-
return getString(key, node, required, location, result, null);
772-
}
773-
774769
public Set<String> getKeys(ObjectNode node) {
775770
Set<String> keys = new LinkedHashSet<>();
776771
if (node == null) {
@@ -1325,23 +1320,6 @@ public Boolean getBoolean(String key, ObjectNode node, boolean required, String
13251320
return value;
13261321
}
13271322

1328-
public Boolean getBooleanWithDefaultValue(String key, ObjectNode node, String location) {
1329-
Boolean value = null;
1330-
JsonNode v = node.get(key);
1331-
if (node == null || v == null) {
1332-
return false;
1333-
} else {
1334-
if (v.getNodeType().equals(JsonNodeType.BOOLEAN)) {
1335-
value = v.asBoolean();
1336-
} else if (v.getNodeType().equals(JsonNodeType.STRING)) {
1337-
String stringValue = v.textValue();
1338-
return Boolean.parseBoolean(stringValue);
1339-
}
1340-
}
1341-
return value;
1342-
}
1343-
1344-
13451323
public BigDecimal getBigDecimal(String key, ObjectNode node, boolean required, String location, ParseResult result) {
13461324
BigDecimal value = null;
13471325
JsonNode v = node.get(key);
@@ -1496,7 +1474,7 @@ public Parameter getParameter(ObjectNode obj, String location, ParseResult resul
14961474
parameter.setDescription(value);
14971475
}
14981476

1499-
Boolean required = getBooleanWithDefaultValue("required", obj, location);
1477+
Boolean required = getBoolean("required", obj, false, location, result);
15001478
if (required != null) {
15011479
parameter.setRequired(required);
15021480
}else {
@@ -2256,7 +2234,6 @@ public Schema getSchema(ObjectNode node, String location, ParseResult result){
22562234
schema.setDefault(value);
22572235
}
22582236

2259-
22602237
//discriminator
22612238

22622239
bool = getBoolean("nullable", node, false, location, result);
@@ -2295,12 +2272,11 @@ public Schema getSchema(ObjectNode node, String location, ParseResult result){
22952272
schema.setExample(example);
22962273
}
22972274

2298-
bool = getBooleanWithDefaultValue("deprecated", node, location);
2275+
bool = getBoolean("deprecated", node, false, location, result);
22992276
if(bool != null){
23002277
schema.setDeprecated(bool);
23012278
}
23022279

2303-
23042280
Map <String,Object> extensions = getExtensions(node);
23052281
if(extensions != null && extensions.size() > 0) {
23062282
schema.setExtensions(extensions);
@@ -2621,7 +2597,7 @@ public Operation getOperation(ObjectNode obj, String location, ParseResult resul
26212597
operation.setCallbacks(callbacks);
26222598
}
26232599

2624-
Boolean deprecated = getBooleanWithDefaultValue("deprecated", obj, location);
2600+
Boolean deprecated = getBoolean("deprecated", obj, false, location, result);
26252601
if (deprecated != null) {
26262602
operation.setDeprecated(deprecated);
26272603
}

modules/swagger-parser/src/test/java/io/swagger/parser/OpenAPIParserTest.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33

44

5-
6-
import com.sun.org.apache.xpath.internal.operations.Bool;
75
import io.swagger.v3.core.util.Yaml;
86
import io.swagger.v3.oas.models.Components;
97
import io.swagger.v3.oas.models.OpenAPI;
@@ -24,7 +22,10 @@
2422

2523
import java.util.List;
2624

27-
import static org.testng.Assert.*;
25+
26+
import static org.testng.Assert.assertEquals;
27+
import static org.testng.Assert.assertNotNull;
28+
import static org.testng.Assert.assertTrue;
2829

2930
public class OpenAPIParserTest {
3031
@Test
@@ -461,14 +462,4 @@ public void testIssue879() {
461462
assertEquals(ref, "#/components/callbacks/callbackEvent");
462463
}
463464

464-
@Test
465-
public void testIssue922() {
466-
OpenAPIParser openAPIParser = new OpenAPIParser();
467-
ParseOptions options = new ParseOptions();
468-
OpenAPI openAPI = openAPIParser.readLocation("petstore.json",null,null).getOpenAPI();
469-
assertNotNull(openAPI);
470-
assertEquals(openAPI.getComponents().getSchemas().get("Pet").getDeprecated(),Boolean.FALSE);
471-
472-
}
473-
474465
}

modules/swagger-parser/src/test/resources/petstore.json

Lines changed: 0 additions & 183 deletions
This file was deleted.

0 commit comments

Comments
 (0)