To enable one to implement these modifications, the swagger.yml file from Part 1 must be modified

Here’s just what preceding code is doing:

Lines 1 – 9 import some Flask modules to create the others API reactions, and additionally importing the db example through the config.py module. In addition, it imports the SQLAlchemy individual and Marshmallow PersonSchema classes to access anyone databases desk and serialize the outcomes.

Range 11 initiate the definition of read_all() that responds for the REMAINDER API URL endpoint GET /api/people and return all the files during the individual databases table arranged in ascending order by last title.

Outlines 19 – 22 tell SQLAlchemy to question the individual database table for all your reports, type all of them in ascending purchase (the default sorting order), and go back a summary of people Python objects because adjustable everyone .

Line 24 is how the Marshmallow PersonSchema lessons description turns out to be useful. Your generate an instance of PersonSchema , driving they the factor many=True . This informs PersonSchema can be expected an interable to serialize, which can be precisely what the folk varying was.

Line 25 utilizes the PersonSchema instance variable ( person_schema ), phoning the dump() technique because of the men and women record.