Open yeralin opened 5 years ago
Actually, it might be a problem in marshmallow
package, when I try to resolve:
test_schema.fields['test'].container.container.name
it returns None
(on doubly nested schema) vs. when I call test_schema.fields['test'].container.name
, it returns test
(on singly nested schema).
Raised an issue under marhsmallow core repo: https://github.com/marshmallow-code/marshmallow/issues/1355
Ok, after the investigation of this issue under the marshmallow core repo, it was discovered that this bug was fixed in 3.0, but not in 2.0! And they can't fix it in 2.0 bc it will not be backwards compatible...
Then, their maintainer added:
As far as fuhrysteve/marshmallow-jsonschema#87 is concerned, I would recommend checking for None and omitting the title. I don't think title's are require for json-schema fields and they don't seem to provide any useful context in this situation.
What do you think? @fuhrysteve
How about this: completely skip title
(since it is not required by JSON Schema specification) if either field.attribute
or field.name
are None
?
Created a PR
Singly nested schema list like:
Works just fine:
But if you add another level of nestness, it will start generating
null
values for titles which doesn't conform to JSON Schema specifications. To reproduce:Will yield: