def handle_extra_payload(payload, api_model):
 if (type(payload) != dict):
  return payload
 data = payload.copy()
 for key in payload:
  if (key not in api_model):
   del data[key]
  elif isinstance(api_model[key], fields.Nested):
   data[key] = handle_extra_payload(data[key], api_model[key].model)
  elif isinstance(api_model[key], fields.List):
   temp = []
   for _ in payload[key]:
    temp.append(handle_extra_payload(_, api_model[key].container))
   data[key] = temp
 return data

def handle_extra_payload ( payload , api_model ) : if ( type ( payload ) != dict ) : return payload data = payload . copy ( ) for key in payload : if ( key not in api_model ) : del data [ key ] elif isinstance ( api_model [ key ] , fields . Nested ) : data [ key ] = handle_extra_payload ( data [ key ] , api_model [ key ] . model ) elif isinstance ( api_model [ key ] , fields . List ) : temp = [ ] for _ in payload [ key ] : temp . append ( handle_extra_payload ( _ , api_model [ key ] . container ) ) data [ key ] = temp return data
handles extra keys in payload .