autodoc_pydantic API Docs

Source

 1from pydantic import BaseSettings, Field, validator
 2
 3
 4class ExampleSettings(BaseSettings):
 5    """Document your project settings very conveniently. Applies like wise
 6    to pydantic models.
 7
 8    """
 9
10    field_plain_with_validator: int = 100
11    """Show standard field with type annotation."""
12
13    field_plain = 100
14    """Show standard field without type annotation."""
15
16    field_with_validator_and_alias: str = Field("FooBar", alias="BarFoo", env="BarFoo")
17    """Shows corresponding validator with link/anchor."""
18
19    field_with_validator_and_alias_typeless = Field(
20        "FooBar", alias="BarFoo", env="BarFoo"
21    )
22    """Shows corresponding validator with link/anchor but without type annotation."""
23
24    field_with_constraints_and_description: int = Field(
25        default=5, ge=0, le=100, description="Shows constraints within doc string."
26    )
27
28    @validator("field_with_validator_and_alias", "field_plain_with_validator")
29    def check_max_length_ten(cls, v):
30        """Show corresponding field with link/anchor."""
31
32        if not len(v) < 10:
33            raise ValueError("No more than 10 characters allowed")
34
35    class Config:
36        env_prefix = "foo_"
37        allow_mutation = True
38
39    def method_without_sig(self) -> BaseSettings:
40        return BaseSettings()

Rendered