rest_api_demo icon indicating copy to clipboard operation
rest_api_demo copied to clipboard

List of values on api.inherit doesn't appear

Open joicy opened this issue 5 years ago • 0 comments

Hi! I'm following this tutorial but I have a problem with the API pagination. Although the pagination data is appearing, the data fields don't. Do you have any idea what I can do?

My code:

flatdata_fields = api.model('Mutations', {
    'id': fields.Integer(readOnly=True),
    'mutation_code': fields.String(required=True),
    'pdb_mutant': fields.String,
    'pdbs_template': fields.String,
    'mutated_chain': fields.String,
    'mutation_type': fields.String,
    'mut_count': fields.Integer,
})
pagination = api.model('A page of results', {
    'total': fields.Integer(),
    'page': fields.Integer(),
    'per_page': fields.Integer(),
})

page_of_flatdata = api.inherit('Page of Mutation data', pagination, {
    'rows': fields.List(fields.Nested(flatdata_fields))
})
@td.route('/')
class rawThermDataList(Resource):
    @api.expect(pagination_arguments)
    @api.marshal_with(page_of_flatdata)
    def get(self):
        args = pagination_arguments.parse_args(request)
        page = args.get('page', 1)
        per_page = args.get('per_page', 10)
        return FlatData.query.paginate(page, per_page, error_out=False)

Thank you!

joicy avatar Sep 12 '20 20:09 joicy