Closed mgd020 closed 5 years ago
Hi @fuhrysteve @mgd020 , could you please clarify what's the status of this PR? I wouldn't mind implementing any of the corrections needed myself to get this into master.
@atmo Not a question for me. Its ready to merge
@mgd020
I was expecting the PR to show any merge conflicts?
Also, cant see any comments above your one this morning.
Looking at the PR changes it does not create a new object?
@mgd020 but there is one. Have a look at marshmallow_jsonschema/base.py
, line 190. You're getting a class from a schema instance in case this object is indeed an instance of SchemaABC
. Then you're using this class to instantiate a schema on the line 205. However, my argument is that you don't need to do that in case field.nested
is already an instance. Just check whether field.nested
is a class and a subclass of Schema
and if so, use it to instantiate an object. Otherwise, do nothing.
Here is a sample code how it might look like:
from inspect import isclass
...
if name not in self._nested_schema_classes and name != outer_name:
wrapped_nested = JSONSchema(nested=True)
if isclass(nested) and issubclass(nested, SchemaABC):
nested = nested(only=only, exclude=exclude, context=context)
wrapped_dumped = wrapped_nested.dump(nested)
...
For this to work you'll have to also get rid of elif isinstance(field.nested, SchemaABC):
check on line 189.
Does it make sense?
I was using mobile view so could not see the "conflicts". Also, I expect there to be conflicts after almost a year!
I have not looked at the code recently, but I would guess that it still needs to create a new instance as only and exclude are passed in.
I am happy for you to take over this PR / fix, as I no longer have time to fix this.
@mgd020 Sure, no problem. @fuhrysteve , please close this PR in favor of #74 and let's continue discussion there.
Also isort imports in
base.py
and ignored.pytest_cache
Fix for #18