diff --git a/fastapi_code_generator/parser.py b/fastapi_code_generator/parser.py index 0af2321..a40dd54 100644 --- a/fastapi_code_generator/parser.py +++ b/fastapi_code_generator/parser.py @@ -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: diff --git a/tests/data/expected/openapi/default_template/body_and_parameters/main.py b/tests/data/expected/openapi/default_template/body_and_parameters/main.py index 9c1e93d..6efa5bf 100644 --- a/tests/data/expected/openapi/default_template/body_and_parameters/main.py +++ b/tests/data/expected/openapi/default_template/body_and_parameters/main.py @@ -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 diff --git a/tests/data/openapi/default_template/body_and_parameters.yaml b/tests/data/openapi/default_template/body_and_parameters.yaml index f8b4085..340fbf3 100644 --- a/tests/data/openapi/default_template/body_and_parameters.yaml +++ b/tests/data/openapi/default_template/body_and_parameters.yaml @@ -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: