Skip to content

Commit ca2988a

Browse files
committed
Add sample using optional body mechanism
1 parent ef834be commit ca2988a

File tree

2 files changed

+529
-0
lines changed
  • packages/samples
    • specs/resource-manager/legacy/optional-body
    • test/output/azure/resource-manager/legacy/optional-body/@azure-tools/typespec-autorest/2025-01-01-preview

2 files changed

+529
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import "@typespec/rest";
2+
import "@typespec/http";
3+
import "@azure-tools/typespec-azure-resource-manager";
4+
import "@typespec/versioning";
5+
6+
using Azure.ResourceManager;
7+
using Versioning;
8+
using Http;
9+
10+
@armProviderNamespace
11+
@versioned(Versions)
12+
namespace Microsoft.OptionalBody;
13+
interface Operations extends Azure.ResourceManager.Operations {}
14+
15+
enum Versions {
16+
@useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1)
17+
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5)
18+
`2025-01-01-preview`,
19+
}
20+
/** The resource-specific properties of a Widget */
21+
model WidgetProperties {
22+
/** Required property */
23+
property1: string;
24+
25+
/** optional Property */
26+
property2: int32;
27+
28+
...DefaultProvisioningStateProperty;
29+
}
30+
31+
model Widget is TrackedResource<WidgetProperties> {
32+
...ResourceNameParameter<Widget>;
33+
}
34+
35+
@armResourceOperations
36+
interface Widgets {
37+
get is ArmResourceRead<Widget>;
38+
createOrReplace is ArmResourceCreateOrReplaceAsync<Widget>;
39+
update is Azure.ResourceManager.Legacy.ArmCustomPatchAsync<
40+
Widget,
41+
Foundations.ResourceUpdateModel<Widget, WidgetProperties>,
42+
RequestBody = {
43+
/** The PATCH request body */
44+
@body body?: Foundations.ResourceUpdateModel<Widget, WidgetProperties>;
45+
}
46+
>;
47+
delete is ArmResourceDeleteWithoutOkAsync<Widget>;
48+
list is ArmResourceListByParent<Widget>;
49+
}

0 commit comments

Comments
 (0)