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

Fix pydantic v2 warnings related to UserGroup #572

Merged

Commits on Nov 26, 2024

  1. api.models: define different user schema models

    Define and use different user models for API
    endpoint and fastapi-users router, i.e. different
    models as request schema for API request model and schema
    for request to `fastapi-users` router.
    For create user request, user needs to send
    `UserCreateRequest` schema as API router request
    and the router will use `UserCreate` schema to
    send the request to `fastapi-users` router.
    This is due to we intend to have a list of user group
    name strings as API router request and `UserGroup`
    instance as `fastapi-users` router request as `user.groups`
    field value.
    
    Signed-off-by: Jeny Sadadia <[email protected]>
    Jeny Sadadia committed Nov 26, 2024
    Configuration menu
    Copy the full SHA
    bc917dc View commit details
    Browse the repository at this point in the history
  2. api.main: fix pydantic v2 warnings for UserGroup

    Fix the below warnings from pydantic v2 while creating
    or updating a user account with user groups:
    ```
    kernelci-api          | /home/kernelci/.local/lib/python3.11/site-packages/pydantic/main.py:390: UserWarning: Pydantic serializer warnings:
    kernelci-api          |   Expected `str` but got `UserGroup` with value `UserGroup(id=ObjectId('64...16ad'), name='kernelci')` - serialized value may not be as expected
    kernelci-api          |   return self.__pydantic_serializer__.to_python(
    ```
    Signed-off-by: Jeny Sadadia <[email protected]>
    Jeny Sadadia committed Nov 26, 2024
    Configuration menu
    Copy the full SHA
    35cdfa5 View commit details
    Browse the repository at this point in the history