diff --git a/pyproject.toml b/pyproject.toml index d2b219503..4d7c796df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -213,6 +213,7 @@ skip = '.git,*.lock,tests,docs/cli-reference,CHANGELOG.md,docs/changelog.md' filterwarnings = [ "error", "ignore:^.*Pydantic v1 runtime support is deprecated.*:DeprecationWarning", + "ignore:^.*No --output-model-type specified.*:DeprecationWarning", "ignore:^.*`--validation` option is deprecated.*", "ignore:^.*--parent-scoped-naming is deprecated.*", "ignore:^.*Field name `name` is duplicated on Pet.*", diff --git a/src/datamodel_code_generator/__main__.py b/src/datamodel_code_generator/__main__.py index 2aa146da8..d0f67fb23 100644 --- a/src/datamodel_code_generator/__main__.py +++ b/src/datamodel_code_generator/__main__.py @@ -1193,6 +1193,22 @@ def main(args: Sequence[str] | None = None) -> Exit: # noqa: PLR0911, PLR0912, if config.disable_warnings: warnings.simplefilter("ignore") + if ( + namespace.output_model_type is None + and pyproject_config.get("output_model_type") is None + and config.output_model_type == DataModelType.PydanticBaseModel + ): + warnings.warn( + "No --output-model-type specified. " + "The current default (pydantic.BaseModel, Pydantic v1) is deprecated " + "and will be removed in a future version. " + "Please explicitly specify --output-model-type. " + "Example: --output-model-type pydantic_v2.BaseModel. " + "See https://github.com/koxudaxi/datamodel-code-generator/issues/2466", + DeprecationWarning, + stacklevel=1, + ) + if not is_pydantic_v2(): warnings.warn( "Pydantic v1 runtime support is deprecated and will be removed in a future version. "