Skip to content

Commit

Permalink
schemas: add SimplifiedSchemaSerializer
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Trzcinska <[email protected]>
  • Loading branch information
annatrz committed Nov 15, 2019
1 parent e6089aa commit 60bc343
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cap/modules/schemas/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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."""

Expand All @@ -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()

0 comments on commit 60bc343

Please sign in to comment.