use of io.swagger.v3.core.util.RefUtils.extractSimpleName in project swagger-core by swagger-api.
the class SpecFilter method removeBrokenReferenceDefinitions.
protected OpenAPI removeBrokenReferenceDefinitions(OpenAPI openApi) {
if (openApi == null || openApi.getComponents() == null || openApi.getComponents().getSchemas() == null) {
return openApi;
}
Set<String> referencedDefinitions = new TreeSet<>();
if (openApi.getPaths() != null) {
for (String resourcePath : openApi.getPaths().keySet()) {
PathItem pathItem = openApi.getPaths().get(resourcePath);
addPathItemSchemaRef(pathItem, referencedDefinitions);
}
}
referencedDefinitions.addAll(resolveAllNestedRefs(referencedDefinitions, referencedDefinitions, openApi));
openApi.getComponents().getSchemas().keySet().retainAll(referencedDefinitions.stream().map(s -> (String) RefUtils.extractSimpleName(s).getLeft()).collect(Collectors.toSet()));
return openApi;
}
use of io.swagger.v3.core.util.RefUtils.extractSimpleName in project swagger-core by swagger-api.
the class SpecFilter method locateReferencedDefinitions.
protected void locateReferencedDefinitions(String ref, Set<String> nestedReferencedDefinitions, OpenAPI openAPI) {
nestedReferencedDefinitions.add(ref);
String simpleName = (String) RefUtils.extractSimpleName(ref).getLeft();
Schema model = openAPI.getComponents().getSchemas().get(simpleName);
if (model != null) {
addSchemaRef(model, nestedReferencedDefinitions);
}
}
Aggregations