Remove swagger README transforms
The current generate code was generated with this readme:
# Azure Search for Python
> see https://aka.ms/autorest
### Settings
```yaml
input-file: searchservice.json
output-folder: generated
namespace: azure.search.documents
no-namespace-folders: true
license-header: MICROSOFT_MIT_NO_VERSION
clear-output-folder: true
python: true
```
### Remove x-ms-pageable
Currently breaking the latest version of autorest.python
``` yaml
directive:
- from: swagger-document
where: $["paths"]..get
transform: >
if ($["x-ms-pageable"]) { delete $["x-ms-pageable"]; }
```
This removes x-ms-pageable and the reason is that some results need transformations on individual results, e.g.
listize_synonyms(x)
before returning/yielding them.
@lmazuel mentions there will be a hook added that will make this transform unecessary
cc @xiangyan99 @heaths
To note, the only list operation that should be pageable is listing indexes. The others should just return a list of objects. For a pageable of indexes, just have the nextLink effectively be None.
Right, the issue is that the swagger has recently changed so that the generated code returns an async page iterator, so that the following (current) code stopped working without the above readme transform:
result = await self._client.synonym_maps.list(**kwargs)
return [listize_synonyms(x) for x in result.as_dict()["synonym_maps"]]
I guess the full list of options is:
- change the swagger back to not be pageable (was this change a mistake?)
- keep a readme transform
- explicitly consume the async iterator inside
list_synonym_maps(with or without and azure core hook to applylistize_synonyms)
I'm not sure whether it was intentional. @brjohnstmsft?
The only pageable API in the Swagger is List Indexes, as we had previously agreed:
https://github.com/Azure/azure-rest-api-specs/blob/be0569400241b7849182f4d26932a0fb0d6c53ab/specification/search/data-plane/Azure.Search/preview/2019-05-06-preview/searchservice.json#L1298
Sorry I was recalling the "listize" part but mis-recalling the exact context. It was indeed the list index function that caused the issue with a very similar call to a listize_flags_for_index on the returned results that is the problem:
https://github.com/Azure/azure-sdk-for-python/blob/2598959164c9d1e87f20060e8ca76ec563d180d6/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_indexes_client.py#L77-L78
In which case the original suggestion to use a (future) azure core async iterator hook seems like the (only) way to go.