Immediately Replacing a Preview Version
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:
- Create the new preview version based on the latest preview version
- Create the stable version (which should immediately precede the new preview version)
- Fill in examples for each
- Create a copy of the spec with just the stable release changes for your first PR
- After this PR is merged, create a PR with the whole spec, effectively adding the new preview
Creating New Preview and Stable Versions
Section titled “Creating New Preview and Stable Versions”- If the existing preview version is
A, add the new stable versionA + 1and the new preview versionA + 2to the Versions enumeration, ensure that versionA + 2is decorated with@previewVersionfrom theAzure.Corelibrary (and remove that decoration from any other version). - For all changes from preview version
Athat are part of stable versionA + 1- if a new type was added in
Aand is now stable (@added(T, A)), add the new decorator@added(T, A + 1) - if a type was made optional in
Aand this change is now stable (@madeOptional(T, A)), add the new decorator@madeOptional(T, A + 1) - if a type was renamed in
Aand this change is now stable (@renamedFrom(T, A, Name)), add the new decorator@typeChangedFrom(T, A + 1, Name) - if a property or parameter had its type changed in
Aand is now stable (@typeChangedFrom(T, A, U)), add the new decorator@typeChangedFrom(T, A + 1, U) - if an operation returnType was changed in
Aand this change is now stable (@returnTypeChangedFrom(T, A, U)), add the new decorator@returnTypeChangedFrom(T, A + 1, U) - If a type was removed in
Aand this change is now stable (@removed(T, A)), add the new decorator@removed(T, A + 1)
- if a new type was added in
- Change all versioning decorators
dec(T, A, args)todec(T, A + 2, args)whereTis a type,Ais the latest preview version,A + 2is the new preview version you added in the first step andargsare any additional arguments to the decorator. Note that, after this change, some decorators will be duplicated in versionA + 1and versionA + 2. This is expected. - Add any new type changes to stable version (A + 1) and decorate appropriately, as shown in the versioning guide. Note that these changes should also appear in the new preview (A + 2)
- Remove version
Afrom the versions enumeration - Create examples directories for the new stable version (A + 1) and populate them with appropriate examples
- If version A is not needed in the specs repo
- Remove its example folder
- Remove all references to version A in
README.md
Create A Copy of the Spec for the Stable Version only
Section titled “Create A Copy of the Spec for the Stable Version only”- Create a complete copy of your spec
- This copy will be used to contain just the new stable version (use this to create the first PR into the specs repo). Call this Copy.
- The original version will contain both the new stable and preview versions (use this to create the final PR after the first PR is merged). Call this Original.
- Do the following with the Copy
- Remove all decorators that reference version
A + 2and use the same parameters as inA + 1- For example, if these decorators exist:
@added(T, A + 2) @added(T, A + 1), then, after this step, only@added(T, A + 1)should remain in this copy of the spec.
- For example, if these decorators exist:
- Undo and remove any remaining decorators referencing
A + 2using the following guide:- For any type
Tdecorated with@added(T, A + 2), delete the typeTand all its decorators - For any type
Tdecorated with@removed(T, A + 2), remove the decorator - For any type
Tdecorated with@renamedFrom(T, A + 2, oldName)rename the typeoldNameand remove the decorator - For any property of parameter
Tdecorated with@typeChangedFrom(T, A + 2, oldType)set the type of the property tooldTypeand remove the decorator - For any operation
Tdecorated with@returnTypeChangedFrom(T, A + 2, oldType)set the return type of the operation tooldTypeand remove the decorator - For any property or parameter
Tdecorated with@madeOptional(T, A + 2)make the parameter or propertyTrequired and remove the decorator
- For any type
- Remove version
A + 2from the version enum. - Compile the spec to produce artifacts (especially the new stable version (
A + 1) openapi ) - Add the new stable version (
A + 1) to the README.md file. - Create and merge the PR
- Remove all decorators that reference version
Create a PR with the Combined Spec
Section titled “Create a PR with the Combined Spec”- Do the following with the Original
- Follow the instructions for normalizing decoration in the converting specifications document. This will remove any redundant decoration between the new stable and preview versions (
A + 1andA + 2). - Add any type changes that are introduced in the new preview and decorate appropriately, following the versioning guide
- Add a new example folder for the new preview version and populate with appropriate examples.
- Compile the spec to produce artifacts (especially the new stable and preview version (
A + 1andA + 2) apis). - Copy the README.md from copy 1 and add the new preview version to the file.
- Create and merge the final PR - this copy will be your specification going forward.
- Follow the instructions for normalizing decoration in the converting specifications document. This will remove any redundant decoration between the new stable and preview versions (