Skip to content

Commit 8323f34

Browse files
committed
refactor(python): rename "payload" to "body"
Relate to #16
1 parent 70c77a3 commit 8323f34

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

examples/python/fastapi/postgres/routes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def get_list_v1_categories(conn=Depends(db_connection)):
9191

9292

9393
@router.post('/v1/categories', status_code = status.HTTP_204_NO_CONTENT)
94-
def post_v1_categories(payload: CreateCategoryDto, conn=Depends(db_connection)):
94+
def post_v1_categories(body: CreateCategoryDto, conn=Depends(db_connection)):
9595
try:
9696
with conn:
9797
with conn.cursor() as cur:
@@ -116,7 +116,7 @@ def post_v1_categories(payload: CreateCategoryDto, conn=Depends(db_connection)):
116116
, NOW()
117117
, %(user_id)s
118118
)
119-
""", {"name": payload.name, "name_ru": payload.name_ru, "slug": payload.slug, "user_id": payload.user_id, "user_id": payload.user_id})
119+
""", {"name": body.name, "name_ru": body.name_ru, "slug": body.slug, "user_id": body.user_id, "user_id": body.user_id})
120120
finally:
121121
conn.close()
122122

src/templates/routes.py.ejs

+3-3
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,15 @@ def <%- pythonMethodName %>(<%- methodArgs.join(', ') %>):
246246
const sql = convertToPsycopgNamedArguments(formatQueryForPython(method.query, 20))
247247
const params = extractParamsFromQuery(method.query);
248248
const formattedParams = params.length > 0
249-
// [ "p.categoryId" ] => [ '"categoryId": payload.categoryId' ]
250-
? ', {' + params.map(param => param.substring(2)).map(param => `"${param}": payload.${param}`).join(', ') + '}'
249+
// [ "p.categoryId" ] => [ '"categoryId": body.categoryId' ]
250+
? ', {' + params.map(param => param.substring(2)).map(param => `"${param}": body.${param}`).join(', ') + '}'
251251
: ''
252252
253253
%>
254254
255255
@router.post('<%- path %>', status_code = status.HTTP_204_NO_CONTENT)
256256
<%# LATER: deal with methodArgs -%>
257-
def <%- pythonMethodName %>(payload: <%- model %>, conn=Depends(db_connection)):
257+
def <%- pythonMethodName %>(body: <%- model %>, conn=Depends(db_connection)):
258258
try:
259259
with conn:
260260
with conn.cursor() as cur:

0 commit comments

Comments
 (0)