Skip to content

Commit d976f1f

Browse files
Joakim Nordlinglietu
andauthored
Apply suggestions from code review
Co-authored-by: Janne Enberg <janne.enberg@lietu.net>
1 parent fd566ce commit d976f1f

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

openapi_to_fastapi/model_generator.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,16 @@ class definition (after the imports at the top) and injecting a comment and then
169169
)
170170

171171
if "AwareDatetime" in file_content or "date" in file_content:
172-
newline = "\n"
172+
nl = "\n"
173173
if "\r\n" in file_content:
174-
newline = "\r\n"
174+
nl = "\r\n"
175175

176-
parts = file_content.partition(f"{newline}{newline}class ")
176+
parts = file_content.partition(f"{nl}{nl}class ")
177177
file_content = (
178-
f"{parts[0]}{newline}"
179-
f"{comment}{newline}"
180-
f"{import_strict_date_time}{newline}"
181-
f"{import_strict_date}{newline}"
178+
f"{parts[0]}{nl}"
179+
f"{comment}{nl}"
180+
f"{import_strict_date_time}{nl}"
181+
f"{import_strict_date}{nl}"
182182
f"{parts[1]}{parts[2]}"
183183
)
184184

openapi_to_fastapi/pydantic_validators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def strict_datetime_validator(value: Any) -> str:
2929

3030
raise PydanticCustomError(
3131
"datetime_type",
32-
"Input should be a valid datetime, input is not a string",
32+
"Input should be a valid datetime in RFC 3339 format, input is not a string",
3333
{"error": "input not string"},
3434
)
3535

@@ -62,7 +62,7 @@ def strict_date_validator(value: Any) -> str:
6262

6363
raise PydanticCustomError(
6464
"date_type",
65-
"Input should be a valid date, input is not a string",
65+
"Input should be a valid date in RFC3339 'full-date' format, input is not a string",
6666
{"error": "input not string"},
6767
)
6868

0 commit comments

Comments
 (0)