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

Deserialize just the right fields when creating new entities #79

Merged
merged 3 commits into from
Dec 3, 2024

Conversation

jhodapp
Copy link
Member

@jhodapp jhodapp commented Dec 2, 2024

Description

This PR fixes each entity's SeaORM model such that we can call the create endpoints with just the right fields for creating a new instance of each one.

GitHub Issue: None

Changes

  • Ensure we deserialize just the right fields when creating new entities
  • Make sure we can set a password when creating a new User but still not able to serialize it for returning an existing User's hashed password
  • Use #[schema(value_type = String, format = DateTime)] consistently on DateTimeWithTimeStamp entity fields

Testing Strategy

  1. From the RAPIdoc UI (http://localhost:4000/rapidoc)
  2. Sign in with a test user
  3. Try creating a new instance of each entity. Check over the entity's schema
  4. Ensure that the schema only includes fields that you expect (i.e. they don't include things like id or created_at
  5. Each entity should create successfully

Concerns

None

@jhodapp jhodapp added the enhancement Improves existing functionality or feature label Dec 2, 2024
@jhodapp jhodapp added this to the 1.0-rc1 milestone Dec 2, 2024
@jhodapp jhodapp self-assigned this Dec 2, 2024
…et a password when creating a new User. Also update the OpenAPI user_controller::create documentation.
@jhodapp jhodapp requested a review from calebbourg December 3, 2024 02:57
@jhodapp jhodapp marked this pull request as ready for review December 3, 2024 02:57
Copy link
Collaborator

@calebbourg calebbourg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! Thank you for cleaning this stuff up.

Re: passwords:
I think what you've changed makes sense. We'd like to accept password (deserialize) but not return them (serialize).

At some point we may want to sit down and talk through how user creation should behave. I would imagine we may want to associate a user with other things like coaching_relationships and organizations at the time of creation.

Something for a future PR though.

@jhodapp
Copy link
Member Author

jhodapp commented Dec 3, 2024

I totally agree with you that we'll want to take a broader look at user creation. For now, I just decided to fix what exists, and am letting the client application I'm writing to create production entities for my clients handle pulling everything together via our basic API.

@jhodapp jhodapp merged commit 313b8ca into main Dec 3, 2024
4 checks passed
@jhodapp jhodapp deleted the fix_create_operations branch December 3, 2024 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improves existing functionality or feature
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants