Skip to content

Commit ea747f3

Browse files
authored
doc: add rule for renamed model/enum breaking change (#47038)
1 parent c218255 commit ea747f3

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

doc/dev/mgmt/sdk-breaking-changes-guide.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,53 @@ Removal of a property and addition of a corresponding property with `_property`
328328
**Impact**: Users need to update property access to use the `_property` suffix (e.g., `.values` to `.values_property`, `.keys` to `.keys_property`, `.items` to `.items_property`).
329329

330330
**Resolution**: Accept these breaking changes.
331+
332+
## 13. Renamed Model or Enum
333+
334+
**Changelog Pattern**:
335+
336+
Entries showing a model or enum has been renamed:
337+
338+
```md
339+
- Renamed model `OldModelName` to `NewModelName`
340+
- Renamed enum `OldEnumName` to `NewEnumName`
341+
```
342+
343+
**Reason**: TypeSpec may produce different model or enum names than Swagger (for example, due to namespace changes or naming convention differences).
344+
345+
**Spec Pattern**:
346+
347+
Find the type definition by examining the new name from the changelog entry:
348+
349+
```tsp
350+
model NewModelName {
351+
...
352+
}
353+
354+
union NewEnumName {
355+
string,
356+
...
357+
}
358+
```
359+
360+
**Resolution**:
361+
362+
Use `@clientName` to restore the original name from the removal entry:
363+
364+
```tsp
365+
@@clientName(NewModelName, "OldModelName", "python");
366+
@@clientName(NewEnumName, "OldEnumName", "python");
367+
```
368+
369+
**Note**: Some renamed models are defined in common types (e.g., `Azure.ResourceManager.CommonTypes`) rather than the current service's TypeSpec. In that case, you may not find the type definition in the local spec — import the relevant library and reference the type by its fully qualified name. For example:
370+
371+
```tsp
372+
import "@azure-tools/typespec-azure-resource-manager";
373+
...
374+
375+
@@clientName(
376+
Azure.ResourceManager.CommonTypes.OperationDisplay,
377+
"OperationInfo",
378+
"python"
379+
);
380+
```

0 commit comments

Comments
 (0)