Do not generate readOnly outside Schema properties

openapi3
Cristi Vîjdea 2018-01-01 15:26:26 +01:00
parent 10deea826d
commit 02b72c466e
3 changed files with 13 additions and 12 deletions

View File

@ -182,7 +182,7 @@ class FieldInspector(BaseInspector):
- arguments specified by the ``kwargs`` parameter of :meth:`._get_partial_types`
- ``instance_kwargs`` passed to the constructor function
- ``title``, ``description``, ``required``, ``default`` and ``read_only`` inferred from the field,
- ``title``, ``description``, ``required`` and ``default`` inferred from the field,
where appropriate
If ``existing_object`` is not ``None``, it is updated instead of creating a new object.
@ -233,11 +233,6 @@ class FieldInspector(BaseInspector):
if default is not None:
instance_kwargs['default'] = default
if 'read_only' not in instance_kwargs and swagger_object_type == openapi.Schema:
# TODO: read_only is only relevant for schema `properties` - should not be generated in other cases
if field.read_only:
instance_kwargs['read_only'] = True
instance_kwargs.setdefault('title', title)
instance_kwargs.setdefault('description', description)
instance_kwargs.update(kwargs)

View File

@ -63,11 +63,18 @@ class InlineSerializerInspector(SerializerInspector):
def make_schema_definition():
properties = OrderedDict()
required = []
for key, value in serializer.fields.items():
key = self.get_property_name(key)
properties[key] = self.probe_field_inspectors(value, ChildSwaggerType, use_references)
if value.required:
required.append(key)
for property_name, child in serializer.fields.items():
property_name = self.get_property_name(property_name)
prop_kwargs = {
'read_only': child.read_only or None
}
prop_kwargs = filter_none(prop_kwargs)
properties[property_name] = self.probe_field_inspectors(
child, ChildSwaggerType, use_references, **prop_kwargs
)
if child.required:
required.append(property_name)
return SwaggerType(
type=openapi.TYPE_OBJECT,

View File

@ -1110,7 +1110,6 @@ definitions:
format: slug
pattern: ^[-a-zA-Z0-9_]+$
readOnly: true
readOnly: true
uniqueItems: true
securityDefinitions:
basic: