@@ -216,6 +216,13 @@ endpoints.forEach(function(endpoint) {
216
216
formattedParams = formatParamsAsPythonDict (params)
217
217
}
218
218
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
+
219
226
if (hasGetOne || hasGetMany) {
220
227
const methodArgs = Array .from (new Set ([... argsFromPath, ... argsFromQuery, ' conn=Depends(db_connection)' ]))
221
228
@@ -282,9 +289,6 @@ def <%- pythonMethodName %>(<%- methodArgs.join(', ') %>):
282
289
< %
283
290
}
284
291
if (method .name === ' post' ) {
285
- const dto = query2dto (sqlParser, method)
286
- // LATER: do we really need signature and cache?
287
- const model = obtainDtoName (dto)
288
292
% >
289
293
290
294
@router .post (' <%- path %>' , status_code= status .HTTP_204_NO_CONTENT )
@@ -300,11 +304,6 @@ def <%- pythonMethodName %>(body: <%- model %>, conn=Depends(db_connection)):
300
304
301
305
}
302
306
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
-
308
307
const methodArgs = [ ` body: ${ model} ` , ... argsFromPath, ' conn=Depends(db_connection)' ]
309
308
% >
310
309
0 commit comments