@@ -208,6 +208,7 @@ endpoints.forEach(function(endpoint) {
208
208
const argsFromQuery = method .query ? extractParamsFromQuery (method .query ).map (stipOurPrefixes) : []
209
209
210
210
// define before "if", to make them available later
211
+ let methodArgs
211
212
let sql
212
213
let formattedParams
213
214
if (method .name === ' post' || method .name === ' put' || method .name === ' delete' ) {
@@ -221,10 +222,15 @@ endpoints.forEach(function(endpoint) {
221
222
const dto = query2dto (sqlParser, method)
222
223
// LATER: do we really need signature and cache?
223
224
model = obtainDtoName (dto)
225
+ methodArgs = [ ` body: ${ model} ` , ... argsFromPath, ' conn=Depends(db_connection)' ]
226
+ }
227
+
228
+ if (method .name === ' delete' ) {
229
+ methodArgs = [ ... argsFromPath, ' conn=Depends(db_connection)' ]
224
230
}
225
231
226
232
if (hasGetOne || hasGetMany) {
227
- const methodArgs = Array .from (new Set ([... argsFromPath, ... argsFromQuery, ' conn=Depends(db_connection)' ]))
233
+ methodArgs = Array .from (new Set ([... argsFromPath, ... argsFromQuery, ' conn=Depends(db_connection)' ]))
228
234
229
235
const queriesWithNames = []
230
236
if (method .query ) {
@@ -292,8 +298,7 @@ def <%- pythonMethodName %>(<%- methodArgs.join(', ') %>):
292
298
% >
293
299
294
300
@router .post (' <%- path %>' , status_code= status .HTTP_204_NO_CONTENT )
295
- < % # LATER : deal with methodArgs -% >
296
- def < %- pythonMethodName % > (body: < %- model % > , conn= Depends (db_connection)):
301
+ def < %- pythonMethodName % > (< %- methodArgs .join (' , ' ) % > ):
297
302
try:
298
303
with conn:
299
304
with conn .cursor () as cur:
@@ -304,7 +309,6 @@ def <%- pythonMethodName %>(body: <%- model %>, conn=Depends(db_connection)):
304
309
305
310
}
306
311
if (method .name === ' put' ) {
307
- const methodArgs = [ ` body: ${ model} ` , ... argsFromPath, ' conn=Depends(db_connection)' ]
308
312
% >
309
313
310
314
@router .put (' <%- path %>' , status_code= status .HTTP_204_NO_CONTENT )
@@ -319,7 +323,6 @@ def <%- pythonMethodName %>(<%- methodArgs.join(', ') %>):
319
323
320
324
}
321
325
if (method .name === ' delete' ) {
322
- const methodArgs = [ ... argsFromPath, ' conn=Depends(db_connection)' ]
323
326
% >
324
327
325
328
@router .delete (' <%- path %>' , status_code= status .HTTP_204_NO_CONTENT )
0 commit comments