Skip to content

Commit cfa0198

Browse files
author
Edvard Majakari
committed
Show example of map_params
1 parent c19bb30 commit cfa0198

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,18 @@ You can also easily add any Falcon style middleware using:
265265
__hug__.http.add_middleware(MiddlewareObject())
266266
```
267267

268+
**Parameter mapping** can be used to override inferred parameter names, eg. for reserved keywords:
269+
270+
```py
271+
import marshmallow.fields as fields
272+
...
273+
274+
@hug.get('/foo', map_params={'from': 'from_date'}) # API call uses 'from'
275+
def get_foo_by_date(from_date: fields.DateTime()):
276+
return find_foo(from_date)
277+
```
278+
279+
Input formatters are mapped based on the `content_type` of the request data, and only perform basic parsing. More detailed parsing should be done by the Type Annotations present on your `api_function`
268280

269281
Splitting APIs over multiple files
270282
===================

0 commit comments

Comments
 (0)