-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Closed
Description
Version: io.swagger.vore.v3:swagger-core:2.1.1
The model resolver is skipping properties in the specific scenario:
- there's a resource returning class A
- class A contains property of type: collection of B
- class B contains property of type: collection of B
The B collection property is missing in the schema definition
Below code example, that reproduces the issue.
DataResponse has property buckets
(List<BucketResponse>
).
BucketResponse has property buckets
(List<BucketResponse>
).
The BucketResponse.buckets
property is missing in the OpenAPI schema.
package swagger.model.issue;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.List;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.jaxrs2.integration.XmlWebOpenApiContext;
import io.swagger.v3.oas.integration.SwaggerConfiguration;
import io.swagger.v3.oas.models.OpenAPI;
import static java.util.Collections.singleton;
public class SwaggerModelIssueTest {
public static void main(String[] args) throws Exception {
SwaggerConfiguration oasConfig = new SwaggerConfiguration()
.resourcePackages(singleton("swagger.model.issue"))
.readAllResources(true);
OpenAPI openAPI =
new XmlWebOpenApiContext<>().openApiConfiguration(oasConfig)
.init()
.read();
System.out.println(Json.pretty(openAPI));
assert(openAPI.getComponents().getSchemas().get("BucketResponse").getProperties().containsKey("buckets"));
}
public static class DataResponse {
private String value;
private List<BucketResponse> buckets;
public String getValue() {
return value;
}
public List<BucketResponse> getBuckets() {
return buckets;
}
}
public static class BucketResponse {
private String value;
private List<BucketResponse> buckets;
public String getValue() {
return value;
}
public List<BucketResponse> getBuckets() {
return buckets;
}
}
@Path("/data")
@Produces(MediaType.APPLICATION_JSON)
public static class DataResource {
@POST
@Path("/")
public DataResponse getData() {
return new DataResponse();
}
}
}
Metadata
Metadata
Assignees
Labels
No labels