Ejemplo n.º 1
0
class SwaggerMethodSerializer(serpy.Serializer):
    consumes = LiteralField(None, display_none=False)
    produces = LiteralField(["application/json"])
    responses = SwaggerResponseSerializer(attr='output_type')
    parameters = SwaggerParamSerializer(many=True)
    summary = serpy.Field()
    operationId = serpy.Field(attr='id')
    tags = serpy.Field()
Ejemplo n.º 2
0
class PlacesCommonSerializer(serpy.DictSerializer):
    '''
    Warning: This class share it's interface with PlaceSerializer (for Kraken)
    If you add/modify fields here, please reflect your changes in
    'jormungandr.jormungandr.interfaces.v1.serializer.pt.PlaceSerializer'.
    '''

    id = NestedPropertyField(attr='properties.geocoding.id', display_none=True)
    name = NestedPropertyField(attr='properties.geocoding.name', display_none=True)
    quality = LiteralField(0, deprecated=True)
    distance = StringNestedPropertyField(attr='distance', display_none=False, required=False)
    embedded_type = LiteralField("administrative_region", display_none=True)
Ejemplo n.º 3
0
class PoiSerializer(PbGenericSerializer):
    coord = CoordSerializer(required=False)
    label = jsonschema.Field(schema_type=str)
    administrative_regions = AdminSerializer(many=True, display_none=False)
    poi_type = PoiTypeSerializer(display_none=False)
    properties = jsonschema.MethodField(
        schema_metadata={'type': 'object', 'additionalProperties': {'type': 'string'}}
    )
    address = AddressSerializer()
    stands = LiteralField(None, schema_type=StandsSerializer, display_none=False)
    car_park = LiteralField(None, schema_type=CarParkSerializer, display_none=False)

    def get_properties(self, obj):
        return {p.type: p.value for p in obj.properties}
Ejemplo n.º 4
0
class JsonSchemaEndpointsSerializer(serpy.Serializer):
    basePath = LiteralField('/' + BASE_PATH)
    swagger = LiteralField('2.0')
    host = LambdaField(lambda *args: request.url_root.replace('http://', '').
                       replace('https://', '').rstrip('/'))
    paths = MethodField()
    definitions = serpy.Field()
    info = LambdaField(lambda s, o: JsonSchemaInfo(o).data)
    securityDefinitions = LambdaField(
        lambda s, o: SecurityDefinitionsSerializer(o).data)
    security = LiteralField([{'basicAuth': []}])

    def get_paths(self, obj):
        return {k: SwaggerPathSerializer(v).data for k, v in obj.paths.items()}
Ejemplo n.º 5
0
class GeocodeStopAreaSerializer(PlacesCommonSerializer):
    embedded_type = LiteralField("stop_area", display_none=True)
    name = NestedPropertyField(attr='properties.geocoding.label', display_none=True)
    stop_area = jsonschema.MethodField()

    def get_stop_area(self, obj):
        return StopAreaSerializer(obj).data
Ejemplo n.º 6
0
class GeocodePoiSerializer(PlacesCommonSerializer):
    embedded_type = LiteralField("poi", display_none=True)
    name = NestedPropertyField(attr='properties.geocoding.label', display_none=True)
    poi = jsonschema.MethodField()

    def get_poi(self, obj):
        return PoiSerializer(obj).data
Ejemplo n.º 7
0
class GeocodeAddressSerializer(PlacesCommonSerializer):
    embedded_type = LiteralField("address", display_none=True)
    id = CoordId(display_none=True)
    name = NestedPropertyField(attr='properties.geocoding.label', display_none=True)
    address = jsonschema.MethodField()

    def get_address(self, obj):
        return AddressSerializer(obj).data
Ejemplo n.º 8
0
class JsonSchemaInfo(serpy.Serializer):
    title = LiteralField('navitia')
    version = LiteralField(_version.__version__)
    description = LiteralField("""
    navitia.io is the open API for building cool stuff with mobility data. It provides the following services

    * journeys computation
    * line schedules
    * next departures
    * exploration of public transport data / search places
    * and sexy things such as isochrones

    navitia is a HATEOAS API that returns JSON formated results
    """)
    contact = LiteralField({
        'name': 'Navitia',
        'url': 'https://www.navitia.io/',
        'email': '*****@*****.**'
    })
    license = LiteralField({
        'name': 'license',
        'url': 'https://www.navitia.io/api-term-of-use'
    })
Ejemplo n.º 9
0
class SecurityDefinitionsSerializer(serpy.Serializer):
    basicAuth = LiteralField({'type': 'basic'})