Skip to content

[mgmt][typespec migration] as_dict behavior change for hierarchy model #41398

@msyyc

Description

@msyyc

When try to migrate azure-mgmt-avs from swagger to typespec, I find the following breakings for hierarchy model:

  • Before
from azure.mgmt.avs.models import CloudLink

model = CloudLink(linked_cloud="hello")
model_dict = model.as_dict(keep_readonly=False)
print(model_dict) # output: {'linked_cloud': 'hello'}
  • After
from azure.mgmt.avs.models import CloudLink

model = CloudLink(linked_cloud="hello")
model_dict = model.as_dict(exclude_readonly=True)
print(model_dict) # output: {'properties': {'linkedCloud': 'hello'}}

We can see there are 3 breakings:

  1. keep_readonly is renamed to exclude_readonly with reverse meaning
  2. key is changed from snake_case to camelCase
  3. old as_dict hide the hierarchy structure to follow model structure while new as_dict respect the hierarchy structure to keep consistent with REST API layer.

Metadata

Metadata

Assignees

Labels

AVSMgmtThis issue is related to a management-plane library.needs-discussion

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions