Skip to content

Using list_route_info to overwrite path is not working #307

@oburla-centumd

Description

@oburla-centumd

Which is because it provides it's attrs adding them to provided ones without using dict.

list_items = self._route_factory.list(
    path="/",
    schema_out=kw.pop("schema_out", self._retrieve_schema),  # type:ignore[arg-type]
    **kw,  # type:ignore[arg-type]
    **paginate_kwargs,
)

instead, why wouldn't we make it whole dict to support overwriting?

list_items = self._route_factory.list(**{
    "path": "/",
    "schema_out": kw.pop("schema_out", self._retrieve_schema),  # type:ignore[arg-type]
    **kw,  # type:ignore[arg-type]
    **paginate_kwargs,
})

or if you want to trigger error if pagination fields interfere with base ones, you may keep them separate.

list_items = self._route_factory.list(
    **{
        "path": "/",
        "schema_out": kw.pop("schema_out", self._retrieve_schema),  # type:ignore[arg-type]
        **kw,  # type:ignore[arg-type]
    }
    **paginate_kwargs,
)

similar applies to the other builder methods. Now to make it working you have to add an endpoint with the factory which seems as an overkill to just change a few options. I assume, making a good use of these *_route_info dicts might remove any need of using the factory for the base actions when using model_config.

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