Skip to content

Commit

Permalink
Fixed generating Marshmallow DateTime formats
Browse files Browse the repository at this point in the history
  • Loading branch information
expobrain committed Aug 28, 2024
1 parent 5ec8e5c commit 47f20ce
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/apispec/ext/marshmallow/field_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,13 +574,25 @@ def datetime2properties(self, field, **kwargs: typing.Any) -> dict:
"example": "1676451277514.654",
"min": "0",
}
elif field.format is not None:
ret = {
"type": "string",
"format": None,
"pattern": (
field.metadata["pattern"]
if field.metadata.get("pattern")
else None
),
}
else:
ret = {
"type": "string",
"format": None,
"pattern": field.metadata["pattern"]
if field.metadata.get("pattern")
else None,
"pattern": (
field.metadata["pattern"]
if field.metadata.get("pattern")
else None
),
}
return ret

Expand Down

0 comments on commit 47f20ce

Please sign in to comment.