@@ -208,6 +208,7 @@ endpoints.forEach(function(endpoint) {
208208 const argsFromQuery = method .query ? extractParamsFromQuery (method .query ).map (stipOurPrefixes) : []
209209
210210 // define before "if", to make them available later
211+ let methodArgs
211212 let sql
212213 let formattedParams
213214 if (method .name === ' post' || method .name === ' put' || method .name === ' delete' ) {
@@ -221,10 +222,15 @@ endpoints.forEach(function(endpoint) {
221222 const dto = query2dto (sqlParser, method)
222223 // LATER: do we really need signature and cache?
223224 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)' ]
224230 }
225231
226232 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)' ]))
228234
229235 const queriesWithNames = []
230236 if (method .query ) {
@@ -292,8 +298,7 @@ def <%- pythonMethodName %>(<%- methodArgs.join(', ') %>):
292298% >
293299
294300@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 (' , ' ) % > ):
297302 try:
298303 with conn:
299304 with conn .cursor () as cur:
@@ -304,7 +309,6 @@ def <%- pythonMethodName %>(body: <%- model %>, conn=Depends(db_connection)):
304309
305310 }
306311 if (method .name === ' put' ) {
307- const methodArgs = [ ` body: ${ model} ` , ... argsFromPath, ' conn=Depends(db_connection)' ]
308312% >
309313
310314@router .put (' <%- path %>' , status_code= status .HTTP_204_NO_CONTENT )
@@ -319,7 +323,6 @@ def <%- pythonMethodName %>(<%- methodArgs.join(', ') %>):
319323
320324 }
321325 if (method .name === ' delete' ) {
322- const methodArgs = [ ... argsFromPath, ' conn=Depends(db_connection)' ]
323326% >
324327
325328@router .delete (' <%- path %>' , status_code= status .HTTP_204_NO_CONTENT )
0 commit comments