Skip to content

Commit 97c796b

Browse files
committed
Generate valid python code if query param exists and requeststBody is required.
Fixed #322.
1 parent 07b70f9 commit 97c796b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fastapi_code_generator/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def get_argument_list(self, snake_case: bool, path: List[str]) -> List[Argument]
330330
for argument in arguments:
331331
if positional_argument and argument.required and argument.default is None:
332332
argument.default = UsefulStr('...')
333-
positional_argument = argument.required or argument.default is not None
333+
positional_argument = argument.required or (argument.default is not None) or argument.type_hint.startswith('Optional[')
334334

335335
return arguments
336336

0 commit comments

Comments
 (0)