hypothesis-jsonschema
hypothesis-jsonschema copied to clipboard
from_schema mutates the passed-in schema
Ran into this when I used a Pydantic.BaseModel.schema() as the argument to from_schema. Pydantic caches the schemas of its models, so this caused unexpected changes elsewhere. I think this happens if the schema uses $refs.
It's easy to work around by passing a deepcopy, but I find this behaviour surprising, and it took a while to figure out.
Thanks for the great lib though, it helped a lot! Kind regards, Daniel
Looks like we can fix that in
https://github.com/Zac-HD/hypothesis-jsonschema/blob/7094f9d93031743a99c2ea2c1388b2f23fc6a698/src/hypothesis_jsonschema/_resolve.py#L71-L88