diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a544383..b630f86c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added import glue (#166) - Added test support for `azure` (#146) - Added support for `delta` tables on S3 (#24) - Added new command `datacontract catalog` that generates a data contract catalog with an `index.html` file. - +- Added field format information to HTML export + ### Fixed - RDF Export: Fix error if owner is not a URI/URN diff --git a/datacontract/breaking/breaking_rules.py b/datacontract/breaking/breaking_rules.py index 1520272a..ca36f1c5 100644 --- a/datacontract/breaking/breaking_rules.py +++ b/datacontract/breaking/breaking_rules.py @@ -20,6 +20,10 @@ class BreakingRules: field_ref_removed = Severity.WARNING field_ref_updated = Severity.WARNING + field_title_added = Severity.INFO + field_title_removed = Severity.INFO + field_title_updated = Severity.INFO + field_type_added = Severity.WARNING field_type_removed = Severity.WARNING field_type_updated = Severity.ERROR diff --git a/datacontract/model/data_contract_specification.py b/datacontract/model/data_contract_specification.py index 8788f64d..3decdfa8 100644 --- a/datacontract/model/data_contract_specification.py +++ b/datacontract/model/data_contract_specification.py @@ -63,6 +63,7 @@ class Definition(pyd.BaseModel): class Field(pyd.BaseModel): ref: str = pyd.Field(default=None, alias="$ref") ref_obj: Definition = pyd.Field(default=None, exclude=True) + title: str = None type: str = None format: str = None required: bool = None @@ -95,6 +96,7 @@ class Model(pyd.BaseModel): class Info(pyd.BaseModel): title: str = None version: str = None + status: str = None description: str = None owner: str = None contact: Contact = None diff --git a/datacontract/templates/datacontract.html b/datacontract/templates/datacontract.html index 3cc86384..2138f190 100644 --- a/datacontract/templates/datacontract.html +++ b/datacontract/templates/datacontract.html @@ -78,6 +78,13 @@
+ |
{{ model_name }}
{{ model.type }}
{{ model.description }}
@@ -366,28 +373,81 @@
{% for field_name, field in model.fields.items() %}
+ |
|
-
- {{ field_name }}
+ {% if field.title %}
+
{{ field.title }}
+ {% endif %}
+ {{ field_name }}
{# TODO nested fields #}
- {% if field.required %}
- R
- {% endif %}
- {% if field.unique %}
- U
- {% endif %}
- |
{% if field.type %}
{{ field.type }}
{% endif %}
|
- |
{{ field.description or "No description" }}
- {# TODO add format information #}
+ {% if field.description %}
+ {{ field.description }}
+ {% else %}
+ No description
+ {% endif %}
+
+ {% if field.example %}
+
+ Example: {{ field.example }}
+
+ {% endif %}
+
+
+ {% if field.primary %}
+ primary
+ {% endif %}
+ {% if field.required %}
+ required
+ {% endif %}
+ {% if field.unique %}
+ unique
+ {% endif %}
+ {% if field.format %}
+ format:{{ field.format }}
+ {% endif %}
+ {% if field.minLength %}
+ minLength:{{ field.minLength }}
+ {% endif %}
+ {% if field.maxLength %}
+ maxLength:{{ field.maxLength }}
+ {% endif %}
+ {% if field.pattern %}
+ pattern:{{ field.pattern }}
+ {% endif %}
+ {% if field.precision %}
+ precision:{{ field.precision }}
+ {% endif %}
+ {% if field.scale %}
+ scale:{{ field.scale }}
+ {% endif %}
+ {% if field.minimum %}
+ minimum:{{ field.minimum }}
+ {% endif %}
+ {% if field.exclusiveMinimum %}
+ exclusiveMinimum:{{ field.exclusiveMinimum }}
+ {% endif %}
+ {% if field.maximum %}
+ maximum:{{ field.maximum }}
+ {% endif %}
+ {% if field.exclusiveMaximum %}
+ exclusiveMaximum:{{ field.exclusiveMaximum }}
+ {% endif %}
+ {% if field.classification %}
+ {{ field.classification }}
+ {% endif %}
+ {% if field.pii %}
+ PII
+ {% endif %}
+
+
|
---|