A couple of parameter serializers to contribute #3264
Unanswered
rafalkrupinski
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wrote a couple of helper functions for parameter serialization. It took some research to figure how to implement them properly, so I thought I would share them, but I feel the implementation is too trivial for a separate project.
They are specific to httpx, so perhaps they'd find a loving home here.
HTTP and related RFC define a couple of serialization methods for path and query parameters, headers and cookies. OpenAPI has a comprehensive guide.
Httpx on the other hand only allows one specific serialization method for each of the request parts, which is sufficient but requires users to prepare data if they need to use another method.
The methods allow passing single level dictionaries and collections either as multiple values (using iterables of tuples) or as a single values (serialized to string). They also convert simple scalar types to strings.
code is here: https://github.com/python-lapidary/lapidary/blob/develop/src/lapidary/runtime/model/param_serialization.py
and tests https://github.com/python-lapidary/lapidary/blob/develop/tests/test_param_serialization.py
Functions are grouped into classes but that could be adjusted.
File also contains deserialisation code, but it still needs clean-up.
Beta Was this translation helpful? Give feedback.
All reactions