Skip to content

Commit

Permalink
feature/mx-1555_remove_datetime_validation_format (#78)
Browse files Browse the repository at this point in the history
# PR Context
<!-- Additional info for the reviewer -->

# Added
<!-- New features and interfaces -->

# Changes
<!-- Changes in existing functionality -->

# Deprecated
<!-- Soon-to-be removed features -->

# Removed

- date-time format validation for mapping model generation

# Fixed
<!-- Fixed bugs -->

# Security
<!-- Fixed vulnerabilities -->
  • Loading branch information
erichesse authored Feb 20, 2024
1 parent 419520e commit 70077dc
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 29 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changes

### Deprecated

### Removed

### Fixed

### Security

## [0.19.4] - 2024-02-15

### Added

### Changes

- update cruft and minor dependencies

### Deprecated

### Removed

- date-time format validation for mapping model generation

### Fixed

### Security
Expand Down
1 change: 0 additions & 1 deletion mex/common/types/timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ def __get_pydantic_json_schema__(
"""Modify the schema to add the class name as title and examples."""
json_schema = handler(core_schema_)
json_schema["title"] = cls.__name__
json_schema["format"] = "date-time"
json_schema["examples"] = [
"2011",
"2019-03",
Expand Down
52 changes: 26 additions & 26 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mex-common"
version = "0.19.3"
version = "0.19.4"
description = "Common library for MEx python projects."
authors = ["RKI MEx Team <[email protected]>"]
readme = "README.md"
Expand Down
6 changes: 5 additions & 1 deletion tests/models/test_model_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from mex.common.models import EXTRACTED_MODEL_CLASSES_BY_NAME
from mex.common.transform import dromedary_to_kebab
from mex.common.types.identifier import MEX_ID_PATTERN
from mex.common.types.timestamp import TIMESTAMP_REGEX

SPECIFIED_SCHEMA_PATH = files("mex.model").joinpath("entities")

Expand Down Expand Up @@ -121,7 +122,10 @@ def prepare_field(field: str, obj: list[Any] | dict[str, Any]) -> None:
# ignore differences between dates and datetimes
# (we only have `Timestamp` as a date-time implementation, but no type for `date`,
# but we might/should add that in the future)
if obj.get("format") in ("date", "date-time"):
if (
obj.get("format") in ("date", "date-time")
or obj.get("pattern") == TIMESTAMP_REGEX
):
obj.pop("examples", None)
obj.pop("pattern", None)
obj["format"] = "date-time"
Expand Down

0 comments on commit 70077dc

Please sign in to comment.