Closed dlabs-matic-leva closed 8 months ago
Current workaround I'm doing is to create separate class for each paginated endpoint (PaginatedResponseForClients
, PaginatedResponseForAccounts
) but it would be nice to use generics.
OpenAPI does not directly support generics for classes. The implementation would be quite problematic and could not be universal for every specification.
There is not enough data in your NestJS-generated specification to realize that PaginatedResponse should be a generic class.
Usually, for such purposes, the spec automatically creates separate classes for each type as you described. This is what FastAPI does, for example.
I'm using NestJs to generate OpenAPI specs and NestJS recommends using schema+references to express generic responses. Below is example OpenAPI specs that is generated following this advice:
This is Dart code that was generated from specs:
Observe that
PaginatedResponse.results
is missing and return type ofclientsList()
isFuture<Object>
. I would expect to see code similar to this:Is this possible to achieve?