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

Error parsing enum value on query #281

Open
ehooo opened this issue Oct 27, 2022 · 1 comment · May be fixed by #282
Open

Error parsing enum value on query #281

ehooo opened this issue Oct 27, 2022 · 1 comment · May be fixed by #282

Comments

@ehooo
Copy link

ehooo commented Oct 27, 2022

Describe the bug
When try to send enum values the payload send is the string of the class

To Reproduce
Execute the following code:

from enum import Enum

class OptionType(Enum):
    OP1 = 'FirstOp'
    OP2 = 'SecondOp'
    OP3 = 'ThirdOp'


class SomeAPI(Consumer):
    @returns.json()
    @get("/path")
    def list_elements(self,
                   option_type: Query(type=OptionType),
                   page: Query(type=int) = 0,
                   limit: Query(type=int) = 100
                   ):
        """ Get list """
        ...

if __name__ == '__main__':
    session = requests.Session()
    client = SomeAPI('http://localhost:5000', client=session)
    resp = client.list_elements(option_type=OptionType.OP1)

The payload send to the server is:
{'option_type': 'OptionType.OP1', 'page': '0', 'limit': '100'}

Expected behavior
The payload expected is:
{'option_type': 'FirstOp', 'page': '0', 'limit': '100'}

Additional context
I think the issue is on the function Sequence.convert

@ehooo
Copy link
Author

ehooo commented Oct 27, 2022

I will try to fix it and adding test when i have some time to do it

ehooo added a commit to ehooo/uplink that referenced this issue Oct 27, 2022
ehooo added a commit to ehooo/uplink that referenced this issue Oct 27, 2022
@ehooo ehooo linked a pull request Nov 19, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants