Skip to content

Commit

Permalink
Merge pull request #655 from akto-api-security/feature/ab_6
Browse files Browse the repository at this point in the history
set slice limit to 100 and add logs
  • Loading branch information
ankush-jain-akto authored Mar 8, 2023
2 parents 5066c5f + 389200b commit 1caa22f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion apps/dashboard/src/main/java/com/akto/action/OpenApiAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ public String execute() {
try {
ApiCollection apiCollection = ApiCollectionsDao.instance.findOne("_id", apiCollectionId);
if (apiCollection == null) return ERROR.toUpperCase();

loggerMaker.infoAndAddToDb("Found API Collection " + apiCollection.getHostName(), LogDb.DASHBOARD);
String host = apiCollection.getHostName();

int limit = 200;
int limit = 100;
List<SampleData> sampleDataList = SampleDataDao.instance.fetchSampleDataPaginated(
apiCollectionId, lastFetchedUrl, lastFetchedMethod, limit, 1
);

int size = sampleDataList.size();
loggerMaker.infoAndAddToDb("Fetched sample data list " + size, LogDb.DASHBOARD);

if (size < limit) {
lastFetchedUrl = null;
lastFetchedMethod = null;
Expand All @@ -51,12 +55,19 @@ public String execute() {
lastFetchedUrl = last.getId().getUrl();
lastFetchedMethod = last.getId().getMethod().name();
}
loggerMaker.infoAndAddToDb("Fetching for " + lastFetchedUrl + " " + lastFetchedMethod, LogDb.DASHBOARD);

SampleDataToSTI sampleDataToSTI = new SampleDataToSTI();
sampleDataToSTI.setSampleDataToSTI(sampleDataList);
loggerMaker.infoAndAddToDb("Converted to STI", LogDb.DASHBOARD);

Map<String,Map<String, Map<Integer, List<SingleTypeInfo>>>> stiList = sampleDataToSTI.getSingleTypeInfoMap();
OpenAPI openAPI = Main.init(apiCollection.getDisplayName(),stiList, includeHeaders, host);
loggerMaker.infoAndAddToDb("Initialized openAPI", LogDb.DASHBOARD);

openAPIString = Main.convertOpenApiToJSON(openAPI);
loggerMaker.infoAndAddToDb("Initialize openAPI", LogDb.DASHBOARD);

} catch (Exception e) {
loggerMaker.errorAndAddToDb("ERROR while downloading openApi file " + e, LogDb.DASHBOARD);
return ERROR.toUpperCase();
Expand Down

0 comments on commit 1caa22f

Please sign in to comment.