Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC]Generate Schema from runtime Dynaconf Instance #1141

Open
rochacbruno opened this issue Jul 7, 2024 · 0 comments
Open

[RFC]Generate Schema from runtime Dynaconf Instance #1141

rochacbruno opened this issue Jul 7, 2024 · 0 comments
Labels
Not a Bug Not a Problem, expected behavior RFC typed_dynaconf
Milestone

Comments

@rochacbruno
Copy link
Member

Given a runtime untyped dynaconf instance with all its validators set and data loaded:

settings=Dynaconf(
    settings_file="x.toml", 
    envvar_prefix="APP", 
   validators=[Validator("name", ne="admin")]
)
# x.toml
name = "Bruno"
age = 16
colors = ["red", "green", "blue"]
profile = {"username": "rocha"}

on CLI

$ dynaconf -i config.settigns generate-schema --set-defaults > schema.py
from dynaconf.typed import Dynaconf, Validator, Options, DictValue

class Profile(DictValue):
    username: str = "rocha"

class Settings(Dynaconf):
    dynaconf_options = Options(settings_file="x.toml", envvar_prefix="APP")

    name: Annotated[str, Validator(ne="admin")] = "Bruno"
    age: int = 16
    colors: list[str] = ["red", "green", "blue"]
    profile: Profile
    

settings = Settings()
@rochacbruno rochacbruno added Not a Bug Not a Problem, expected behavior RFC typed_dynaconf labels Jul 7, 2024
@rochacbruno rochacbruno added this to the 4.0.0 milestone Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Not a Bug Not a Problem, expected behavior RFC typed_dynaconf
Projects
None yet
Development

No branches or pull requests

1 participant