Skip to content

Commit

Permalink
fix conint confloat args (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
koxudaxi authored May 19, 2020
1 parent 258f214 commit 9bc3229
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions datamodel_code_generator/model/pydantic/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def get_data_int_type(types: Types, **kwargs: Any) -> DataType:
return DataType(
type='conint',
is_func=True,
kwargs=data_type_kwargs,
kwargs={k: int(v) for k, v in data_type_kwargs.items()},
imports_=[IMPORT_CONINT],
)
return type_map[types]
Expand All @@ -125,7 +125,7 @@ def get_data_float_type(types: Types, **kwargs: Any) -> DataType:
return DataType(
type='confloat',
is_func=True,
kwargs=data_type_kwargs,
kwargs={k: float(v) for k, v in data_type_kwargs.items()},
imports_=[IMPORT_CONFLOAT],
)
return type_map[types]
Expand Down
2 changes: 1 addition & 1 deletion docs/jsonschema.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The codegen generate pydantic models from JsonSchema
## Example

```bash
$ datamodel-codegen --input person.json --input-file-type jsonshema --output model.py
$ datamodel-codegen --input person.json --input-file-type jsonschema --output model.py
```

`person.json`:
Expand Down
8 changes: 4 additions & 4 deletions tests/model/pydantic/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_get_data_int_type(types, params, data_type):
DataType(
type='confloat',
is_func=True,
kwargs={'lt': 10},
kwargs={'lt': 10.0},
imports_=[IMPORT_CONFLOAT],
),
),
Expand All @@ -94,7 +94,7 @@ def test_get_data_int_type(types, params, data_type):
DataType(
type='confloat',
is_func=True,
kwargs={'ge': 10},
kwargs={'ge': 10.0},
imports_=[IMPORT_CONFLOAT],
),
),
Expand All @@ -104,7 +104,7 @@ def test_get_data_int_type(types, params, data_type):
DataType(
type='confloat',
is_func=True,
kwargs={'gt': 10},
kwargs={'gt': 10.0},
imports_=[IMPORT_CONFLOAT],
),
),
Expand All @@ -114,7 +114,7 @@ def test_get_data_int_type(types, params, data_type):
DataType(
type='confloat',
is_func=True,
kwargs={'multiple_of': 10},
kwargs={'multiple_of': 10.0},
imports_=[IMPORT_CONFLOAT],
),
),
Expand Down
2 changes: 1 addition & 1 deletion tests/parser/test_jsonschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_json_schema_object_ref_url():
"""class Pets(BaseModel):
firstName: Optional[str] = None
lastName: Optional[str] = None
age: Optional[conint(ge=0.0)] = None""",
age: Optional[conint(ge=0)] = None""",
)
],
)
Expand Down
2 changes: 1 addition & 1 deletion tests/parser/test_openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ class AllOfobj(BaseModel):
class AllOfCombine(Pet):
birthdate: Optional[date] = None
size: Optional[conint(ge=1.0)] = None
size: Optional[conint(ge=1)] = None
class AnyOfCombine(Pet, Car):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def test_main_autodetect():
class Person(BaseModel):
firstName: Optional[str] = Field(None, description="The person\'s first name.")
lastName: Optional[str] = Field(None, description="The person\'s last name.")
age: Optional[conint(ge=0.0)] = Field(
age: Optional[conint(ge=0)] = Field(
None, description='Age in years which must be equal to or greater than zero.'
)
friends: Optional[List] = None
Expand Down Expand Up @@ -396,7 +396,7 @@ def test_main_jsonschema():
class Person(BaseModel):
firstName: Optional[str] = Field(None, description="The person\'s first name.")
lastName: Optional[str] = Field(None, description="The person\'s last name.")
age: Optional[conint(ge=0.0)] = Field(
age: Optional[conint(ge=0)] = Field(
None, description='Age in years which must be equal to or greater than zero.'
)
friends: Optional[List] = None
Expand Down

0 comments on commit 9bc3229

Please sign in to comment.