Azure / autorest.java

Extension for AutoRest (https://github.com/Azure/autorest) that generates Java code
MIT License
33 stars 82 forks source link

Autorest should not make an assumption on the pageable return type as JsonArray #1027

Open pallavit opened 3 years ago

pallavit commented 3 years ago

A lot of rest APIs support list apis w/o pagination (nextLink) support. The client SDK often tries to be forward looking and make the SDK endpoints pageable. Hence, autorest should support an implementation where we get the naked response object for the Single and Next page links so we can customize the pagination response.

For example: Swagger: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/d06fc6e105c57df31284d36c90385bce354490e1/specification/containerregistry/data-plane/Azure.ContainerRegistry/preview/2019-08-15-preview/containerregistry.json OperationId: ContainerRegistry_GetManifests returns a pageable object AcrManifests which has the following definition

"AcrManifests": { "description": "Manifest attributes", "properties": { "registry": {}, "imageName": {}, "manifests": { "type": "array", "description": "List of manifests", "items": { "$ref": "#/definitions/ManifestAttributesBase", } }, "link": { "type": "string" } },

However the pagination code generated for this type is below which has lost the fields like registry and imageName.

@ServiceMethod(returns = ReturnType.SINGLE) public Mono<PagedResponse<ManifestAttributesBase>> getManifestsSinglePageAsync( String name, String last, Integer n, String orderby)

Ask:- We should add another overload here that can return Mono instead so we can create the pageable response ourselves.

pallavit commented 3 years ago

/cc: @srnagar