Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #39 from lendingblock/master
Browse files Browse the repository at this point in the history
0.2.4
  • Loading branch information
lsbardel authored Jul 5, 2018
2 parents 0092daa + 1c5c848 commit 44750e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion openapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Minimal OpenAPI asynchronous server application
"""
__version__ = '0.2.3'
__version__ = '0.2.4'
17 changes: 12 additions & 5 deletions openapi/db/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@ def db(self):
def db_table(self):
return self.request.app['metadata'].tables[self.table]

async def get_list(self, query=None):
async def get_list(
self,
query=None,
table=None,
query_schema='query_schema',
dump_schema='response_schema'
):
"""Get a list of models
"""
params = self.get_filters(query)
table = table if table is not None else self.db_table
params = self.get_filters(query, query_schema=query_schema)
limit = params.pop('limit', DEF_PAGINATION_LIMIT)
offset = params.pop('offset', 0)
query = self.get_query(self.db_table.select(), params)
query = self.get_query(table.select(), params, table=table)

# pagination
query = query.offset(offset)
Expand All @@ -39,7 +46,7 @@ async def get_list(self, query=None):
sql, args = compile_query(query)
async with self.db.acquire() as db:
values = await db.fetch(sql, *args)
return self.dump('response_schema', values)
return self.dump(dump_schema, values)

async def create_one(
self, data=None, table=None, body_schema='body_schema',
Expand Down Expand Up @@ -85,7 +92,7 @@ async def get_one(
query=None,
table=None,
query_schema='query_schema',
dump_schema='response_schema',
dump_schema='response_schema'
):
"""Get a single model
"""
Expand Down

0 comments on commit 44750e8

Please sign in to comment.