From 60bc3438c834f7cafa0e997b75471bada06a4f83 Mon Sep 17 00:00:00 2001 From: Anna Trzcinska Date: Fri, 15 Nov 2019 14:16:04 +0100 Subject: [PATCH] schemas: add SimplifiedSchemaSerializer Signed-off-by: Anna Trzcinska --- cap/modules/schemas/serializers.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cap/modules/schemas/serializers.py b/cap/modules/schemas/serializers.py index 36f0e7c652..7871d98c23 100644 --- a/cap/modules/schemas/serializers.py +++ b/cap/modules/schemas/serializers.py @@ -25,10 +25,10 @@ import copy from flask import url_for -from invenio_jsonschemas.proxies import current_jsonschemas -from marshmallow import Schema, ValidationError, fields, pre_load, validate from cap.utils import url_to_api_url +from invenio_jsonschemas.proxies import current_jsonschemas +from marshmallow import Schema, ValidationError, fields, pre_load, validate from .validators import JSONSchemaValidator @@ -102,6 +102,15 @@ def filter_out_fields_that_cannot_be_updated(self, data, **kwargs): return data +class SimplifiedSchemaSerializer(Schema): + """Simplified serializer for schema.""" + + name = fields.Str(dump_only=True, required=True) + version = fields.Str(dump_only=True, required=True, + validate=validate.Regexp(regex=r"(\d+).(\d+).(\d+)")) + fullname = fields.Str(dump_only=True) + + class ResolvedSchemaSerializer(SchemaSerializer): """Schema serializer with resolved jsonschemas.""" @@ -125,5 +134,6 @@ def get_resolved_record_schema(self, obj): schema_serializer = SchemaSerializer() +simplified_schema_serializer = SimplifiedSchemaSerializer() update_schema_serializer = UpdateSchemaSerializer() resolved_schemas_serializer = ResolvedSchemaSerializer()