Add LRO test with array response using ArmProviderActionAsync#3791
Add LRO test with array response using ArmProviderActionAsync#3791weidongxu-microsoft merged 7 commits intomainfrom
Conversation
Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
|
In mockapi.ts For response with status 202, add a header. In section of "// LRO POST poll intermediate/get final result - Azure-AsyncOperation Header" header. When exportArrayPollCount>0, response should have the location header In section of "// LRO POST poll intermediate/get final result - Location Header" Check the instruction, run the necessary pnpm command, include |
…polling state Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
All requested changes have been implemented in commit bbdddc2:
|
Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
|
The model on the Response is wrong. It should not be a model ExportResultArray with value of string[]. It should be the array itself, e.g. Fix this, update mockapi, scenario doc, summary accordingly. |
commit: |
Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
Fixed in commit 02f1d75:
|
|
run pnpm format |
|
And |
Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
|
run |
Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
## Plan to Add exportArray LRO Test with Array Response - [x] Understand the existing code structure - [x] Review lro.tsp file and existing export operation - [x] Review mockapi.ts and understand mock implementation pattern - [x] Review ArmProviderActionAsync template definition - [x] Understand SubscriptionActionScope usage - [x] Add exportArray operation to lro.tsp - [x] Create response as direct array type (ExportResult[]) - [x] Add exportArray operation using ArmProviderActionAsync template with SubscriptionActionScope - [x] Add scenario documentation with expected requests/responses - [x] Add mock API implementation for exportArray in mockapi.ts - [x] Add initial POST request handler at subscription scope - [x] Add Location header polling handler - [x] Add Azure-AsyncOperation header polling handler - [x] Return array response directly (not wrapped) - [x] Fix LRO headers based on feedback - [x] Add `retry-after: 1` header to all 202 responses (including Location polling) - [x] Add location header to all Location polling responses - [x] Add retry-after and azure-asyncoperation headers to AAO polling when InProgress - [x] Add location header to AAO polling when Succeeded - [x] Add changeset for the feature - [x] Fix response model structure - [x] Remove ExportResultArray wrapper model - [x] Use ExportResult[] as direct array response type - [x] Update mockapi to return array of ExportResult objects - [x] Update scenario documentation to reflect array response - [x] Format code with prettier - [x] Regenerate documentation ## Implementation Complete Successfully added `exportArray` operation that returns an array of ExportResult objects directly, with proper LRO polling headers that conform to Azure LRO specifications. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>azure-http-specs, add a test of LRO return has Response/FinalResult as an array</issue_title> > <issue_description>Add a test in packages/azure-http-specs/specs/azure/resource-manager/operation-templates/lro.tsp > > Add operation `exportArray` with template `ArmProviderActionAsync`, with SubscriptionActionScope > https://github.com/Azure/typespec-azure/blob/main/packages/typespec-azure-resource-manager/lib/operations.tsp#L763-L788 > > You can refer to the `export` operation (as well as the corresponding code in "mockapi.ts"), to learn how the operation and mockapi be written, but mind that this uses a slightly different template, so the route is not same. > > Have its Response be an array. > > Add the mock to existing mockapi.ts</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes #3790 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/Azure/typespec-azure/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
Plan to Add exportArray LRO Test with Array Response
retry-after: 1header to all 202 responses (including Location polling)Implementation Complete
Successfully added
exportArrayoperation that returns an array of ExportResult objects directly, with proper LRO polling headers that conform to Azure LRO specifications.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.