Skip to content

Add new method req.get_param_as_dict() #2542

@vytas7

Description

@vytas7

As we are planning to add OpenAPI spec affordances down the 4.x road, we'll need to make adjustments to our request utility methods.

We should add a helper for getting a param as OAS "object", the suggested method name is req.get_param_as_dict():

  • required – Set to True to raise HTTPBadRequest instead of returning None when the parameter is not found (default False).
  • deep_object – Set to True to use the deepObject (as in OAS) format. Note that this would deviate from other param methods as it would aggregate the return value from multiple parameters following the deep object name pattern.
  • delimiter – TBD (?) When not using deep_object, to get elements from delimited list items, depends on Add delimiter support to req.get_param_as_list() #2538.
  • store – A dict-like object in which to place the value of the param, but only if the param is found (default None).
  • default – If the param is not found returns the given value instead of None.

When not using deep_object, we would basically assert that the number of items from get_param_as_list() is even, and zip it pairwise to return a dict.

We could also name the method req.get_param_as_object(), but since other get_param_as_* methods follow the Python types, req.get_param_as_dict() probably sounds more fitting?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issueComment on this issue if you'd like to volunteer to work on this. Thanks!

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions