diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 5c991cf..90e0bc2 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -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** diff --git a/src/drf_yasg/inspectors/field.py b/src/drf_yasg/inspectors/field.py index 32c9d0a..42101ec 100644 --- a/src/drf_yasg/inspectors/field.py +++ b/src/drf_yasg/inspectors/field.py @@ -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( diff --git a/testproj/articles/serializers.py b/testproj/articles/serializers.py index 728c363..e4804a4 100644 --- a/testproj/articles/serializers.py +++ b/testproj/articles/serializers.py @@ -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)