Fixed small issues for ships endpoint validation

This commit is contained in:
Daniel Schick 2024-07-09 09:04:05 +02:00
parent 3d2e1f5158
commit 83520a2bc7
2 changed files with 5 additions and 5 deletions

View File

@ -45,7 +45,7 @@ def PostShip():
except Exception as ex:
logging.error(ex)
print(ex)
return json.dumps("bad format"), 400
return json.dumps(repr(ex)), 400
return impl.ships.PostShip(loadedModel)
@ -67,7 +67,7 @@ def PutShip():
except Exception as ex:
logging.error(ex)
print(ex)
return json.dumps("bad format"), 400
return json.dumps(repr(ex)), 400
return impl.ships.PutShip(loadedModel)
@ -93,6 +93,6 @@ def DeleteShip():
except Exception as ex:
logging.error(ex)
print(ex)
return json.dumps("bad format"), 400
return json.dumps(repr(ex)), 400
return impl.ships.DeleteShip(options)

View File

@ -11,10 +11,10 @@ def check_if_string_has_special_characters(text:str):
User: https://stackoverflow.com/users/10035985/andrej-kesely
returns bool
"""
return bool(set(text).difference(ascii_letters + digits))
return bool(set(text).difference(ascii_letters + digits + ' '))
def check_if_int_is_valid_flag(value, enum_object):
# e.g., when an IntFlag has the values 1,2,4; the maximum valid value is 7
max_int = sum([int(val) for val in list(enum_object._value2member_map_.values())])
return 0 < value <= max_int
return 0 < value <= max_int