igorbenav / fastcrud

FastCRUD is a Python package for FastAPI, offering robust async CRUD operations and flexible endpoint creation utilities.
MIT License
530 stars 32 forks source link

Simplified endpoints #105

Closed JakNowy closed 1 day ago

JakNowy commented 1 week ago

Pull Request Template for FastCRUD

Description

This PR implements https://github.com/igorbenav/fastcrud/issues/67. It covers 2 issues:

  1. It provides support for passing empty endpoint_names to fastcrud.crud_router() without redundant // in generated paths

    endpoint_names = {
    "create": "",
    "read": "",
    "update": "",
    "delete": "",
    "db_delete": "",
    "read_multi": "",
    "read_paginated": "get_paginated",
    }
  2. It mixes existing _read_paginated endpoint logic into _read_items. Now "page" and "items_per_page" query parameters can be passed to _read_paginated resulting in same behavour. I also confirmed that old-style request for _read_items persist it's functinality. Default:

  'http://localhost:8000/users/get_multi?offset=0&limit=100' \
  -H 'accept: application/json'

works for both and new _read_items.

  1. Appropriate warning have been added as needed.

  2. I've added small update to advanced filters AND clauses documentation.

Tests

Describe the tests you added or modified to cover your changes, if applicable.

Checklist

Additional Notes

Include any additional information that you think is important for reviewers to know.

JakNowy commented 4 days ago

@igorbenav are you ok with this direction? Ultimately I would love to see plain endpoints the default behaviour, as well as read_paginated dropped and mixed into read_items. But those changes are breaking, so the question arises are you planning any major breaking release soon or should I just keep the changes minimalistic for now?

igorbenav commented 3 days ago

If we really use the simplified as the default, the changes are breaking in nature. I believe the best approach for the first version of this is:

igorbenav commented 3 days ago

Then, after this, we may merge a fully breaking version without the warnings. Let's say 0.14.x has this warnings, 0.15.0 implements the breaking changes

JakNowy commented 2 days ago

@igorbenav feel free to review!

igorbenav commented 2 days ago

Other than the warning, I think it's just missing the pagination stuff and the deprecation warnings in the docs here and it's good to go

igorbenav commented 1 day ago

Nice one, @JakNowy, thanks!