Skip to content

Commit c6aa80b

Browse files
Copilotmarkcowl
andauthored
Address review feedback: remove data-plane section, add ARM/data-plane examples, update headings
Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/83ebf765-92d4-4c47-8eab-eb4aa807c173 Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
1 parent b065300 commit c6aa80b

File tree

5 files changed

+327
-117
lines changed

5 files changed

+327
-117
lines changed

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

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Versioning lets you evolve your API without breaking existing clients. This guid
88

99
To support multiple API versions, define them in an enum. After defining your enum, link it to your namespace using the `@versioned` decorator. For each version, specify your dependencies:
1010

11+
**ARM:**
12+
1113
```tsp
1214
/** Contoso API versions */
1315
enum Versions {
@@ -22,6 +24,19 @@ enum Versions {
2224
namespace Microsoft.ContosoProviderHub;
2325
```
2426

27+
**Data-plane:**
28+
29+
```tsp
30+
enum Versions {
31+
v1,
32+
v2,
33+
}
34+
35+
@versioned(Versions)
36+
@service(#{ title: "Widget Service" })
37+
namespace DemoService;
38+
```
39+
2540
## Adding a Resource or Operation
2641

2742
To introduce a new model or operation in a specific version (and all later versions), use the `@added` decorator:
@@ -35,7 +50,7 @@ model Employee {
3550
}
3651
```
3752

38-
**Add an operation in v2:**
53+
**Add an operation in v2 (ARM):**
3954

4055
```tsp
4156
@armResourceOperations
@@ -46,6 +61,16 @@ interface Employees {
4661
}
4762
```
4863

64+
**Add an operation in v2 (Data-plane):**
65+
66+
```tsp
67+
interface Widgets {
68+
getWidget is Operations.ResourceRead<Widget>;
69+
@added(Versions.v2)
70+
createOrReplaceWidget is Operations.ResourceCreateOrReplace<Widget>;
71+
}
72+
```
73+
4974
## Adding a Property or Parameter
5075

5176
You can also add new properties or parameters to models and operations in a specific version:
@@ -61,7 +86,7 @@ model Employee {
6186
}
6287
```
6388

64-
**Add a parameter in v2:**
89+
**Add a parameter in v2 (ARM):**
6590

6691
```tsp
6792
@armResourceOperations
@@ -78,11 +103,31 @@ interface Employees {
78103
}
79104
```
80105

106+
**Add a parameter in v2 (Data-plane):**
107+
108+
```tsp
109+
interface Widgets {
110+
getWidget is Operations.ResourceRead<
111+
Widget,
112+
Traits = {
113+
parameters: {
114+
@query
115+
name: string;
116+
117+
@added(Versions.v2)
118+
@query
119+
department?: string;
120+
};
121+
}
122+
>;
123+
}
124+
```
125+
81126
## Adding New Operations
82127

83128
You can add new operations to an interface for a specific version:
84129

85-
**Add a new operation in v2:**
130+
**Add a new operation in v2 (ARM):**
86131

87132
```tsp
88133
@armResourceOperations
@@ -94,6 +139,17 @@ interface Employees {
94139
}
95140
```
96141

142+
**Add a new operation in v2 (Data-plane):**
143+
144+
```tsp
145+
interface Widgets {
146+
getWidget is Operations.ResourceRead<Widget>;
147+
148+
@added(Versions.v2)
149+
moveWidget is Operations.ResourceAction<Widget, MoveRequest, MoveResponse>;
150+
}
151+
```
152+
97153
---
98154

99155
For more details and advanced scenarios, see the [full versioning documentation](../howtos/Versioning/01-about-versioning.md).

website/src/content/docs/docs/howtos/Versioning/01-about-versioning.md

Lines changed: 5 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,22 @@ Additionally, in Azure, preview APIs have a limited lifespan and limited support
1919
- Only one version may be marked with the `@previewVersion` decorator.
2020
- Mark all changes from the latest stable with appropriate versioning decorators, using `Versions.<PreviewVersion>` as the version argument (where `<PreviewVersion>` is the name of the last enum value)
2121

22-
## Preview Versioning Rules for Data Plane APIs
23-
24-
- For a new GA, add a new version enum **BEFORE** the preview enum value. Manually change all **preview** items that are GA'ing so that the `@added` version value matches the new GA enum value
25-
- For any items remaining in **preview**, rename the **old preview** enum value to the **new preview** enum value.
26-
2722
## Common Version Transition Scenarios
2823

29-
This section describes how to evolve APIs according to these guidelines, and how to meet both the single active preview guideline and the need to maintain some preview versions in certain situations:
24+
These documents add specific guidance about how to follow these guidelines for specific version changes
3025

3126
- [How to add a new preview version when the last version was preview](./02-preview-after-preview.md)
3227
- [How to add a new stable version when the last version was preview](./03-stable-after-preview.md)
3328
- [How to add a new preview version when the last version was stable](./04-preview-after-stable.md)
3429
- [How to add a new stable version when the last version was stable](./05-stable-after-stable.md)
3530

