Use a fixed example date

This commit is contained in:
mvdbeek
2022-12-05 18:51:18 +01:00
parent 47ff70af8e
commit d707507f46
+3 -12
View File
@@ -18,12 +18,7 @@ from galaxy.structured_app import MinimalManagerApp
log = logging.getLogger(__name__)
def datetime_to_iso8601(utc_datetime: datetime) -> str:
"""
Returns the date as string with ISO8601 format.
i.e: 2021-01-23T18:25:43.511Z
"""
return f"{utc_datetime.isoformat()}Z"
SOME_EXAMPLE_DATE = "2021-01-23T18:25:43.511Z"
class Metric(BaseModel):
@@ -36,7 +31,7 @@ class Metric(BaseModel):
..., # Required
title="Timestamp",
description="The timestamp in ISO format.",
example=datetime_to_iso8601(datetime.utcnow()),
example=SOME_EXAMPLE_DATE,
)
level: int = Field(
..., # Required
@@ -54,11 +49,7 @@ class CreateMetricsPayload(BaseModel):
metrics: List[Metric] = Field(
default=[],
title="List of metrics to be recorded.",
example=[
Metric(
namespace="test-source", time=datetime_to_iso8601(datetime.utcnow()), level=0, args='{"test":"value"}'
)
],
example=[Metric(namespace="test-source", time=SOME_EXAMPLE_DATE, level=0, args='{"test":"value"}')],
)