guardicode / monkeytypes

A collection of types and models used by Infection Monkey
GNU General Public License v3.0
1 stars 1 forks source link

Fix incomplete PercentLimited JSON schema generation #19

Closed mssalvatore closed 5 months ago

mssalvatore commented 5 months ago

When migrating from Pydantic 1 to Pydantic 2, this detail was missed. The schema generated for PercentLimited did not include the maximum. The type's schema needed to be redefined using Annotated in order to add the maximum to the JSON schema.

mssalvatore commented 5 months ago

So the PercentLimited model would reject a value outside the [0, 100] range, but this was not being reflected in the schema?

Correct. There's a validator function that enforces validation.