From 1ec8b1b86c758595825390dceb190702334ff831 Mon Sep 17 00:00:00 2001 From: "Stephen J. Fuhry" Date: Thu, 26 Oct 2023 08:39:22 -0400 Subject: [PATCH] make it easier to customize schema --- marshmallow_jsonschema/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/marshmallow_jsonschema/base.py b/marshmallow_jsonschema/base.py index 1096363..2db5a3d 100644 --- a/marshmallow_jsonschema/base.py +++ b/marshmallow_jsonschema/base.py @@ -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", {}) @@ -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