Example #1
0
    class JsonchemaSupportedType(serpy.Serializer):
        jsonschemaStrField = StrField(required=False)
        jsonschemaBoolField = BoolField(required=True, display_none=True)
        jsonschemaFloatField = FloatField(required=True, display_none=True)
        jsonschemaIntField = IntField()
        jsonschemaField = Field(schema_type=int)
        jsonschemaMethodField = MethodField(schema_type=str)
        lambda_schema = LambdaField(method=lambda **kw: None, schema_type=Custom())
        list_lambda_schema = LambdaField(method=lambda **kw: None,
                                         schema_type=Custom(many=True))

        def get_jsonschemaMethodField(self, obj):
            pass
Example #2
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()}
Example #3
0
class CoverageSerializer(NullableDictSerializer):
    id = Field(attr="region_id",
               schema_type=str,
               display_none=True,
               description='Identifier of the coverage')
    start_production_date = Field(
        schema_type=str,
        description='Beginning of the production period. '
        'We only have data on this production period',
    )
    end_production_date = Field(
        schema_type=str,
        description='End of the production period. '
        'We only have data on this production period',
    )
    last_load_at = LambdaField(
        method=lambda _, o: CoverageDateTimeField('last_load_at').to_value(o),
        description='Datetime of the last data loading',
        schema_type=str,
    )
    name = Field(schema_type=str,
                 display_none=True,
                 description='Name of the coverage')
    status = Field(schema_type=str)
    shape = Field(schema_type=str,
                  display_none=True,
                  description='GeoJSON of the shape of the coverage')
    error = CoverageErrorSerializer(display_none=False)
    dataset_created_at = Field(schema_type=str,
                               description='Creation date of the dataset')
Example #4
0
class SwaggerParamSerializer(serpy.Serializer):
    description = Field()
    location = Field(label='in')
    name = StrField()
    required = Field()
    type = StrField()
    default = StrField()
    enum = Field()
    minimum = Field()
    maximum = Field()
    format = Field()
    collectionFormat = Field(attr='collection_format')
    items = LambdaField(
        method=lambda _, obj: SwaggerParamSerializer(obj.items).data if obj.items else None, display_none=False
    )
Example #5
0
class ContextSerializer(PbNestedSerializer):
    car_direct_path = LambdaField(lambda _, obj: CO2Serializer(obj, display_none=True).data,
                                  schema_type=CO2Serializer())
Example #6
0
class SwaggerOptionPathSerializer(serpy.Serializer):
    get = LambdaField(method=lambda _, obj: SwaggerMethodSerializer(obj.methods.get('get')).data)
    definitions = serpy.Field()