fuhrysteve / marshmallow-jsonschema

JSON Schema Draft v7 (http://json-schema.org/) formatting with marshmallow
MIT License
209 stars 72 forks source link

Add definitions_path argument to __init__ for customization #179

Open mrtedn21 opened 1 year ago

mrtedn21 commented 1 year ago

of resulting json schema, where schemas are placed

fuhrysteve commented 1 year ago

Thanks for the PR! I thought about it for a minute, and it seems that making a method that you can override for this would add less complexity. So I made & merged this PR #180

If you are working off of the latest master, you should now be able to override the _schema_base method:

from marshmallow_jsonschema import JSONSchema
class MyJSONSchema(JSONSchema):
    def _schema_base(self, name):
        return {"type": "object", "$ref": "#/anything_you_want_here/{}".format(name)}

Let me know if that works for you!

mrtedn21 commented 1 year ago

O thanx, it is good solution, but method "wrap" with "post_dump" decorator, that creates resulting json_schema dict, it anyway hardcode with '#/definitions/'