HealthITAU / pyconnectwise

A library for simplifying interactions with the ConnectWise Manage API in Python
https://healthit.com.au
GNU General Public License v3.0
42 stars 7 forks source link

Opt out of Pydantic validation altogether. #2

Closed mendykrauss closed 1 year ago

mendykrauss commented 1 year ago

How do we do that?

Yoshify commented 1 year ago

Hi Mendykrauss. This is handled for you already under the hood. Pydantic models are typically constructed (with validation) from model(**json) or model.parse_obj(**json) - instead we're using model.construct(**json) to build the models but skip validation.

We've overridden the method to support nested models, which isn't something that Pydantic supports out of the box.

You can check out the implementation here: https://github.com/HealthITAU/pyconnectwise/blob/6b8361ee4d01af910037bd5e4291b157151723f7/src/pyconnectwise/models/base/connectwise_model.py#L15-L49