Skip to content

Add QueryMask#97

Merged
Tishka17 merged 11 commits into
reagento:developfrom
neocim:add-query-mask
May 12, 2026
Merged

Add QueryMask#97
Tishka17 merged 11 commits into
reagento:developfrom
neocim:add-query-mask

Conversation

@neocim

@neocim neocim commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

This class allows to create masks to convert the names of certain query parameters through a regular expression.

Usage:

class Api:
    @rest.get("/", QueryMask(lambda n: n.upper(), "^p.*$"))
    # only `phone_number` converts to `PHONE_NUMBER`
    def do_get(self, user_id: int, phone_number: str) -> Model: ...

If we need to set a default QueryMask for all rest methods, we can do it by setting QueryMask in RestBuilder:

# we may not to use regex
query_mask = QueryMask(lambda n: n.upper())
rest = RestBuilder(query_mask)

class Api:
    # parameters `a`, `b`, `c` will be converted to the ​​`A`, `B`, and `C` respectively, 
    # but `d` will be ignored, because it is an explicit query parameter
    @rest.get("/", Query("d"))
    def do_get(self, a: int, b: int, c: int, d: int) -> Model: ...

@neocim neocim force-pushed the add-query-mask branch 3 times, most recently from 8fb02fd to 314602b Compare April 22, 2026 17:55
@neocim neocim force-pushed the add-query-mask branch 4 times, most recently from 98dfc6f to e2c38ff Compare April 23, 2026 13:49
@sonarqubecloud

Copy link
Copy Markdown

@Tishka17 Tishka17 merged commit b5bfdc3 into reagento:develop May 12, 2026
8 checks passed
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.

2 participants