Here’s just what above code is performing:
Contours 1 – 9 significance some Flask modules to create the REST API reactions, plus importing the db case through the config.py module. Furthermore, they imports the SQLAlchemy people and Marshmallow PersonSchema classes to access the individual database desk and serialize the outcome.
Range 11 starts the definition of read_all() that responds for the REST API Address endpoint GET /api/people and returns all of the files when you look at the people databases desk arranged in rising purchase by finally term.
Contours 19 – 22 inform SQLAlchemy to question anyone databases table for all the files, sort them in rising order (the default sorting order), and go back a summary of people Python objects since the changeable men .
Range 24 is where the Marshmallow PersonSchema course definition turns out to be useful. You develop an instance associated with the PersonSchema , passing they the parameter many=True . This tells PersonSchema to expect an interable to serialize, that is what the folks varying is. Fortsätt läsa ”To ensure that you to definitely apply these variations, the swagger.yml file from Part 1 must be edited”