Skip to content

Commit 90760b2

Browse files
committed
fix tests
1 parent bbc19ba commit 90760b2

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public class OpenAPIDeserializer {
139139
private static final String REFERENCE_SEPARATOR = "#/";
140140
private Components components;
141141
private final Set<String> operationIDs = new HashSet<>();
142-
private List<String> internalProperties = new ArrayList();
142+
private Map<String,String> localSchemaRefs = new HashMap<>();
143143

144144
public SwaggerParseResult deserialize(JsonNode rootNode) {
145145
return deserialize(rootNode, null);
@@ -185,9 +185,9 @@ public OpenAPI parseRoot(JsonNode node, ParseResult result, String path) {
185185
Components components = getComponents(obj, "components", result);
186186
openAPI.setComponents(components);
187187
this.components = components;
188-
for (String schema : internalProperties){
188+
for (String schema : localSchemaRefs.keySet()){
189189
if(components.getSchemas().get(schema) == null){
190-
result.missing("components.schemas",schema);
190+
result.invalidType(localSchemaRefs.get(schema), schema, "schema", rootNode);
191191
}
192192
}
193193
}
@@ -2300,7 +2300,7 @@ public Schema getSchema(ObjectNode node, String location, ParseResult result) {
23002300
}
23012301
if(schema.get$ref().startsWith("#/components/schemas")){// it's internal
23022302
String refName = schema.get$ref().substring(schema.get$ref().lastIndexOf("/")+1);
2303-
internalProperties.add(refName);
2303+
localSchemaRefs.put(refName,location);
23042304
}
23052305
return schema;
23062306
} else {

modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public void testIssue1643() throws Exception{
125125
Assert.assertNotNull(result);
126126
Assert.assertNotNull(result.getOpenAPI());
127127
assertEquals(result.getMessages().size(),1);
128-
assertTrue(result.getMessages().contains("attribute components.schemas.Employee is missing"));
128+
assertTrue(result.getMessages().contains("attribute components.schemas.Person.Employee is not of type `schema`"));
129129
}
130130

131131
@Test
@@ -328,7 +328,7 @@ public void testCantReadDeepProperties() {
328328
options.setResolveFully(true);
329329

330330
final SwaggerParseResult parseResult = parser.readLocation("src/test/resources/cant-read-deep-properties.yaml", null, options);
331-
assertEquals(parseResult.getMessages().size(), 0);
331+
assertEquals(parseResult.getMessages().size(), 1);
332332
Schema projects = (Schema) parseResult.getOpenAPI().getComponents().getSchemas().get("Project").getProperties().get("project_type");
333333
assertEquals(projects.getType(), "integer");
334334
}
@@ -2511,7 +2511,7 @@ public void testIssue931() {
25112511
SwaggerParseResult result = new OpenAPIV3Parser().readLocation("Issue_931.json", null, options);
25122512
assertNotNull(result.getOpenAPI());
25132513
assertTrue(result.getMessages().size() > 0);
2514-
assertEquals(result.getMessages().get(0).contains("doesn't adhere to regular expression ^[a-zA-Z0-9\\.\\-_]+$"), true);
2514+
assertEquals(result.getMessages().get(1).contains("doesn't adhere to regular expression ^[a-zA-Z0-9\\.\\-_]+$"), true);
25152515

25162516
}
25172517

0 commit comments

Comments
 (0)