datacontract-cli 0.10.19__py3-none-any.whl → 0.10.21__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of datacontract-cli might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: datacontract-cli
3
- Version: 0.10.19
3
+ Version: 0.10.21
4
4
  Summary: The datacontract CLI is an open source command-line tool for working with Data Contracts. It uses data contract YAML files to lint the data contract, connect to data sources and execute schema and quality tests, detect breaking changes, and export to different formats. The tool is written in Python. It can be used as a standalone CLI tool, in a CI/CD pipeline, or directly as a Python library.
5
5
  Author-email: Jochen Christ <jochen.christ@innoq.com>, Stefan Negele <stefan.negele@innoq.com>, Simon Harrer <simon.harrer@innoq.com>
6
6
  Project-URL: Homepage, https://cli.datacontract.com
@@ -15,8 +15,6 @@ Requires-Dist: typer<0.16,>=0.15.1
15
15
  Requires-Dist: pydantic<2.11.0,>=2.8.2
16
16
  Requires-Dist: pyyaml~=6.0.1
17
17
  Requires-Dist: requests<2.33,>=2.31
18
- Requires-Dist: fastapi==0.115.6
19
- Requires-Dist: uvicorn==0.34.0
20
18
  Requires-Dist: fastjsonschema<2.22.0,>=2.19.1
21
19
  Requires-Dist: fastparquet==2024.11.0
22
20
  Requires-Dist: numpy<2.0.0,>=1.26.4
@@ -51,7 +49,7 @@ Provides-Extra: postgres
51
49
  Requires-Dist: soda-core-postgres<3.4.0,>=3.3.20; extra == "postgres"
52
50
  Provides-Extra: s3
53
51
  Requires-Dist: s3fs==2024.12.0; extra == "s3"
54
- Requires-Dist: aiobotocore<2.18.0,>=2.17.0; extra == "s3"
52
+ Requires-Dist: aiobotocore<2.20.0,>=2.17.0; extra == "s3"
55
53
  Provides-Extra: snowflake
56
54
  Requires-Dist: snowflake-connector-python[pandas]<3.13,>=3.6; extra == "snowflake"
57
55
  Requires-Dist: soda-core-snowflake<3.4.0,>=3.3.20; extra == "snowflake"
@@ -65,13 +63,18 @@ Provides-Extra: dbml
65
63
  Requires-Dist: pydbml>=1.1.1; extra == "dbml"
66
64
  Provides-Extra: parquet
67
65
  Requires-Dist: pyarrow>=18.1.0; extra == "parquet"
66
+ Provides-Extra: api
67
+ Requires-Dist: fastapi==0.115.6; extra == "api"
68
+ Requires-Dist: uvicorn==0.34.0; extra == "api"
69
+ Provides-Extra: custom
70
+ Requires-Dist: Jinja2>=3.1.5; extra == "custom"
68
71
  Provides-Extra: all
69
- Requires-Dist: datacontract-cli[bigquery,csv,databricks,dbml,dbt,iceberg,kafka,parquet,postgres,s3,snowflake,sqlserver,trino]; extra == "all"
72
+ Requires-Dist: datacontract-cli[api,bigquery,csv,custom,databricks,dbml,dbt,iceberg,kafka,parquet,postgres,s3,snowflake,sqlserver,trino]; extra == "all"
70
73
  Provides-Extra: dev
71
74
  Requires-Dist: datacontract-cli[all]; extra == "dev"
72
75
  Requires-Dist: httpx==0.28.1; extra == "dev"
73
76
  Requires-Dist: kafka-python; extra == "dev"
74
- Requires-Dist: moto==5.0.26; extra == "dev"
77
+ Requires-Dist: moto==5.0.27; extra == "dev"
75
78
  Requires-Dist: pandas>=2.1.0; extra == "dev"
76
79
  Requires-Dist: pre-commit<4.1.0,>=3.7.1; extra == "dev"
77
80
  Requires-Dist: pytest; extra == "dev"
