Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions docs/cli-reference/general-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -1168,14 +1168,12 @@ The `--check` flag compares the generated output with existing files and exits w
a non-zero status if they differ. Useful for CI/CD validation to ensure schemas
and generated code stay in sync. Works with both single files and directory outputs.

**Related:** [`--no-use-standard-collections`](typing-customization.md#no-use-standard-collections), [`--no-use-union-operator`](typing-customization.md#no-use-union-operator)

**See also:** [CI/CD Integration](../ci-cd.md)

!!! tip "Usage"

```bash
datamodel-codegen --input schema.json --disable-timestamp --use-union-operator --use-standard-collections --check # (1)!
datamodel-codegen --input schema.json --disable-timestamp --check # (1)!
```

1. :material-arrow-left: `--check` - the option documented here
Expand Down
7 changes: 3 additions & 4 deletions tests/main/test_main_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,8 @@ def test_skip_root_model_command_line(output_file: Path) -> None:
@pytest.mark.cli_doc(
options=["--check"],
input_schema="jsonschema/person.json",
cli_args=["--disable-timestamp", "--use-union-operator", "--use-standard-collections", "--check"],
cli_args=["--disable-timestamp", "--check"],
golden_output="person.py",
related_options=["--use-union-operator", "--use-standard-collections"],
)
def test_check_file_matches(output_file: Path) -> None:
"""Verify generated code matches existing output without modifying files.
Expand All @@ -489,13 +488,13 @@ def test_check_file_matches(output_file: Path) -> None:
input_path=input_path,
output_path=output_file,
input_file_type="jsonschema",
extra_args=["--disable-timestamp", "--use-union-operator", "--use-standard-collections"],
extra_args=["--disable-timestamp"],
)
run_main_and_assert(
input_path=input_path,
output_path=output_file,
input_file_type="jsonschema",
extra_args=["--disable-timestamp", "--use-union-operator", "--use-standard-collections", "--check"],
extra_args=["--disable-timestamp", "--check"],
expected_exit=Exit.OK,
)

Expand Down
Loading