@@ -27,20 +27,33 @@ public class OpenApiAction extends UserAction implements ServletResponseAware {
27
27
private int apiCollectionId ;
28
28
private String openAPIString = null ;
29
29
private boolean includeHeaders = true ;
30
+
31
+ private String lastFetchedUrl ;
32
+ private String lastFetchedMethod ;
30
33
@ Override
31
34
public String execute () {
32
35
try {
33
-
34
- List <SampleData > sampleData = SampleDataDao .instance .findAll (
35
- Filters .eq ("_id.apiCollectionId" , apiCollectionId )
36
- );
37
36
ApiCollection apiCollection = ApiCollectionsDao .instance .findOne ("_id" , apiCollectionId );
38
- if (apiCollection == null ) {
39
- return ERROR .toUpperCase ();
40
- }
37
+ if (apiCollection == null ) return ERROR .toUpperCase ();
41
38
String host = apiCollection .getHostName ();
39
+
40
+ int limit = 200 ;
41
+ List <SampleData > sampleDataList = SampleDataDao .instance .fetchSampleDataPaginated (
42
+ apiCollectionId , lastFetchedUrl , lastFetchedMethod , limit , 1
43
+ );
44
+
45
+ int size = sampleDataList .size ();
46
+ if (size < limit ) {
47
+ lastFetchedUrl = null ;
48
+ lastFetchedMethod = null ;
49
+ } else {
50
+ SampleData last = sampleDataList .get (size -1 );
51
+ lastFetchedUrl = last .getId ().getUrl ();
52
+ lastFetchedMethod = last .getId ().getMethod ().name ();
53
+ }
54
+
42
55
SampleDataToSTI sampleDataToSTI = new SampleDataToSTI ();
43
- sampleDataToSTI .setSampleDataToSTI (sampleData );
56
+ sampleDataToSTI .setSampleDataToSTI (sampleDataList );
44
57
Map <String ,Map <String , Map <Integer , List <SingleTypeInfo >>>> stiList = sampleDataToSTI .getSingleTypeInfoMap ();
45
58
OpenAPI openAPI = Main .init (apiCollection .getDisplayName (),stiList , includeHeaders , host );
46
59
openAPIString = Main .convertOpenApiToJSON (openAPI );
@@ -84,4 +97,20 @@ public void setServletResponse(HttpServletResponse response) {
84
97
public void setIncludeHeaders (boolean includeHeaders ) {
85
98
this .includeHeaders = includeHeaders ;
86
99
}
100
+
101
+ public String getLastFetchedUrl () {
102
+ return lastFetchedUrl ;
103
+ }
104
+
105
+ public void setLastFetchedUrl (String lastFetchedUrl ) {
106
+ this .lastFetchedUrl = lastFetchedUrl ;
107
+ }
108
+
109
+ public String getLastFetchedMethod () {
110
+ return lastFetchedMethod ;
111
+ }
112
+
113
+ public void setLastFetchedMethod (String lastFetchedMethod ) {
114
+ this .lastFetchedMethod = lastFetchedMethod ;
115
+ }
87
116
}
0 commit comments