feat(http-client-python): add encode/boolean Spector mock API tests + fix boolean-as-string encoding#11087
Conversation
…oolean string encode support - Add `encode/boolean` to regenerate-common.ts spec list - Bump @typespec/http-specs to 0.1.0-alpha.39-dev.4 (includes encode/boolean spec) - Fix TCGC to propagate encode=string for boolean types - Fix Python generator BooleanType to set encode="str" when @encode(string) is used - Add _deserialize_bool_as_str to model_base.py.jinja2 template - Add sync and async mock API tests for azure and unbranded flavors - Add changelog entry Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
…n assertions Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
|
Need new compiler version to support this feature. |
… feature Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
commit: |
|
All changed packages have been documented.
Show changes
|
|
@copilot resolve the merge conflicts in this pull request |
…add-test-case-for-pull-10875 # Conflicts: # packages/http-client-python/package-lock.json # packages/http-client-python/package.json Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
|
You can try these changes here
|
Resolved the conflicts with current |
replied |
Adds Python SDK mock API test coverage for the
encode/booleanSpector scenarios from #10875 (@encode(string)on boolean types). This required updating multiple layers of the Python codegen stack.Generator fixes
types.ts— property emissionPreserves boolean
@encode(string)metadata from the compiler and maps it to the Python runtime’s"str"format token.primitive_types.py—BooleanTypeDetects
yaml_data["encode"] == "string"and setsself.encode = "str", mirroringIntegerType.model_base.py.jinja2Adds
_deserialize_bool_as_strfor case-insensitive string-to-boolean deserialization:Also dispatches to it when
annotation is bool and rf._format == "str".Test coverage
Adds sync and async tests for Azure and unbranded clients covering:
trueLower—"true"→TruefalseLower—"false"→FalsetrueUpper—"TRUE"→TruefalseMixed—"FaLsE"→FalseDependencies
@typespec/compiler1.14, which supports boolean@encode(string).@typespec/http-specs0.1.0-alpha.39, containing theencode/booleanscenarios.encode/booleantoregenerate-common.ts.Code diff:
Azure/azure-sdk-for-python#48067