Skip to content

Commit

Permalink
Merge pull request #180 from fuhrysteve/customize_schema_base
Browse files Browse the repository at this point in the history
make it easier to customize schema
  • Loading branch information
fuhrysteve authored Oct 26, 2023
2 parents 7446d3d + 1ec8b1b commit 2a9e786
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion marshmallow_jsonschema/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def _from_nested_schema(self, obj, field):
self._nested_schema_classes.update(wrapped_nested._nested_schema_classes)

# and the schema is just a reference to the def
schema = {"type": "object", "$ref": "#/definitions/{}".format(name)}
schema = self._schema_base(name)

# NOTE: doubled up to maintain backwards compatibility
metadata = field.metadata.get("metadata", {})
Expand All @@ -348,6 +348,9 @@ def _from_nested_schema(self, obj, field):

return schema

def _schema_base(self, name):
return {"type": "object", "$ref": "#/definitions/{}".format(name)}

def dump(self, obj, **kwargs):
"""Take obj for later use: using class name to namespace definition."""
self.obj = obj
Expand Down

0 comments on commit 2a9e786

Please sign in to comment.