Avoid marking read_only fields as required (#133)
* Avoid marking read_only fields as required Read only properties cannot be marked as required by a schema.openapi3
parent
a4a11ad1ab
commit
408b31fc4f
|
|
@ -36,7 +36,7 @@ You want to contribute some code? Great! Here are a few steps to get you started
|
|||
$ virtualenv venv
|
||||
$ source venv/bin/activate
|
||||
(venv) $ pip install -e .[validation]
|
||||
(venv) $ pip install -rrequirements/dev.txt "Django>=1.11.7"
|
||||
(venv) $ pip install -r requirements/dev.txt
|
||||
|
||||
#. **Make your changes and check them against the test project**
|
||||
|
||||
|
|
|
|||
|
|
@ -67,10 +67,12 @@ class InlineSerializerInspector(SerializerInspector):
|
|||
}
|
||||
prop_kwargs = filter_none(prop_kwargs)
|
||||
|
||||
properties[property_name] = self.probe_field_inspectors(
|
||||
child_schema = self.probe_field_inspectors(
|
||||
child, ChildSwaggerType, use_references, **prop_kwargs
|
||||
)
|
||||
if child.required:
|
||||
properties[property_name] = child_schema
|
||||
|
||||
if child.required and not getattr(child_schema, 'read_only', False):
|
||||
required.append(property_name)
|
||||
|
||||
result = SwaggerType(
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ArticleSerializer(serializers.ModelSerializer):
|
|||
read_only=True,
|
||||
)
|
||||
uuid = serializers.UUIDField(help_text="should articles have UUIDs?", read_only=True)
|
||||
cover_name = serializers.FileField(use_url=False, source='cover', read_only=True)
|
||||
cover_name = serializers.FileField(use_url=False, source='cover', required=True)
|
||||
group = serializers.SlugRelatedField(slug_field='uuid', queryset=ArticleGroup.objects.all())
|
||||
original_group = serializers.SlugRelatedField(slug_field='uuid', read_only=True)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue