Skip to content

Commit

Permalink
fix(type-safe-api): fix reversed pydantic minimum and maximum (#908)
Browse files Browse the repository at this point in the history
Correct the generated Pydantic fields so that `minimum` is greater than and `maximum` is less than.

fix #907
  • Loading branch information
jstrunk authored Feb 19, 2025
1 parent adc072f commit e1250a4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const getPythonPydanticConstraints = (property) => {
constraints.max_length = property.maxLength ?? property.maxItems;
}
if (property.minimum !== undefined) {
constraints[property.exclusiveMinimum ? 'lt' : 'le'] = property.minimum;
constraints[property.exclusiveMinimum ? 'gt' : 'ge'] = property.minimum;
}
if (property.maximum !== undefined) {
constraints[property.exclusiveMaximum ? 'gt' : 'ge'] = property.maximum;
constraints[property.exclusiveMaximum ? 'lt' : 'le'] = property.maximum;
}
if (Object.keys(constraints).length > 0) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e1250a4

Please sign in to comment.