Skip to content

Commit 9ee557e

Browse files
committed
feat: Re-enable WorkSearchScheme field name mapping and update AllAllowedParams to handle underscore prefixes with aliases.
1 parent d774d7e commit 9ee557e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

openlibrary/fastapi/search.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,17 @@ def pagination(
4141

4242

4343
field_names = set(WorkSearchScheme.all_fields) | set(
44-
# WorkSearchScheme.field_name_map.keys()
45-
# Temporarily commented out because field names can't start with underscores but we have _ia_collection
44+
WorkSearchScheme.field_name_map.keys()
4645
)
4746

48-
4947
# Dynamically create the model
5048
AllAllowedParams = create_model(
5149
'AllAllowedParams',
5250
__base__=BaseModel,
53-
**{name: (str | None, Query(None)) for name in field_names},
51+
**{
52+
field.removeprefix('_'): (str | None, Query(None, alias=field))
53+
for field in field_names
54+
},
5455
)
5556

5657

0 commit comments

Comments
 (0)