Skip to content

Conversation

@YuriiMotov
Copy link
Member

@YuriiMotov YuriiMotov commented Nov 4, 2025

Test Coverage Summary

Tests for Pydantic V2 include:

  • Basic alias functionality Form(alias=...) + the same for form model
  • Validation alias functionality Form(validation_alias=...) + the same for form model
  • Combined aliases Form(alias=..., validation_alias=...) + the same for form model
  • Workaround Form(alias=X, validation_alias=X)

Each of test cases (except workaround) covers different field types:

  • Required str field
  • Optional str field
  • list field
  • Optional list field

Each of test cases covers different parameter types:

  • Form field
  • Form field declared as model (think about adding tests for alias_generator, populate_by_name, alias_priority, alias_choices)
  • File field
  • File field declared as model (TODO: add tests)
  • Body field (TODO: add tests)
  • Body field declared as model (TODO: add tests)

For each type of parameter declaration, the following is checked:

  • Send parameter by name
  • Send parameter by alias
  • Send parameter by validation_alias (if specified)
  • Generate openapi schema

Tests for Pydantic V1

Tests for Pydantic V1 duplicate tests for V2, excluding all tests with validation_alias (it's not implmented for V1 and I don't think we need to add this)

Current situation with alias support

Currently tests expose several issues with Pydantic V2:

  • Single fields (not model):
    • alias - for Form\File fields works partially - isn't reflected in schema
    • validation_alias- for Form\File fields is reflected in schema, but doesn't work
    • optlional list of files - fails with TypeError
  • Fields declared as model:
    • Pydantic Models with validation_alias for List Fields fails due to some bug ("Input should be a valid list","input":"456")

Currently tests expose 1 issue with Pydantic V1:

  • Schema for all optional fields is invalid(?) (just string instead of anyOf) - TODO: investigate

@YuriiMotov YuriiMotov force-pushed the fix-body-fields-aliases branch from 74c03ce to 9769694 Compare November 5, 2025 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant