Skip to content

Commit 6efa478

Browse files
authored
Merge pull request #174 from koxudaxi/fix_invalid_argument_order
Fix invalid argument order
2 parents a5239c3 + 1235213 commit 6efa478

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

fastapi_code_generator/parser.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,13 @@ def get_argument_list(self, snake_case: bool) -> List[Argument]:
240240

241241
if self.request:
242242
arguments.append(self.request)
243+
244+
positional_argument: bool = False
245+
for argument in arguments:
246+
if positional_argument and argument.required and argument.default is None:
247+
argument.default = UsefulStr('...')
248+
positional_argument = argument.required
249+
243250
return arguments
244251

245252
def get_data_type(self, schema: JsonSchemaObject, suffix: str = '') -> DataType:

tests/data/expected/openapi/default_template/body_and_parameters/main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,11 @@ def get_users() -> List[UsersGetResponse]:
113113
@app.post('/users', response_model=None)
114114
def post_users(body: List[UsersPostRequest]) -> None:
115115
pass
116+
117+
118+
@app.post('/{ue_id}/sdm-subscriptions', response_model=None)
119+
def subscribe(ue_id: str = Path(..., alias='ueId'), body: Pet = ...) -> None:
120+
"""
121+
subscribe to notifications
122+
"""
123+
pass

tests/data/openapi/default_template/body_and_parameters.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,26 @@ paths:
317317
responses:
318318
'201':
319319
description: OK
320+
/{ueId}/sdm-subscriptions:
321+
post:
322+
summary: subscribe to notifications
323+
operationId: Subscribe
324+
tags:
325+
- Subscription Creation
326+
parameters:
327+
- name: ueId
328+
in: path
329+
description: Identity of the user
330+
required: true
331+
schema:
332+
type: string
333+
responses: {}
334+
requestBody:
335+
content:
336+
application/json:
337+
schema:
338+
$ref: '#/components/schemas/Pet'
339+
required: true
320340
components:
321341
parameters:
322342
MyParam:

0 commit comments

Comments
 (0)