Skip to content

Commit 6012a50

Browse files
Make request bodies optional (Azure#2674)
Still needs: - [x] Sample - [x] Tests - [x] azure-rest-api-specs-prs --------- Co-authored-by: Timothee Guerin <[email protected]>
1 parent 1b9313b commit 6012a50

File tree

12 files changed

+990
-137
lines changed

12 files changed

+990
-137
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
changeKind: feature
3+
packages:
4+
- "@azure-tools/typespec-azure-resource-manager"
5+
---
6+
7+
Allow optional request bodies in Resource actions templates

packages/azure-http-specs/spec-summary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ Expected response body:
333333

334334
### Azure_Core_Basic_createOrUpdate
335335

336-
- Endpoint: `get /azure/core/basic`
336+
- Endpoint: `patch /azure/core/basic`
337337

338338
Should only generate models named User and UserOrder.
339339

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.CustomPatchAsync<
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)