cmis: include descriptions in file upload schema (#54661)
This commit is contained in:
parent
2b0966469a
commit
b0da466dae
|
@ -45,29 +45,48 @@ FILE_NAME_PATTERN = r'[\w%s\.]+$' % re.escape(SPECIAL_CHARS)
|
|||
|
||||
UPLOAD_SCHEMA = {
|
||||
'type': 'object',
|
||||
'title': _('CMIS file upload'),
|
||||
'properties': {
|
||||
'file': {
|
||||
'title': _('File object'),
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'filename': {
|
||||
'type': 'string',
|
||||
'description': _('Filename (numbers, letters and special caracters "%s" are allowed)')
|
||||
% SPECIAL_CHARS,
|
||||
'pattern': FILE_NAME_PATTERN,
|
||||
},
|
||||
'content': {'type': 'string'},
|
||||
'content_type': {'type': 'string'},
|
||||
'content': {
|
||||
'type': 'string',
|
||||
'description': _('Content'),
|
||||
},
|
||||
'content_type': {
|
||||
'type': 'string',
|
||||
'description': _('Content type'),
|
||||
},
|
||||
},
|
||||
'required': ['content'],
|
||||
},
|
||||
'filename': {
|
||||
'type': 'string',
|
||||
'description': _('Filename (takes precendence over filename in "file" object)'),
|
||||
'pattern': FILE_NAME_PATTERN,
|
||||
},
|
||||
'path': {
|
||||
'type': 'string',
|
||||
'description': _('File path (with leading but not trailing slash)'),
|
||||
'pattern': FILE_PATH_PATTERN,
|
||||
},
|
||||
'object_type': {'type': 'string'},
|
||||
'properties': {'type': 'object', 'additionalProperties': {'type': 'string'}},
|
||||
'object_type': {
|
||||
'type': 'string',
|
||||
'description': _('CMIS object type'),
|
||||
},
|
||||
'properties': {
|
||||
'type': 'object',
|
||||
'title': _('CMIS properties'),
|
||||
'additionalProperties': {'type': 'string'},
|
||||
},
|
||||
},
|
||||
'required': ['file', 'path'],
|
||||
'unflatten': True,
|
||||
|
|
|
@ -50,7 +50,7 @@ from django.views.generic import (
|
|||
View,
|
||||
)
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
from jsonschema import ValidationError, validate
|
||||
from jsonschema import ValidationError, validate, validators
|
||||
|
||||
from passerelle.base.models import BaseResource, ResourceLog
|
||||
from passerelle.compat import json_loads
|
||||
|
@ -403,6 +403,12 @@ class GenericEndpointView(GenericConnectorMixin, SingleObjectMixin, View):
|
|||
data.update(data.pop('extra', {}))
|
||||
if pre_process is not None:
|
||||
pre_process(self.endpoint.__self__, data)
|
||||
|
||||
# disable validation on description and title in order to allow lazy translation strings
|
||||
validator = validators.validator_for(json_schema)
|
||||
validator.META_SCHEMA['properties'].pop('description', None)
|
||||
validator.META_SCHEMA['properties'].pop('title', None)
|
||||
|
||||
try:
|
||||
validate(data, json_schema)
|
||||
except ValidationError as e:
|
||||
|
|
Loading…
Reference in New Issue