Skip to content

Commit 5e384a3

Browse files
authored
Merge pull request #277 from SmartAPI/fix-bte-filter
removed default name setting, fix issue#275
2 parents ce0268f + 2540b68 commit 5e384a3

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/handlers/api.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -464,25 +464,22 @@ async def get(self, *args, **kwargs):
464464
def get_filtered_api(self, api_dict):
465465
"""Extract and return filtered API information."""
466466
api_info = api_dict
467-
468467
if not self.args.bte and not self.args.api_details: # no bte and no api details
469468
filtered_api= {
470-
'name': api_info.get('name', 'Default Name'),
471-
'smartapi': {
472-
'id': api_info.get('smartapi', {}).get('id', 'Default ID')
473-
}
469+
**({"name": api_info["name"]} if "name" in api_info else {}),
470+
**({"smartapi": {"id": api_info["smartapi"]["id"]}} if "smartapi" in api_info and "id" in api_info["smartapi"] else {})
474471
}
475472
elif self.args.bte and not self.args.api_details : # bte and no api details
476473
filtered_api= {
477-
'name': api_info.get('name', 'Default Name'),
478-
'smartapi': {
479-
'id': api_info.get('smartapi', {}).get('id', 'Default ID')
480-
},
474+
**({"name": api_info["name"]} if "name" in api_info else {}),
475+
**({"smartapi": {"id": api_info["smartapi"]["id"]}} if "smartapi" in api_info and "id" in api_info["smartapi"] else {}),
481476
'bte': api_info.get('bte', {})
482477
}
483478
elif not self.args.bte and self.args.api_details: # no bte and api details
484479
api_info.pop('bte', None)
485-
filtered_api= api_info
480+
filtered_api = api_info
481+
else:
482+
filtered_api = api_info
486483
return filtered_api
487484

488485
def process_apis(self, apis):

0 commit comments

Comments
 (0)