Skip to content

Commit

Permalink
Merge pull request #174 from koxudaxi/fix_invalid_argument_order
Browse files Browse the repository at this point in the history
Fix invalid argument order
  • Loading branch information
koxudaxi authored Jun 17, 2021
2 parents a5239c3 + 1235213 commit 6efa478
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fastapi_code_generator/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,13 @@ def get_argument_list(self, snake_case: bool) -> List[Argument]:

if self.request:
arguments.append(self.request)

positional_argument: bool = False
for argument in arguments:
if positional_argument and argument.required and argument.default is None:
argument.default = UsefulStr('...')
positional_argument = argument.required

return arguments

def get_data_type(self, schema: JsonSchemaObject, suffix: str = '') -> DataType:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,11 @@ def get_users() -> List[UsersGetResponse]:
@app.post('/users', response_model=None)
def post_users(body: List[UsersPostRequest]) -> None:
pass


@app.post('/{ue_id}/sdm-subscriptions', response_model=None)
def subscribe(ue_id: str = Path(..., alias='ueId'), body: Pet = ...) -> None:
"""
subscribe to notifications
"""
pass
20 changes: 20 additions & 0 deletions tests/data/openapi/default_template/body_and_parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,26 @@ paths:
responses:
'201':
description: OK
/{ueId}/sdm-subscriptions:
post:
summary: subscribe to notifications
operationId: Subscribe
tags:
- Subscription Creation
parameters:
- name: ueId
in: path
description: Identity of the user
required: true
schema:
type: string
responses: {}
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
required: true
components:
parameters:
MyParam:
Expand Down

0 comments on commit 6efa478

Please sign in to comment.