@@ -304,7 +307,7 @@ Commands
304
307
  - [diff](#diff)
305
308
  - [catalog](#catalog)
306
309
  - [publish](#publish)
307
- - [serve](#serve)
310
+ - [api](#api)
308
311
 
309
312
  ### init
310
313
  ```
@@ -880,7 +883,7 @@ models:
880
883
  │ vro-idl|sql|sql-query|html| │
881
884
  │ go|bigquery|dbml|spark|sqla │
882
885
  │ lchemy|data-caterer|dcs|mar │
883
- │ kdown|iceberg]
886
+ │ kdown|iceberg|custom]
884
887
  │ --output PATH Specify the file path where │
885
888
  │ the exported data will be │
886
889
  │ saved. If no path is │
@@ -903,6 +906,9 @@ models:
903
906
  │ --engine TEXT [engine] The engine used for │
904
907
  │ great expection run. │
905
908
  │ [default: None] │
909
+ │ --template PATH [custom] The file path of │
910
+ │ Jinja template. │
911
+ │ [default: None] │
906
912
  │ --help Show this message and exit. │
907
913
  ╰──────────────────────────────────────────────────────────────────────────────╯
908
914
  ╭─ RDF Options ────────────────────────────────────────────────────────────────╮
@@ -954,6 +960,7 @@ Available export options:
954
960
  | `dcs` | Export to Data Contract Specification in YAML format | ✅ |
955
961
  | `markdown` | Export to Markdown | ✅ |
956
962
  | `iceberg` | Export to an Iceberg JSON Schema Definition | partial |
963
+ | `custom` | Export to Custom format with Jinja | ✅ |
957
964
  | Missing something? | Please create an issue on GitHub | TBD |
958
965
 
959
966
 
@@ -1135,6 +1142,76 @@ to limit your contract export to a single model.
1135
1142
  }
1136
1143
  ```
1137
1144
 
1145
+ #### Custom
1146
+
1147
+ The export function converts the data contract specification into the custom format with Jinja. You can specify the path to a Jinja template with the `--template` argument, allowing you to output files in any format.
1148
+
1149
+ ```shell
1150
+ datacontract export --format custom --template template.txt datacontract.yaml
1151
+ ```
1152
+
1153
+ ##### Jinja variables
1154
+
1155
+ You can directly use the Data Contract Specification as template variables.
1156
+
1157
+ ```shell
1158
+ $ cat template.txt
1159
+ title: {{ data_contract.info.title }}
1160
+
1161
+ $ datacontract export --format custom --template template.txt datacontract.yaml
1162
+ title: Orders Latest
1163
+ ```
1164
+
1165
+ ##### Example Jinja Templates
1166
+
1167
+ ###### Customized dbt model
1168
+
1169
+ You can export the dbt models containing any logic.
1170
+
1171
+ Below is an example of a dbt staging layer that converts a field of `type: timestamp` to a `DATETIME` type with time zone conversion.
1172
+
1173
+ template.sql
1174
+
1175
+ {% raw %}
1176
+ ```sql
1177
+ {%- for model_name, model in data_contract.models.items() %}
1178
+ {#- Export only the first model #}
1179
+ {%- if loop.first -%}
1180
+ SELECT
1181
+ {%- for field_name, field in model.fields.items() %}
1182
+ {%- if field.type == "timestamp" %}
1183
+ DATETIME({{ field_name }}, "Asia/Tokyo") AS {{ field_name }},
1184
+ {%- else %}
1185
+ {{ field_name }} AS {{ field_name }},
1186
+ {%- endif %}
1187
+ {%- endfor %}
1188
+ FROM
1189
+ {{ "{{" }} ref('{{ model_name }}') {{ "}}" }}
1190
+ {%- endif %}
1191
+ {%- endfor %}
1192
+ ```
1193
+ {% endraw %}
1194
+
1195
+ command
1196
+
1197
+ ```shell
1198
+ datacontract export --format custom --template template.sql --output output.sql datacontract.yaml
1199
+ ```
1200
+
1201
+ output.sql
1202
+
1203
+ ```sql
1204
+ SELECT
1205
+ order_id AS order_id,
1206
+ DATETIME(order_timestamp, "Asia/Tokyo") AS order_timestamp,
1207
+ order_total AS order_total,
1208
+ customer_id AS customer_id,
1209
+ customer_email_address AS customer_email_address,
1210
+ DATETIME(processed_timestamp, "Asia/Tokyo") AS processed_timestamp,
1211
+ FROM
1212
+ {{ ref('orders') }}
1213
+ ```
1214
+
1138
1215
  ### import
1139
1216
  ```
1140
1217
 
@@ -1539,18 +1616,23 @@ datacontract catalog --files "*.odcs.yaml"
1539
1616
 
1540
1617
  ```
1541
1618
 
1542
- ### serve
1619
+ ### api
1543
1620
  ```
1544
-
1545
- Usage: datacontract serve [OPTIONS]
1546
-
1547
- Start the datacontract web server.
1548
-
1549
- ╭─ Options ────────────────────────────────────────────────────────────────────╮
1550
- --port INTEGER Bind socket to this port. [default: 4242] │
1551
- --host TEXT Bind socket to this host. [default: 127.0.0.1] │
1552
- │ --help Show this message and exit. │
1553
- ╰──────────────────────────────────────────────────────────────────────────────╯
1621
+
1622
+ Usage: datacontract api [OPTIONS]
1623
+
1624
+ Start the datacontract CLI as server application with REST API.
1625
+ The OpenAPI documentation as Swagger UI is available on http://localhost:4242. You can execute the commands directly from the Swagger UI.
1626
+ To protect the API, you can set the environment variable DATACONTRACT_CLI_API_KEY to a secret API key. To authenticate, requests must include the header 'x-api-key' with the
1627
+ correct API key. This is highly recommended, as data contract tests may be subject to SQL injections or leak sensitive information.
1628
+ To connect to servers (such as a Snowflake data source), set the credentials as environment variables as documented in https://cli.datacontract.com/#test
1629
+
1630
+ ╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
1631
+ │ --port INTEGER Bind socket to this port. [default: 4242] │
1632
+ │ --host TEXT Bind socket to this host. Hint: For running in docker, set it to 0.0.0.0 [default: 127.0.0.1] │
1633
+ │ --help Show this message and exit. │
1634
+ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
1635
+
1554
1636
 
1555
1637
  ```
1556
1638
 
@@ -1708,7 +1790,7 @@ class CustomExporter(Exporter):
1708
1790
 
1709
1791
 
1710
1792
  # Register the new custom class into factory
1711
- exporter_factory.register_exporter("custom", CustomExporter)
1793
+ exporter_factory.register_exporter("custom_exporter", CustomExporter)
1712
1794
 
1713
1795
 
1714
1796
  if __name__ == "__main__":
@@ -1718,7 +1800,7 @@ if __name__ == "__main__":
1718
1800
  )
1719
1801
  # Call export
1720
1802
  result = data_contract.export(
1721
- export_format="custom", model="orders", server="production", custom_arg="my_custom_arg"
1803
+ export_format="custom_exporter", model="orders", server="production", custom_arg="my_custom_arg"
1722
1804
  )
1723
1805
  print(result)
1724
1806
 
@@ -1,8 +1,8 @@
1
1
  datacontract/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- datacontract/cli.py,sha256=LCXFYd8kN4yrsgLlG8ZaYBkIRmbNWtpWaFH6GdgIMSo,17100
2
+ datacontract/api.py,sha256=qZJr8I5MI4wZlvjUEAvqna9Xj5Ic2GCBxSyogBlKEbE,8166
3
+ datacontract/cli.py,sha256=5pt8xYYezGyCT5YM_N4rwtm6bkY5q-j0PuQVAzJg5fc,18174
3
4
  datacontract/data_contract.py,sha256=KzsF4xvMWZnyTrwL7YDE0_dYWrWG9Bn7efCmW3vK5SI,14767
4
5
  datacontract/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- datacontract/web.py,sha256=MePB-XJvTZObMzrk3tIW8-bAvk-QcEEt767RVos3Zoc,2105
6
6
  datacontract/breaking/breaking.py,sha256=vUjPZzGsOF_ufTjdKa2T_gjQgPtZrZKytmcatkUr7ck,20428
7
7
  datacontract/breaking/breaking_rules.py,sha256=OKwYWCMkIob2uX8zxav7LbIhx_6RC4msioBjuNlox1k,4060
8
8
  datacontract/catalog/catalog.py,sha256=wmv_2BBxHhNBlilAmQHHhNe4tK14DowkyIOVaQW2DWU,2691
@@ -27,12 +27,13 @@ datacontract/export/avro_converter.py,sha256=xNRo0eXR3n--EA8SziarWqhlvOYtQWkWJtE
27
27
  datacontract/export/avro_idl_converter.py,sha256=SGO7JfI9UGXLYFR5wMGNUH1qf6kt9lF6dUU9roVqnFo,9878
28
28
  datacontract/export/bigquery_converter.py,sha256=VSBdVGWrlar18ETzgNArxDzk8Zt5JcAc_wKjfwLpG_A,4734
29
29
  datacontract/export/csv_type_converter.py,sha256=ZZuJwBgQnafZC7PPvAXsBf2IajPJq8TYZ1l8Qq0GYeI,1290
30
+ datacontract/export/custom_converter.py,sha256=xb8KbkRRgHmT4ewwC7XxtnKpe_ZMSJWBjYOaKjmO_KQ,1216
30
31
  datacontract/export/data_caterer_converter.py,sha256=eSEuy3TbqUIG_lHYEBOydAgp_CJNoGArXrcJvh81wcw,5984
31
32
  datacontract/export/dbml_converter.py,sha256=f_OZEFwRUyL-Kg2yn_G58I8iz1VfFrZh8Nbw3Wq0JDo,4777
32
33
  datacontract/export/dbt_converter.py,sha256=BPvcKyT-v1C_zcYh8ocn5qeNVUjTjYIcMVxnq8BY-Us,10342
33
34
  datacontract/export/dcs_exporter.py,sha256=RALQ7bLAjak7EsoFFL2GFX2Oju7pnCDPCdRN_wo9wHM,210
34
- datacontract/export/exporter.py,sha256=b9z5vjY5dsc0Nw-gG03RkNYyOuidMk-RGkS9GAE-elk,3051
35
- datacontract/export/exporter_factory.py,sha256=sW6-43FiOFTzqgho2jvSzhd7_PGqWApfKOnfFFzjs90,6021
35
+ datacontract/export/exporter.py,sha256=kRg1Ka6t9g2PuTZJyYSah0l0SfBXO9X6_FUuHDjs81o,3073
36
+ datacontract/export/exporter_factory.py,sha256=IhLqLiBNDtP1PpaOxu1OqlbRfpeBoWYqomrv97LlRz8,6175
36
37
  datacontract/export/go_converter.py,sha256=Ttvbfu3YU-3GBwRD6nwCsFyZuc_hiIvJD-Jg2sT5WLw,3331
37
38
  datacontract/export/great_expectations_converter.py,sha256=zMaHaj5DLj_Q_q-iFEa7EZHW-qHdFMxWL4MiMIFKV80,10505
38
39
  datacontract/export/html_export.py,sha256=ojazWrb0AwSc7Vr72M_otMo-3PA8mfi8tfIy9BCXk9o,2578
@@ -75,7 +76,7 @@ datacontract/lint/lint.py,sha256=Ew0n3ooXxmCVnUxJ_cDoacsD82QdMZYnKrxnG9J0sWQ,507
75
76
  datacontract/lint/resolve.py,sha256=_QtoAReUhiJ8I_4fyNimyUnHhpZGYmmDHFA59wUTeFw,10684
76
77
  datacontract/lint/resources.py,sha256=nfeZmORh1aP7EKpMKCmfbS04Te8pQ0nz64vJVkHOq3c,647
77
78
  datacontract/lint/schema.py,sha256=4pYX6JX6SkASftyqaWTodKFRVPi2qV0_Z60tvaCOk80,1813
78
- datacontract/lint/urls.py,sha256=W7Edcd8Iw4NjokVtuSshEfzsXshQpuh_tpO73aM9dsM,2294
79
+ datacontract/lint/urls.py,sha256=giac0eAYa6hha8exleL3KsiPtiFlOq8l53axtAmCilw,2529
79
80
  datacontract/lint/linters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
80
81
  datacontract/lint/linters/description_linter.py,sha256=7fla7FQwDa-1UrLFCFKFoeUzkR91e4o9W6ySKSW6_U8,1555
81
82
  datacontract/lint/linters/example_model_linter.py,sha256=tmgxGxC-GzMUxFumTOuuASdz9ZlncBZHasPGJsWnDT8,3973
@@ -85,26 +86,27 @@ datacontract/lint/linters/notice_period_linter.py,sha256=6r413aEVOVHWJHb33-68ecV
85
86
  datacontract/lint/linters/quality_schema_linter.py,sha256=ZXFHlMLFV1GZejizbUdfW6-msffFECoDGNsdynaPnog,2182
86
87
  datacontract/lint/linters/valid_constraints_linter.py,sha256=qTFh1X3I9wOtAxuXlvbGesCQ3GQ6iWc-MT_ttIybRsw,4916
87
88
  datacontract/model/breaking_change.py,sha256=BIDEUo1U2CQLVT2-I5PyFttxAj6zQPI1UUkEoOOQXMY,2249
88
- datacontract/model/data_contract_specification.py,sha256=HsHllx4-Uk-K9LSQspja9OwI2fSavzAsZ4C4pfuPl48,8123
89
+ datacontract/model/data_contract_specification.py,sha256=1bEE7hQJEjzoL4XtCQBmPe6VWclU_D_YiUJW2oNRNos,8655
89
90
  datacontract/model/exceptions.py,sha256=zW9NoyzwsND-c9UqgyTVuezUVGEc6KK1Uc2zl12loyo,1178
90
91
  datacontract/model/odcs.py,sha256=9PXwm72FASjNwteF1Jn591iP3-St0aq16Cpsk0PkEW8,389
91
- datacontract/model/run.py,sha256=zIosfMAKB3WVsWN3UcFQteHaQ04SlYZX45opaRXklNw,2827
92
+ datacontract/model/run.py,sha256=LGYlMlS5NlNhkBE10n_U6DEqaiLybag6Og_RZ_W9xgs,2826
92
93
  datacontract/schemas/datacontract-1.1.0.init.yaml,sha256=_WQX6NRwimXlPVKcKeHLd4mFL0TJ2vYH0WnyMXZeQ8Y,1828
93
94
  datacontract/schemas/datacontract-1.1.0.schema.json,sha256=3Bu2rxEjkF6dNLcqi1GF4KoXBnEIopaJ87Qb8S4zUvg,62872
94
95
  datacontract/schemas/odcs-3.0.1.schema.json,sha256=bRZsSXA0fV0EmV_8f1K68PlXu1m4K7JcuHpLnY3ESwQ,72933
95
- datacontract/templates/datacontract.html,sha256=gCq5pfFR-L9DLznVjrUlvyQe597h5lZzD7xpQum_OEM,14534
96
+ datacontract/templates/datacontract.html,sha256=9rm5hLkST8EnOFwj0al9c0xPajzlyWlnfxT2iicSRCM,15179
96
97
  datacontract/templates/index.html,sha256=nyi9nrEsSPuOrXszKzqkqwZGveXsdy1PLJp2g9oDw0A,12517
97
98
  datacontract/templates/partials/datacontract_information.html,sha256=7ZBxgEgi2XndKBypeOpe03oCSRPOujC6NVlN7zexGNM,6221
98
99
  datacontract/templates/partials/datacontract_servicelevels.html,sha256=ed3QgB11B0Qq2h_NwaroGZ4pQMBPEhfeQaoS-qEipqY,11401
99
100
  datacontract/templates/partials/datacontract_terms.html,sha256=1cnJcOTpxwot2BCuZmkLF_SPfiVloLs3c8mj9WfE4sc,1865
100
- datacontract/templates/partials/definition.html,sha256=SveQlfdTyCHuAu3455VXL8_Cgv298lD_dgtdwA_YaAg,7461
101
+ datacontract/templates/partials/definition.html,sha256=gZEmNvwNGGxA_Fnzx_0L6tXlAMk_EAPWr5ziRIThb_o,1005
101
102
  datacontract/templates/partials/example.html,sha256=F1dWbHDIXQScgfs4OVgqM1lR4uV4xX5j6suasXHNM88,1204
102
- datacontract/templates/partials/model_field.html,sha256=QA0U95hHthEc66AjSYk4Di24hU-pHZbef0Sz-hSpdGM,7215
103
+ datacontract/templates/partials/model_field.html,sha256=2YBF95ypNCPFYuYKoeilRnDG-H_FuW4JK1znkCaYCac,7625
104
+ datacontract/templates/partials/quality.html,sha256=ynEDWRn8I90Uje-xhGYgFcfwOgKI1R-CDki-EvTsauQ,1785
103
105
  datacontract/templates/partials/server.html,sha256=WkWFbz1ZvhIAUQQhH5Lkwb0HZRW907ehEnFmJSkpquQ,6235
104
- datacontract/templates/style/output.css,sha256=F3oEhUpuv8kA_dWr4pJymBS_Ju6huIIZdLMkJzPzMmU,25647
105
- datacontract_cli-0.10.19.dist-info/LICENSE,sha256=23h64qnSeIZ0DKeziWAKC-zBCt328iSbRbWBrXoYRb4,2210
106
- datacontract_cli-0.10.19.dist-info/METADATA,sha256=hF27km7hZIRpbFfD0rshENziv1IO80ZhVOGRXKLjF_k,98715
107
- datacontract_cli-0.10.19.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
108
- datacontract_cli-0.10.19.dist-info/entry_points.txt,sha256=D3Eqy4q_Z6bHauGd4ppIyQglwbrm1AJnLau4Ppbw9Is,54
109
- datacontract_cli-0.10.19.dist-info/top_level.txt,sha256=VIRjd8EIUrBYWjEXJJjtdUgc0UAJdPZjmLiOR8BRBYM,13
110
- datacontract_cli-0.10.19.dist-info/RECORD,,
106
+ datacontract/templates/style/output.css,sha256=V1k6smSvlz07W2UNOkhcDFUb0HLmoas7DnNg_o8XUcA,25759
107
+ datacontract_cli-0.10.21.dist-info/LICENSE,sha256=23h64qnSeIZ0DKeziWAKC-zBCt328iSbRbWBrXoYRb4,2210
108
+ datacontract_cli-0.10.21.dist-info/METADATA,sha256=uquXgiucFDTjcXNkkj04No0TxtEjo9fOU7bgrot8qVY,102667
109
+ datacontract_cli-0.10.21.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
110
+ datacontract_cli-0.10.21.dist-info/entry_points.txt,sha256=D3Eqy4q_Z6bHauGd4ppIyQglwbrm1AJnLau4Ppbw9Is,54
111
+ datacontract_cli-0.10.21.dist-info/top_level.txt,sha256=VIRjd8EIUrBYWjEXJJjtdUgc0UAJdPZjmLiOR8BRBYM,13
112
+ datacontract_cli-0.10.21.dist-info/RECORD,,
datacontract/web.py DELETED
@@ -1,67 +0,0 @@
1
- from typing import Annotated, Optional, Union
2
-
3
- import typer
4
- from fastapi import FastAPI, File
5
- from fastapi.responses import HTMLResponse, PlainTextResponse
6
-
7
- from datacontract.data_contract import DataContract, ExportFormat
8
-
9
- app = FastAPI()
10
-
11
-
12
- @app.get("/", response_class=HTMLResponse)
13
- def index():
14
- # TODO OpenAPI spec
15
- return """
16
- <html>
17
- <body>
18
- <h1>datacontract web server</h1>
19
- <ul>
20
- <li>POST /lint</li>
21
- <li>POST /export</li>
22
- </ul>
23
- </body>
24
- </html>
25
- """
26
-
27
-
28
- @app.post("/lint")
29
- def lint(file: Annotated[bytes, File()], linters: Union[str, set[str]] = "all"):
30
- data_contract = DataContract(data_contract_str=str(file, encoding="utf-8"))
31
- lint_result = data_contract.lint(enabled_linters=linters)
32
- return {"result": lint_result.result, "checks": lint_result.checks}
33
-
34
-
35
- @app.post("/export", response_class=PlainTextResponse)
36
- def export(
37
- file: Annotated[bytes, File()],
38
- export_format: Annotated[ExportFormat, typer.Option(help="The export format.")],
39
- server: Annotated[str, typer.Option(help="The server name to export.")] = None,
40
- model: Annotated[
41
- str,
42
- typer.Option(
43
- help="Use the key of the model in the data contract yaml file "
44
- "to refer to a model, e.g., `orders`, or `all` for all "
45
- "models (default)."
46
- ),
47
- ] = "all",
48
- rdf_base: Annotated[
49
- Optional[str],
50
- typer.Option(help="[rdf] The base URI used to generate the RDF graph.", rich_help_panel="RDF Options"),
51
- ] = None,
52
- sql_server_type: Annotated[
53
- Optional[str],
54
- typer.Option(
55
- help="[sql] The server type to determine the sql dialect. By default, it uses 'auto' to automatically detect the sql dialect via the specified servers in the data contract.",
56
- rich_help_panel="SQL Options",
57
- ),
58
- ] = "auto",
59
- ):
60
- result = DataContract(data_contract_str=str(file, encoding="utf-8"), server=server).export(
61
- export_format=export_format,
62
- model=model,
63
- rdf_base=rdf_base,
64
- sql_server_type=sql_server_type,
65
- )
66
-
67
- return result