(confloat(gt=5, lt=10), { 'exclusiveMinimum': 5, 'exclusiveMaximum': 10 }), (confloat(ge=5, le=10), { 'minimum': 5, 'maximum': 10 }), (PositiveFloat, { 'exclusiveMinimum': 0 }), (NegativeFloat, { 'exclusiveMaximum': 0 }), (ConstrainedDecimal, {}), (condecimal(gt=5, lt=10), { 'exclusiveMinimum': 5, 'exclusiveMaximum': 10 }), (condecimal(ge=5, le=10), { 'minimum': 5, 'maximum': 10 }), ], ) def test_special_float_types(field_type, expected_schema): class Model(BaseModel): a: field_type base_schema = { 'title': 'Model',
base_schema['properties']['a'].update(expected_schema) assert Model.schema() == base_schema @pytest.mark.parametrize( 'field_type,expected_schema', [ (ConstrainedFloat, {}), (confloat(gt=5, lt=10), {'exclusiveMinimum': 5, 'exclusiveMaximum': 10}), (confloat(ge=5, le=10), {'minimum': 5, 'maximum': 10}), (confloat(multiple_of=5), {'multipleOf': 5}), (PositiveFloat, {'exclusiveMinimum': 0}), (NegativeFloat, {'exclusiveMaximum': 0}), (ConstrainedDecimal, {}), (condecimal(gt=5, lt=10), {'exclusiveMinimum': 5, 'exclusiveMaximum': 10}), (condecimal(ge=5, le=10), {'minimum': 5, 'maximum': 10}), (condecimal(multiple_of=5), {'multipleOf': 5}), ], ) def test_special_float_types(field_type, expected_schema): class Model(BaseModel): a: field_type base_schema = { 'title': 'Model', 'type': 'object', 'properties': {'a': {'title': 'A', 'type': 'number'}}, 'required': ['a'], } base_schema['properties']['a'].update(expected_schema)
}), (confloat(ge=5, le=10), { 'minimum': 5, 'maximum': 10 }), (confloat(multiple_of=5), { 'multipleOf': 5 }), (PositiveFloat, { 'exclusiveMinimum': 0 }), (NegativeFloat, { 'exclusiveMaximum': 0 }), (ConstrainedDecimal, {}), (condecimal(gt=5, lt=10), { 'exclusiveMinimum': 5, 'exclusiveMaximum': 10 }), (condecimal(ge=5, le=10), { 'minimum': 5, 'maximum': 10 }), (condecimal(multiple_of=5), { 'multipleOf': 5 }), ], ) def test_special_float_types(field_type, expected_schema): class Model(BaseModel): a: field_type