Micro Services Classroom Series – 05/Dec/2021

Adding Nested Fields to the Recipe Schema

  • In the Recipe Schema, lets define an attribute author which represents User Scheam and is available only for Serialization.
  • This author represents the user attribute and it returns the id and username
  • Refer Here for the changeset

Updating the Recipes Partially

  • We already have PUT method which is used to update the recipe, but it updates the whole recipe.
  • In some usecase, we might be updating only a part of recipe
  • For updating the items partially in HTTP we have a method PATCH
  • Lets create a patch implementation in the Recipe Resource

View the recipes by its visibility

  • I want to make changes in the visibility resource to get the recipes /user/{username}/recipes?visibility=<public | private | all>
  • The default visibility will be public
  • Lets start by making changes in the recipe model to add some methods
  • Now we would like to parse the arguments from http requests (visibility), for that we would add a package webargs Refer Here for the official docs
  • Since the webargs package was unable to parse query strings we have handled from request.args.get() as a workaround.
  • Refer Here for the other changes and postman tests

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin