Skip to content

fix(python): support @clientDefaultValue on model properties + bump azure-http-specs to 0.1.0-alpha.40-dev.6#10461

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-test-case-for-pull-4300
Draft

fix(python): support @clientDefaultValue on model properties + bump azure-http-specs to 0.1.0-alpha.40-dev.6#10461
Copilot wants to merge 2 commits intomainfrom
copilot/add-test-case-for-pull-4300

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 22, 2026

@clientDefaultValue on model properties was silently ignored by the Python emitter — the decorator's values were never forwarded to the code model, so generated models used Optional[T] = None instead of the correct default, and the SDK omitted those fields from serialized request bodies.

Root cause

emitProperty in emitter/src/types.ts did not include clientDefaultValue in its output (unlike the HTTP parameter path in http.ts, which handled it correctly).

Changes

Effect on generated code

Before:

class ModelWithDefaultValues(_Model):
    timeout: Optional[int] = rest_field(visibility=[...])
    tier: Optional[str] = rest_field(visibility=[...])
    retry: Optional[bool] = rest_field(visibility=[...])

    def __init__(self, *, name: str, timeout: Optional[int] = None, ...) -> None: ...

After:

class ModelWithDefaultValues(_Model):
    timeout: int = rest_field(visibility=[...], default=30)
    tier: str = rest_field(visibility=[...], default="standard")
    retry: bool = rest_field(visibility=[...], default=True)

    def __init__(self, *, name: str, timeout: int = 30, tier: str = "standard", retry: bool = True) -> None: ...

ModelWithDefaultValues(name="test") now serializes to {"name": "test", "timeout": 30, "tier": "standard", "retry": true} as expected.

… emitter to include clientDefaultValue, update spec version

Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/e76e44d3-8913-4cc0-8f5e-b4844d172290

Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:python Issue for the Python client emitter: @typespec/http-client-python label Apr 22, 2026
Copilot AI changed the title [WIP] Add test case for pull request 4300 fix(python): support @clientDefaultValue on model properties + bump azure-http-specs to 0.1.0-alpha.40-dev.6 Apr 22, 2026
Copilot AI requested a review from msyyc April 22, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:python Issue for the Python client emitter: @typespec/http-client-python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[python] add test case for https://github.com/Azure/typespec-azure/pull/4300

2 participants