|
@@ -126,4 +126,31 @@ public class OpenAPIScan {
|
|
|
return openAPIS;
|
|
return openAPIS;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static JSONObject filterOpenApi(String str, String sign) {
|
|
|
|
|
+ if (StringUtils.isEmpty(sign)) {
|
|
|
|
|
+ sign = "openAPI";
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ try {
|
|
|
|
|
+ jsonObject = new JSONObject(str);
|
|
|
|
|
+ JSONObject schemas = new JSONObject();
|
|
|
|
|
+ if (jsonObject.containsKey("components")) {
|
|
|
|
|
+ schemas = jsonObject.getJSONObject("components").getJSONObject("schemas");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (jsonObject.containsKey("paths")) {
|
|
|
|
|
+ JSONObject paths = jsonObject.getJSONObject("paths");
|
|
|
|
|
+ List<String> keys = List.of(paths.keySet().toArray(new String[0]));
|
|
|
|
|
+ for (String key : keys) {
|
|
|
|
|
+ if (key.indexOf(sign) < 0) {
|
|
|
|
|
+ paths.remove(key);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ jsonObject.set("paths", paths);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ return jsonObject;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|