Skip to content

Conversation

@gautierc-thelio
Copy link

@gautierc-thelio gautierc-thelio commented Jul 4, 2025

  • Tests pass
  • ruff format
  • README.md updated (if relevant)
  •  CHANGELOG.md entry added

Closes #814

- Update README to document usage of --spec with custom export and template variables.
- Add CLI validation to prevent usage of --spec with formats other than custom.
- Add/adjust tests to ensure CLI rejects --spec with non-
data_contract_file: str = None,
data_contract_str: str = None,
data_contract: DataContractSpecification = None,
data_contract: DataContractSpecification | OpenDataContractStandard = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change would require a switch in all instance methods, in particular in test() methods.

It feels correct that we should support ODCS spec in the DataContract class. However introducing this in would be a major enhancement (and this PR is a bit specific).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def export(self, export_format: ExportFormat, model: str = "all", sql_server_type: str = "auto", **kwargs) -> str:
if export_format == ExportFormat.html or export_format == ExportFormat.mermaid:
def export(self, export_format: ExportFormat, model: str = "all", spec: Spec = Spec.datacontract_specification, sql_server_type: str = "auto", **kwargs) -> str:
if export_format == ExportFormat.html or export_format == ExportFormat.mermaid or spec == Spec.odcs:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should enable the new resolve logic (v2) also for ExportFormat.custom. We do not need the spec as a parameter here.

Optional[Path],
typer.Option(help="[custom] The file path of Jinja template."),
] = None,
spec: Annotated[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need the parameter, as we can automatically detect whether a YAML file is DCS or ODCS. Supporting a jinja template that can handle DCS and ODCS is not something we want to support. And it could be implemented with an instance of check anyway without this parameter.

@simonharrer
Copy link
Contributor

@gautierc-thelio thanks for your contribution! This is really important, and long overdue. We can simplify the implementation quite a bit, by staying close to how the HTML export itself is implemented. We do not need the --spec parameter, making the implementation much simpler. Would you be so kind to simplify your solution along those lines? I've added a few inline comments as pointers. Then, we can merge this quickly.

@jochenchrist
Copy link
Contributor

@gautierc-thelio

Can you incorporate the requested changes into this PR?

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.

Support custom export for ODCS

3 participants