Skip to content

Commit

Permalink
Handle swagger_extra_fields in field_to_swagger_object (#142)
Browse files Browse the repository at this point in the history
* Move add_manual_fields call to make_schema_definition
* Do not call add_manual_fields twice
  • Loading branch information
andrewyager authored and axnsan12 committed Jun 16, 2018
1 parent 54ad904 commit 4825ec7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/drf_yasg/inspectors/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ def add_manual_fields(self, serializer, schema):
setattr(schema, attr, val)

def get_schema(self, serializer):
result = self.probe_field_inspectors(serializer, openapi.Schema, self.use_definitions)
schema = openapi.resolve_ref(result, self.components)
self.add_manual_fields(serializer, schema)
return result
return self.probe_field_inspectors(serializer, openapi.Schema, self.use_definitions)

def add_manual_parameters(self, serializer, parameters):
"""Add/replace parameters from the given list of automatically generated request parameters. This method
Expand Down Expand Up @@ -117,6 +114,10 @@ def make_schema_definition():
# but is visually displayed like the model name, which is confusing
# it is better to just remove title from inline models
del result.title

# Provide an option to add manual paremeters to a schema
# for example, to add examples
self.add_manual_fields(field, result)
return result

if not ref_name or not use_references:
Expand Down

0 comments on commit 4825ec7

Please sign in to comment.