Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Generates SyntaxError if a path parameter without a default value follows another that has a default value

Open
#1,281 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
50/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
openapi, python
Domain
api, tooling

Research direction

Reproduce the issue with the minimum OpenAPI spec in the report and inspect the generator path that builds the generated _get_kwargs signature for path parameters. Confirm the fix by generating a client successfully and verifying that required path parameters can follow defaulted ones without a Python SyntaxError.

Written by the indexing model from the issue text.

Description

Describe the bug
Fails to generate client when a path parameter without a default value follows another one that has a default value.

Message:

Error(s) encountered while generating, client was not created
ruff failed
SyntaxError: Parameter without a default cannot follow a parameter with a default

OpenAPI Spec File
Motivating api: https://avaandmed.keskkonnaportaal.ee/swagger/index.html ("File of document")
Minimum example:

openapi: 3.0.0
info:
  title: Minimal Repro for Parameter Order Bug
  version: 1.0.0
paths:
  /test/{has_default}/{no_default}:
    get:
      summary: Test endpoint with required path params, some with defaults
      parameters:
        - name: has_default
          in: path
          required: true
          schema:
            type: string
            default: default_value
          description: Required path param with default
        - name: no_default
          in: path
          required: true
          schema:
            type: integer
          description: Required path param, no default
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: string

Desktop (please complete the following information):

  • OS: Ubuntu 22.04.5 LTS
  • Python Version: 3.10.12
  • openapi-python-client version 0.25.2

Additional context
The generated function signature for _get_kwargs looks like this:

def _get_kwargs(
    has_default: str = 'default_value',
    no_default: int,
) -> dict[str, Any]:

The issue does not occur for query parameters, as the generator emits keyword-only arguments (*) for them. It only occurs for path parameters, which are emitted as positional-or-keyword arguments.

Dominant language
Python
Stars
2k
Forks
293
Avg merge
34m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openapi-generators/openapi-python-client

All issues in openapi-generators/openapi-python-client

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.