Skip to content

Commit 2e94dc2

Browse files
Copilotmarkcowl
andauthored
Address review: use Trait templates, add @pollingOperation, add @madeRequired section, apply suggestions, remove data-plane examples
Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/56c71242-0384-4237-b485-c9d866377d88 Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
1 parent 31077eb commit 2e94dc2

6 files changed

Lines changed: 47 additions & 140 deletions

File tree

website/src/content/docs/docs/getstarted/versioning.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,14 @@ interface Employees {
109109
interface Widgets {
110110
getWidget is Operations.ResourceRead<
111111
Widget,
112-
Traits = {
113-
parameters: {
114-
@query
115-
name: string;
116-
117-
@added(Versions.v2)
118-
@query
119-
department?: string;
120-
};
121-
}
112+
QueryParametersTrait<{
113+
@query
114+
name: string;
115+
116+
@added(Versions.v2)
117+
@query
118+
department?: string;
119+
}>
122120
>;
123121
}
124122
```

website/src/content/docs/docs/howtos/Versioning/02-preview-after-preview.md

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -174,54 +174,3 @@ This includes the following steps:
174174
```
175175
176176
- If you _do_ need the older preview version (see [Should I Retain the OpenAPI for an Old Preview API](./01-about-versioning.md#should-i-retain-the-openapi-for-an-old-preview-api-arm-only) if you are not sure), update README.md to include a new entry for the new preview version.
177-
178-
## Data-Plane Example
179-
180-
In the following example, we introduce a new preview version called `v3Preview` which includes everything from `v2` plus adds a new property to the `Widget` resource.
181-
182-
```diff lang=tsp
183-
import "@typespec/http";
184-
import "@typespec/rest";
185-
import "@typespec/versioning";
186-
import "@azure-tools/typespec-azure-core";
187-
188-
using Http;
189-
using Rest;
190-
using Versioning;
191-
using Azure.Core;
192-
193-
194-
@versioned(Versions)
195-
@service(#{ title: "Widget Service" })
196-
namespace DemoService;
197-
198-
enum Versions {
199-
v1,
200-
v2,
201-
+ @previewVersion
202-
+ v3Preview
203-
}
204-
205-
/**
206-
* Model defining the Widget resource
207-
*/
208-
model Widget {
209-
/**
210-
* Identifier of the Widget Resource
211-
*/
212-
@visibility(Lifecycle.Read)
213-
@key id: string;
214-
/**
215-
* Weight of the widget
216-
*/
217-
weight: int32;
218-
/**
219-
* Color of the widget;
220-
*/
221-
color: "red" | "blue";
222-
/**
223-
* Nickname of the Widget resource
224-
*/
225-
+ @added(Versions.v3Preview) nickname: string;
226-
}
227-
```

website/src/content/docs/docs/howtos/Versioning/03-stable-after-preview.md

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -164,56 +164,3 @@ This includes the following steps:
164164
```
165165

166166
- update README.md to include a new entry for the new preview version.
167-
168-
## Data-Plane Example
169-
170-
This example builds on the data-plane preview version example in [Adding a Preview Version when the Last Version was Preview](./02-preview-after-preview.md#data-plane-example), where `v3` is introduced which GA's the `nickname` property introduced in `v3Preview`.
171-
172-
```diff lang=tsp
173-
import "@typespec/http";
174-
import "@typespec/rest";
175-
import "@typespec/versioning";
176-
import "@azure-tools/typespec-azure-core";
177-
178-
using Http;
179-
using Rest;
180-
using Versioning;
181-
using Azure.Core;
182-
183-
184-
@versioned(Versions)
185-
@service(#{ title: "Widget Service" })
186-
namespace DemoService;
187-
188-
enum Versions {
189-
v1,
190-
v2,
191-
- @previewVersion
192-
- v3Preview
193-
+ v3
194-
}
195-
196-
/**
197-
* Model defining the Widget resource
198-
*/
199-
model Widget {
200-
/**
201-
* Identifier of the Widget Resource
202-
*/
203-
@visibility(Lifecycle.Read)
204-
@key id: string;
205-
/**
206-
* Weight of the widget
207-
*/
208-
weight: int32;
209-
/**
210-
* Color of the widget;
211-
*/
212-
color: "red" | "blue";
213-
/**
214-
* Nickname of the Widget resource
215-
*/
216-
- @added(Versions.v3Preview) nickname: string;
217-
+ @added(Versions.v3) nickname: string;
218-
}
219-
```

website/src/content/docs/docs/howtos/Versioning/06-evolving-apis.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,14 @@ interface Employees {
129129
interface Widgets {
130130
getWidget is Operations.ResourceRead<
131131
Widget,
132-
Traits = {
133-
parameters: {
134-
@query
135-
name: string;
132+
QueryParametersTrait<{
133+
@query
134+
name: string;
136135
137-
@added(Versions.v2)
138-
@query
139-
department?: string;
140-
};
141-
}
136+
@added(Versions.v2)
137+
@query
138+
department?: string;
139+
}>
142140
>;
143141
}
144142
```
@@ -229,12 +227,10 @@ interface Employees {
229227
interface Widgets {
230228
listWidgets is Operations.ResourceList<
231229
Widget,
232-
Traits = {
233-
parameters: {
234-
@header
235-
location: string;
236-
};
237-
}
230+
RequestHeadersTrait<{
231+
@header
232+
location: string;
233+
}>
238234
>;
239235
}
240236
```
@@ -272,17 +268,16 @@ interface Employees {
272268
interface Widgets {
273269
listWidgets is Operations.ResourceList<
274270
Widget,
275-
Traits = {
276-
parameters: {
277-
@madeOptional(Versions.v2)
278-
@header
279-
location?: string;
280-
271+
RequestHeadersTrait<{
272+
@madeOptional(Versions.v2)
273+
@header
274+
location?: string;
275+
}> &
276+
QueryParametersTrait<{
281277
@added(Versions.v2)
282278
@query("order-by")
283279
orderBy?: string;
284-
};
285-
}
280+
}>
286281
>;
287282
}
288283
```
@@ -342,8 +337,12 @@ interface Widgets {
342337
@sharedRoute
343338
createOrReplaceWidgetV1 is Operations.ResourceCreateOrReplace<Widget>;
344339
340+
@added(Versions.v2)
341+
getWidgetOperationStatus is Operations.GetResourceOperationStatus<Widget, never>;
342+
345343
@added(Versions.v2)
346344
@sharedRoute
345+
@pollingOperation(Widgets.getWidgetOperationStatus)
347346
createOrReplaceWidget is Operations.LongRunningResourceCreateOrReplace<Widget>;
348347
}
349348
```
@@ -354,6 +353,7 @@ interface Widgets {
354353
- `@renamedFrom(Versions.v2, "createOrUpdate")` keeps the original name for v1.
355354
- `@added(Versions.v2)` adds the new asynchronous operation in v2 and later.
356355
- `@sharedRoute` ensures both operations can use the same route.
356+
- `@pollingOperation` links the long-running operation to its status monitor endpoint (data-plane only).
357357

358358
## Versioning Decorators
359359

website/src/content/docs/docs/howtos/Versioning/uncommon-scenarios/01-converting-specs.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ Normalizing version decoration consists of removing redundant decorators and fol
9999
nowOptional?: string;
100100
```
101101

102+
## `@madeRequired(T, u)` decorator
103+
104+
- Based on the version referenced in the decorator, determine the immediate successor version `u + 1`
105+
- If version `u + 1` does not exist (the version argument is the last version) then this version will not be deleted
106+
- If there is one or more `@madeRequired` decorators referencing the immediate successor version, remove them.
107+
- Change `@madeRequired(T, u)` to `@madeRequired(T, u + 1)`
108+
109+
```diff lang=tsp
110+
- @madeRequired(Versions.`2025-10-01-preview`)
111+
+ @madeRequired(Versions.`2025-11-01`)
112+
nowRequired: string;
113+
```
114+
102115
## `@added(T, u)` decorator
103116

104117
- Based on the version referenced in the decorator, determine the immediate successor version `u + 1`

website/src/content/docs/docs/howtos/Versioning/uncommon-scenarios/02-perpetual-preview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: "ARM: Managing a Single Active Preview with Perpetual Preview Features"
2+
title: "ARM: Managing a Single Active Preview When Some Features Always Remain in Preview"
33
llmstxt: true
44
---
55

66
:::note
7-
This document applies specifically to **Azure Resource Manager (ARM) APIs**. Data plane services should follow the [general versioning guidance](../01-about-versioning.md).
7+
This document applies specifically to **Azure Resource Manager (ARM) APIs**. Data plane services should not allow versions to remain in preview across stable releases.
88
:::
99

1010
For some Resource Providers, whenever a new stable version is released, a new preview version is created, because some preview features are not ready to be stable, but may become stable in a future version. To accommodate this need and account for the limitations of breaking change checks, which require a single version change for any PR into the rest-api-specs repo, the recommended solution is to introduce a stable and subsequent preview _together_ in your TypeSpec API description and then split this change into two PRs: one representing the new stable and the second representing the subsequent preview. This involves the following steps described in the sections below:
@@ -80,7 +80,7 @@ For some Resource Providers, whenever a new stable version is released, a new pr
8080
newName: int32;
8181
```
8282

83-
- Add any new type changes to stable version (A + 1) and decorate appropriately, as shown in the [versioning guide](../06-evolving-apis.md). Note that these changes should also appear in the new preview (A + 2)
83+
- Add any new type changes to stable version (A + 1) and decorate appropriately, as shown in the [versioning guide](../06-evolving-apis.md). Note that these changes will also appear in the new preview (A + 2)
8484
- Remove version `A` from the versions enumeration
8585

8686
```diff lang=tsp

0 commit comments

Comments
 (0)