Skip to content

Order of method decorators is not arbitrary #284

@vonZeppelin

Description

@vonZeppelin

Describe the bug
The decorator that specifies HTTP method and URI must be the "closest" to a Consumer method in order to the rest of decorators have any effect.

To Reproduce

class ApiConsumer(Consumer):
    # Content-Type header WILL be set
    @headers({"Content-Type": "text/plain"})
    @post("foo")
    def foo(self, file: Body):
        ...

    # Content-Type header WILL NOT be set
    @post("bar")
    @headers({"Content-Type": "text/plain"})
    def bar(self, file: Body):
        ...

Expected behavior
Order of decorators doesn't matter OR documentation explicitly states that @http_method decorator must be the "last" one.

Additional context
All code examples actually have @http_method decorator applied last, but I couldn't find mentions of importance of that 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions