Skip to content
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

Merged
merged 7 commits into from
Jul 8, 2024

Conversation

msyyc
Copy link
Member

@msyyc msyyc commented Jul 4, 2024

fixes #2670

@@ -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]:
Copy link
Member Author

@msyyc msyyc Jul 5, 2024

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:

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

@msyyc msyyc changed the title only construct headers for constant Fix for construct headers and queries when build request Jul 5, 2024
@@ -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"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused variable

@msyyc msyyc marked this pull request as ready for review July 5, 2024 06:35
@iscai-msft iscai-msft merged commit 507d8ca into main Jul 8, 2024
15 checks passed
@iscai-msft iscai-msft deleted the fix-bug-header branch July 8, 2024 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[typespec-python] accept is not defined in generated build request method
2 participants