-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for construct headers and queries when build request #2681
Conversation
packages/typespec-python/generator/pygen/codegen/serializers/builder_serializer.py
Outdated
Show resolved
Hide resolved
@@ -410,14 +410,19 @@ def _json_response_template_name(self) -> str: | |||
return "response.json()" | |||
|
|||
@staticmethod | |||
def declare_non_inputtable_constants(builder: RequestBuilderType) -> List[str]: | |||
def declare_non_inputtable_headers_queries(builder: RequestBuilderType) -> List[str]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used for "construct headers and queries" so we had better update the function name with its usage scenario:
autorest.python/packages/typespec-python/generator/pygen/codegen/serializers/builder_serializer.py
Lines 469 to 498 in 3b89887
def serialize_headers(self, builder: RequestBuilderType) -> List[str]: | |
headers = [ | |
h | |
for h in builder.parameters.headers | |
if not builder.has_form_data_body or h.wire_name.lower() != "content-type" | |
] | |
retval = ["# Construct headers"] if headers else [] | |
for header in headers: | |
retval.extend( | |
self.parameter_serializer.serialize_query_header( | |
header, | |
"headers", | |
self.serializer_name, | |
self.code_model.is_legacy, | |
) | |
) | |
return retval | |
def serialize_query(self, builder: RequestBuilderType) -> List[str]: | |
retval = ["# Construct parameters"] | |
for parameter in builder.parameters.query: | |
retval.extend( | |
self.parameter_serializer.serialize_query_header( | |
parameter, | |
"params", | |
self.serializer_name, | |
self.code_model.is_legacy, | |
) | |
) | |
return retval |
@@ -117,7 +117,6 @@ def build_put_referenced_constant_request(**kwargs: Any) -> HttpRequest: | |||
|
|||
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) | |||
accept = _headers.pop("Accept", "application/json") | |||
color_constant = "green-color" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused variable
fixes #2670