@@ -216,6 +216,13 @@ endpoints.forEach(function(endpoint) {
216216 formattedParams = formatParamsAsPythonDict (params)
217217 }
218218
219+ let model
220+ if (method .name === ' post' || method .name === ' put' ) {
221+ const dto = query2dto (sqlParser, method)
222+ // LATER: do we really need signature and cache?
223+ model = obtainDtoName (dto)
224+ }
225+
219226 if (hasGetOne || hasGetMany) {
220227 const methodArgs = Array .from (new Set ([... argsFromPath, ... argsFromQuery, ' conn=Depends(db_connection)' ]))
221228
@@ -282,9 +289,6 @@ def <%- pythonMethodName %>(<%- methodArgs.join(', ') %>):
282289< %
283290 }
284291 if (method .name === ' post' ) {
285- const dto = query2dto (sqlParser, method)
286- // LATER: do we really need signature and cache?
287- const model = obtainDtoName (dto)
288292% >
289293
290294@router .post (' <%- path %>' , status_code= status .HTTP_204_NO_CONTENT )
@@ -300,11 +304,6 @@ def <%- pythonMethodName %>(body: <%- model %>, conn=Depends(db_connection)):
300304
301305 }
302306 if (method .name === ' put' ) {
303- // TODO: reduce duplication with POST
304- const dto = query2dto (sqlParser, method)
305- // LATER: do we really need signature and cache?
306- const model = obtainDtoName (dto)
307-
308307 const methodArgs = [ ` body: ${ model} ` , ... argsFromPath, ' conn=Depends(db_connection)' ]
309308% >
310309
0 commit comments