Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,13 @@ public boolean equals(Object o) {
AnnotatedType that = (AnnotatedType) o;
List<Annotation> thisAnnotations = getProcessedAnnotations(this.ctxAnnotations);
List<Annotation> thatAnnotations = getProcessedAnnotations(that.ctxAnnotations);
String thisParentName = this.parent != null ? this.parent.getName() : null;
String thatParentName = that.parent != null ? that.parent.getName() : null;

return includePropertiesWithoutJSONView == that.includePropertiesWithoutJSONView &&
schemaProperty == that.schemaProperty &&
isSubtype == that.isSubtype &&
(!schemaProperty || Objects.equals(thisParentName, thatParentName)) &&
Objects.equals(type, that.type) &&
Objects.equals(thisAnnotations, thatAnnotations) &&
Objects.equals(jsonViewAnnotation, that.jsonViewAnnotation) &&
Expand All @@ -289,7 +293,8 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
List<Annotation> processedAnnotations = getProcessedAnnotations(this.ctxAnnotations);
return Objects.hash(type, jsonViewAnnotation, includePropertiesWithoutJSONView, processedAnnotations, schemaProperty, isSubtype, schemaProperty ? propertyName : null);
String parentName = (schemaProperty && this.parent != null) ? this.parent.getName() : null;
return Objects.hash(type, jsonViewAnnotation, includePropertiesWithoutJSONView, processedAnnotations, schemaProperty, isSubtype, schemaProperty ? propertyName : null, parentName);
}

private boolean processableAnnotationPackage(Package pkg) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package io.swagger.v3.core.resolving;

import io.swagger.v3.core.converter.ModelConverters;
import io.swagger.v3.oas.models.media.Schema;
import org.testng.annotations.Test;

import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;

import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertEquals;

public class RecursivePropertyMissingTest {

static class WrapperDTO {
@JsonProperty("nodes")
@JsonPropertyDescription("Child nodes")
public List<TestNodeDTO> nodes;
}

static class TestNodeDTO {
@JsonProperty("name")
public String name;

@JsonProperty("nodes")
@JsonPropertyDescription("Child nodes")
public List<TestNodeDTO> nodes;
}

@Test
public void testRecursivePropertyNotMissing() {
Map<String, Schema> schemas = ModelConverters.getInstance().readAll(WrapperDTO.class);
Schema testNodeDTOSchema = schemas.get("TestNodeDTO");
assertNotNull(testNodeDTOSchema);

Map<String, Schema> properties = testNodeDTOSchema.getProperties();
assertNotNull(properties, "Properties should not be null");
assertNotNull(properties.get("nodes"), "The 'nodes' property is missing from TestNodeDTO schema");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@
},
"friend" : {
"type" : "string"
},
"baseArray" : {
"minItems" : 0,
"uniqueItems" : true,
"type" : "array",
"description" : "Thingy",
"items" : {
"$ref" : "#/components/schemas/Base"
}
}
},
"description" : "The SubB class"
Expand Down