Skip to content

Error parsing enum value on query #281

@ehooo

Description

@ehooo

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions