@@ -42,6 +42,24 @@ type CollectionParams = struct {
4242 NotificationFeedCollections
4343}
4444
45+ type collectionOptions struct {
46+ noPagination bool
47+ }
48+
49+ type CollectionOption interface {
50+ apply (* collectionOptions )
51+ }
52+
53+ type noPaginationOption bool
54+
55+ func (n noPaginationOption ) apply (opts * collectionOptions ) {
56+ opts .noPagination = bool (n )
57+ }
58+
59+ func WithNoPagination (n bool ) CollectionOption {
60+ return noPaginationOption (n )
61+ }
62+
4563const (
4664 // Messages are a special case as they are a feed rather than a normal collection
4765 notificationFeedRef = "NotificationFeed"
@@ -208,13 +226,21 @@ func getCollectionSchema(swagger *openapi3.T, appJSON *openapi3.MediaType, endpo
208226 return
209227}
210228
211- func newCollection (collectionRef , itemRef string , noPagination bool ) Collection {
229+ func newCollection (collectionRef , itemRef string , opts ... CollectionOption ) Collection {
230+ options := collectionOptions {
231+ noPagination : false ,
232+ }
233+
234+ for _ , opt := range opts {
235+ opt .apply (& options )
236+ }
237+
212238 return Collection {
213239 CollectionRef : collectionRef ,
214240 ItemRef : trimRefPrefix (itemRef ),
215241 ModelRef : fmt .Sprintf ("%sModel" , strings .TrimSuffix (collectionRef , "Collection" )),
216242 IteratorRef : fmt .Sprintf ("%sIterator" , strings .TrimSuffix (collectionRef , "Collection" )),
217- NoPagination : noPagination ,
243+ NoPagination : options . noPagination ,
218244 }
219245}
220246
@@ -321,7 +347,11 @@ func GetCollections(swagger *openapi3.T) (collections CollectionParams, err erro
321347 return
322348 }
323349
324- collectionSet .Add (newCollection (collectionRef , itemRef , isNoPaginationCollection ))
350+ if isNoPaginationCollection {
351+ collectionSet .Add (newCollection (collectionRef , itemRef , WithNoPagination (true )))
352+ } else {
353+ collectionSet .Add (newCollection (collectionRef , itemRef ))
354+ }
325355 }
326356
327357 if isMessagesCollection := strings .HasSuffix (endpoint , "messages" ); isMessagesCollection {
0 commit comments