Skip to content

Add configurable response key for get_multi method #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

doubledare704
Copy link
Contributor

@doubledare704 doubledare704 commented Feb 23, 2025

Pull Request Template for FastCRUD

Description

Add multi_response_key parameter to FastCRUD constructor to allow customization of the response key in get_multi results. Default value is "data" for better semantic clarity.

I think it will resolve a #155

Changes

  • Add multi_response_key parameter with default value "data"
  • Replace hardcoded response key with configurable one
  • Maintain backward compatibility with existing implementations

Tests

Added 2 tests to check if response as dict is valid, and if response is model is valid.

Checklist

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • I have added necessary documentation (if appropriate).
  • I have added tests that cover my changes (if applicable).
  • All new and existing tests passed.

Additional Notes

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

@doubledare704 doubledare704 force-pushed the feature/allow-define-key-for-multi-response branch from 6a8cf35 to 2aa727b Compare March 27, 2025 11:05
Add multi_response_key parameter to FastCRUD constructor to allow
customization of the response key in get_multi results. Default
value is "data" for better semantic clarity.

- Add multi_response_key parameter with default value "data"
- Replace hardcoded response key with configurable one
- Maintain backward compatibility with existing implementations
- Update paginated response handling in response.py to support flexible key names
- Modify EndpointCreator to use dynamic response models
- Add create_list_response and create_paginated_response utility functions
- Maintain backward compatibility with existing "data" key

Related files:
- fastcrud/paginated/response.py
- fastcrud/endpoint/endpoint_creator.py
- fastcrud/paginated/schemas.py
@doubledare704 doubledare704 force-pushed the feature/allow-define-key-for-multi-response branch from 13e45d9 to c2ceaf0 Compare April 7, 2025 19:00
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