from skylines.model import Airspace, Location


def get_airspaces_by_location(location):
    if not isinstance(location, Location):
        raise TypeError('Invalid `location` parameter.')

    airspaces = Airspace.by_location(location)
    return map(airspace_to_dict, airspaces)


def airspace_to_dict(airspace):
    return {
        'name': airspace.name,
        'base': airspace.base,
        'top': airspace.top,
        'airspace_class': airspace.airspace_class,
        'country': airspace.country_code,
    }

@@ -1,8 +1,62 @@
+from skylines.api.schemas import airspace_list_schema%0A
 from sky
@@ -245,328 +245,120 @@
     
-airspaces = Airspace.by_location(location)%0A    return map(airspace_to_dict, airspaces)%0A%0A%0Adef airspace_to_dict(airspace):%0A    return %7B%0A        'name': airspace.name,%0A        'base': airspace.base,%0A        'top': airspace.top,%0A        'airspace_class': airspace.airspace_class,%0A        'country': airspace.country_code,%0A    %7D
+data, errors = airspace_list_schema.dump(%0A        Airspace.by_location(location).all(), many=True)%0A%0A    return data
 %0A

Use AirspaceSchema class for serialization