-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix duplicate response headers found in appcompliance with tsp #2550
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5f31be1
generate appcompliance with tsp
kazrael2119 51cbd0f
fix duplicate response headers
qiaozha de26f16
Merge branch 'main' into pr/kazrael2119/2550
qiaozha 114a876
add ut
qiaozha 5de494d
remove AppComplianceAutomation test
kazrael2119 e91bcf1
Merge branch 'appcompliance-tsp' of https://github.com/kazrael2119/au…
kazrael2119 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import { assert } from "chai"; | ||
import { emitResponsesFromTypeSpec } from "../util/emitUtil.js"; | ||
import { assertEqualContent } from "../util/testUtil.js"; | ||
|
||
describe("ARM template", () => { | ||
it("Response with ArmProviderActionAsync", async () => { | ||
const tspContent = ` | ||
import "@azure-tools/typespec-azure-resource-manager"; | ||
import "@typespec/versioning"; | ||
|
||
using Azure.ResourceManager; | ||
using TypeSpec.Versioning; | ||
|
||
@armProviderNamespace | ||
@service({ | ||
title: "App Compliance Automation Tool for Microsoft 365", | ||
}) | ||
@versioned(Versions) | ||
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v3) | ||
namespace Microsoft.AppComplianceAutomation; | ||
|
||
/** | ||
* The available API versions. | ||
*/ | ||
enum Versions { | ||
/** | ||
* The 2024-06-27 API version. | ||
*/ | ||
@useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) | ||
@useDependency(Azure.Core.Versions.v1_0_Preview_1) | ||
v2024_06_27: "2024-06-27", | ||
} | ||
|
||
alias PlaceholderResource = Azure.ResourceManager.Foundations.ProxyResource; | ||
alias ArmProviderActionAsync< | ||
Request extends {} | void, | ||
Response extends {} | void, | ||
Parameters extends {} = {}, | ||
LroHeaders extends TypeSpec.Reflection.Model = ArmLroLocationHeader & | ||
Azure.Core.Foundations.RetryAfterHeader | ||
> = Azure.ResourceManager.ArmResourceActionAsync< | ||
PlaceholderResource, | ||
Request, | ||
Response | ArmAcceptedLroResponse<"Accepted", LroHeaders>, | ||
BaseParameters = ApiVersionParameter, | ||
Parameters = Parameters, | ||
LroHeaders = ArmLroLocationHeader<Azure.Core.StatusMonitorPollingOptions<ArmOperationStatus>> | ||
>; | ||
|
||
@doc("Parameters for onboard operation") | ||
model OnboardRequest { | ||
/** | ||
* List of subscription ids to be onboarded | ||
*/ | ||
subscriptionIds: string[]; | ||
} | ||
|
||
/** | ||
* Onboard subscriptions response. | ||
*/ | ||
@doc("Success. The response indicates given subscriptions has been onboarded.") | ||
model OnboardResponse { | ||
/** | ||
* List of subscription ids that are onboarded | ||
*/ | ||
subscriptionIds?: string[]; | ||
} | ||
|
||
op upload is ArmProviderActionAsync<OnboardRequest, OnboardResponse>; | ||
`; | ||
const response = await emitResponsesFromTypeSpec( | ||
tspContent, | ||
false, | ||
true, | ||
true, | ||
true | ||
); | ||
assert.ok(response); | ||
await assertEqualContent(response!.content, ` | ||
import { RawHttpHeaders } from "@azure/core-rest-pipeline"; | ||
import { HttpResponse } from "@azure-rest/core-client"; | ||
import { OnboardResponseOutput, ErrorResponseOutput } from "./outputModels.js"; | ||
|
||
/** Azure operation completed successfully. */ | ||
export interface Upload200Response extends HttpResponse { | ||
status: "200"; | ||
body: OnboardResponseOutput; | ||
} | ||
|
||
export interface Upload202Headers { | ||
/** The Location header contains the URL where the status of the long running operation can be checked. */ | ||
"location"?: string; | ||
/** The Retry-After header can indicate how long the client should wait before polling the operation status. */ | ||
"retry-after"?: number; | ||
} | ||
|
||
/** Resource operation accepted. */ | ||
export interface Upload202Response extends HttpResponse { | ||
status: "202"; | ||
headers: RawHttpHeaders & Upload202Headers; | ||
} | ||
|
||
export interface UploadDefaultResponse extends HttpResponse { | ||
status: string; | ||
body: ErrorResponseOutput; | ||
} | ||
|
||
/** The final response for long-running upload operation */ | ||
export interface UploadLogicalResponse extends HttpResponse { | ||
status: "200"; | ||
body: OnboardResponseOutput; | ||
}`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't have the fix, we will generate two
location
headers.