Skip to content

Profile

--profile

Use a named profile from pyproject.toml configuration.

Profiles allow you to define multiple named configurations in your pyproject.toml file. Each profile can override the default settings with its own set of options.

Related: pyproject.toml Configuration

Usage

datamodel-codegen --input schema.json --profile strict # (1)!
  1. --profile - the option documented here
Configuration (pyproject.toml)
[tool.datamodel-codegen]
# Default configuration
output-model-type = "pydantic_v2.BaseModel"

[tool.datamodel-codegen.profiles.strict]
# Strict profile with additional options
strict-types = ["str", "int", "float", "bool"]
strict-nullable = true

[tool.datamodel-codegen.profiles.dataclass]
# Dataclass profile
output-model-type = "dataclasses.dataclass"

Use profiles:

# Use the strict profile
datamodel-codegen --input schema.json --profile strict

# Use the dataclass profile
datamodel-codegen --input schema.json --profile dataclass