[python] Add Spector test for response-as-bool and fix ConstantType deserialization#10520
Draft
[python] Add Spector test for response-as-bool and fix ConstantType deserialization#10520
response-as-bool and fix ConstantType deserialization#10520Conversation
…n generator" Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/3d8ae12d-7aff-4090-aa21-db3eae2369c4 Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add test case for pull request 4328
[python] Add Spector test for Apr 27, 2026
response-as-bool and fix ConstantType deserialization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Python mock API test coverage for the
azure/client-generator-core/response-as-boolSpector scenario (from Azure/typespec-azure#4328), which tests@responseAsBool— HEAD operations that return aboolbased on HTTP status code (2xx →True, 404 →False).Generator bug fix
The generator was emitting
response.json()forConstantTyperesponse types (Literal[True]/Literal[False]). HEAD responses have no body, so this caused aJSONDecodeErrorat runtime.Before (generated code):
After (generated code):
Fix is in
builder_serializer.py: added aConstantTypebranch inresponse_deserializationthat emits the constant value directly instead of attempting body deserialization.Changes
generator/pygen/codegen/serializers/builder_serializer.py— importConstantType; add branch to emit constant value directly forConstantTyperesponses in DPG modepackage.json— bump@azure-tools/azure-http-specsto0.1.0-alpha.40-dev.9(first release containing theresponse-as-boolspec)tests/mock_api/azure/test_azure_client_generator_core_response_as_bool.py— sync tests forexists()→Trueandnot_exists()→Falsetests/mock_api/azure/asynctests/test_azure_client_generator_core_response_as_bool_async.py— async counterpart