Skip to content

feat: export a default custom property as the pydantic field default - #1701

Closed
amassoudi wants to merge 1 commit into
datacontract:mainfrom
amassoudi:feat/pydantic-default-custom-property
Closed

amassoudi wants to merge 1 commit into
datacontract:mainfrom
amassoudi:feat/pydantic-default-custom-property

Conversation

@amassoudi

Copy link
Copy Markdown
Contributor

datacontract export pydantic-model reads a default custom property on an optional property and emits it as the field default (pydantic.Field(default='NON', pattern=...), or = 'NON' without constraints). Required fields and non-scalar values are ignored. datacontract import pydantic-model writes a scalar field default back to the same custom property, so the round trip stays lossless.

Closes #1700

  • Tests pass (uv run pytest)
  • Code formatted (uv run ruff check --fix && uv run ruff format)
  • Docs updated (if relevant)
  • CHANGELOG.md entry added

@amassoudi

Copy link
Copy Markdown
Contributor Author

A default describes how a consumer interprets a missing value, not the data itself, so it belongs to the ingestion step rather than to the exporter. I keep the value in my contract as a custom property for my own tooling. The logicalTypeOptions constraints from #1678 cover the important part.

I closed related issue and I close this PR

@amassoudi amassoudi closed this Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

export pydantic-model: no way to declare a default value for an optional property

2 participants