36-
This section also describes how to convert an existing multi-API TypeSpec spec with multiple previews into a spec with a single active preview. Note that this is not required, but it may significantly simplify the versioning decoration in your spec:
31+
This document describes how to convert an existing multi-API TypeSpec spec with multiple previews into a spec with a single active preview. Note that this is not required, but it may significantly simplify the versioning decoration in your spec:
3732

3833
- [How to convert a spec with multiple preview versions into a spec with a single active preview](./uncommon-scenarios/01-converting-specs.md)
3934

40-
Additionally, there are some services that may always have features that remain in preview after a stable version is released. This can happen, for example, if there are multiple independent teams that own different resources in a service and operate on their own schedule. The recommended way to handle this scenario is to model your ResourceProvider as multiple services, so each version and the corresponding SDKs can version independently. For some older services, this is not an option, so there is specialized guidance on how to maintain preview features over stable API releases (described below). If you are thinking about splitting your service, or about creating a new preview version with every stable version, be sure to have a discussion with the [Azure API Stewardship Board](https://aka.ms/azapi/officehours) and the [Azure SDK team](https://eng.ms/docs/products/azure-developer-experience/onboard) first.
35+
### Uncommon Scenarios
36+
37+
Additionally, there are some (ARM) services that may always have features that remain in preview after a stable version is released. This can happen, for example, if there are multiple independent teams that own different resources in a service and operate on their own schedule. The recommended way to handle this scenario is to model your ARM ResourceProvider as multiple services, so each sub-service and the corresponding SDKs can version independently. For some older services, this is not an option, so there is specialized guidance on how to maintain preview features over stable API releases (described below). If you are thinking about splitting your service, or about creating a new preview version with every stable version, be sure to have a discussion with the [Azure API Stewardship Board](https://aka.ms/azapi/officehours) and the [Azure SDK team](https://eng.ms/docs/products/azure-developer-experience/onboard) first.
4138

4239
- [How to manage a single active preview if your service always has some features in preview (ARM only)](./uncommon-scenarios/02-perpetual-preview.md)
4340

@@ -57,109 +54,3 @@ It is safe to remove the swagger for an old API version if any of the following
5754
- The OpenAPI document in the azure-rest-api-specs repo is not needed for ARM registration
5855

5956
It is recommended that preview api-versions are set for retirement within 90 days when a preview or stable API is introduced. See the [Azure Retirement Policy](https://aka.ms/AzureRetirementPolicy) and [Azure Retirement Process](https://aka.ms/cpexretirementsprocess) for details.
60-
61-
### Usage Examples
62-
63-
#### New preview version
64-
65-
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.
66-
67-
```diff lang=tsp
68-
import "@typespec/http";
69-
import "@typespec/rest";
70-
import "@typespec/versioning";
71-
import "@azure-tools/typespec-azure-core";
72-
73-
using Http;
74-
using Rest;
75-
using Versioning;
76-
using Azure.Core;
77-
78-
79-
@versioned(Versions)
80-
@service(#{ title: "Widget Service" })
81-
namespace DemoService;
82-
83-
enum Versions {
84-
v1,
85-
v2,
86-
+ @previewVersion
87-
+ v3Preview
88-
}
89-
90-
/**
91-
* Model defining the Widget resource
92-
*/
93-
model Widget {
94-
/**
95-
* Identifier of the Widget Resource
96-
*/
97-
@visibility(Lifecycle.Read)
98-
@key id: string;
99-
/**
100-
* Weight of the widget
101-
*/
102-
weight: int32;
103-
/**
104-
* Color of the widget;
105-
*/
106-
color: "red" | "blue";
107-
/**
108-
* Nickname of the Widget resource
109-
*/
110-
+ @added(Versions.v3Preview) nickname: string;
111-
}
112-
```
113-
114-
#### Adding a new stable (GA) version
115-
116-
This example builds on the previous one, where `v3` is introduced which GA's the `nickname` property introduced in `v3Preview`
117-
118-
```diff lang=tsp
119-
import "@typespec/http";
120-
import "@typespec/rest";
121-
import "@typespec/versioning";
122-
import "@azure-tools/typespec-azure-core";
123-
124-
using Http;
125-
using Rest;
126-
using Versioning;
127-
using Azure.Core;
128-
129-
130-
@versioned(Versions)
131-
@service(#{ title: "Widget Service" })
132-
namespace DemoService;
133-
134-
enum Versions {
135-
v1,
136-
v2,
137-
- @previewVersion
138-
- v3Preview
139-
+ v3
140-
}
141-
142-
/**
143-
* Model defining the Widget resource
144-
*/
145-
model Widget {
146-
/**
147-
* Identifier of the Widget Resource
148-
*/
149-
@visibility(Lifecycle.Read)
150-
@key id: string;
151-
/**
152-
* Weight of the widget
153-
*/
154-
weight: int32;
155-
/**
156-
* Color of the widget;
157-
*/
158-
color: "red" | "blue";
159-
/**
160-
* Nickname of the Widget resource
161-
*/
162-
- @added(Versions.v3Preview) nickname: string;
163-
+ @added(Versions.v3) nickname: string;
164-
}
165-
```

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,54 @@ 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: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,56 @@ 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+
```

0 commit comments

Comments
 (0)