Skip to content

refactor: standardise pydantic models with snake_case and aliases in response models #2

Description

@NehuenLian

Context

Currently, many Pydantic models in the service/api/response_models layer use PascalCase directly from the AFIP XML structure (e.g., Code, Msg, FchProceso).
We need to transition to snake_case for all fields using Pydantic Field aliases.

This task is strictly limited to models within the ./service/api/response_models/

For example:

Before (Now):

class Err(BaseModel):
    Code: int
    Msg: str | None = None

After:

class Err(BaseModel):

    model_config = ConfigDict(populate_by_name=True)

    code: int = Field(..., alias="Code")
    msg: str | None = Field(None, alias="Msg")

Technical Notes

  • Remember to include model_config = ConfigDict(populate_by_name=True) in the models so the fields can still be accessed or initialized by their original AFIP names.

  • Field Optionality: Pay close attention to the types:
    If the field is mandatory (e.g., code: int): Use Field(..., alias="Code").
    If the field is optional (e.g., msg: str | None = None): Use Field(None, alias="Msg").

  • You don't need to write new test cases for this issue.

  • Before submitting your PR, ensure the existing suite passes by running:
    pytestc implementation details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomersno-tests-neededChanges don't affect logic. Existing tests are sufficient.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions