Only allow supported search types to /search, /regenerate APIs

- Use a SearchType to limit types that can be passed by user
- FastAPI automatically validates type passed in query param
- Available type options show up in Swagger UI, FastAPI docs
- controller code looks neater instead of doing string comparisons for type
- Test invalid, valid search types via pytest
This commit is contained in:
Debanjum Singh Solanky
2021-09-29 19:02:55 -07:00
parent 150593c776
commit 81ce0cacc3
3 changed files with 58 additions and 10 deletions

9
src/utils/config.py Normal file
View File

@@ -0,0 +1,9 @@
from enum import Enum
class SearchType(str, Enum):
Notes = "notes"
Ledger = "ledger"
Music = "music"
Image = "image"