Open bendavis78 opened 5 years ago
This is indeed something that might need to be addressed. However I believe there are lots of tools which get confused by allOf
constructs, so I think this would need to sit behind a feature flag.
I think there might also be other places where we could use allOf
to improve detailing of schemas.
@bendavis78 removing the line https://github.com/axnsan12/drf-yasg/blob/master/src/drf_yasg/inspectors/field.py#L136 respects the read_only value of the nested serializer. @axnsan12 can you perhaps explain how this works? The comment at https://github.com/axnsan12/drf-yasg/blob/master/src/drf_yasg/openapi.py#L504 does not fully explain why the property is popped.
@hedleyroos because readOnly
is not valid when a Schema
is defined in a definitions
section. It is only valid when it is a direct child of another Schema
via properties
. The proper way to use readOnly
with references is already outlined in the OP.
Soooo, whats' going on in here? Is it going to ever happen?
same issue +1
Same issue: +1
Same issue: +1
Any updates on this?
I think we have to update to https://github.com/tfranzel/drf-spectacular to get this feature...looks like a lot of work.
Serializer fields that point to other serializers and are
read_only
should be marked asreadOnly
in the schema.For example, I have an
AccountSerializer
with a field calleduser
that points toUserSerializer
, and isread_only
. The schema definition for theuser
field is generated as:Instead it should be: