Skip to content

[BUG] Specifying parameters in openapi_extras overrides query parameters, rather than appending them #1505

@AnyByte

Description

@AnyByte

Describe the bug
When specifying parameters in openapi_extras for an endpoint, they will overwrite the existing query parameters with the extra parameters, rather than appending the parameters to the spec.

Versions (please complete the following information):

  • Python version: 3.11.5
  • Django version: 5.1.8
  • Django-Ninja version: 1.4.0
  • Pydantic version: 2.11.1

Without openapi_extras:

class ProductFilters(FilterSchema):
    id__in: list[str] | None


@router.get('/', response=ProductSchemaOut)
def get_products(request, filters: ProductFilters = Query(...)):
    pass
Image

With openapi_extras:

class ProductFilters(FilterSchema):
    id__in: list[str] | None


@router.get(
    '/',
    response=ProductSchemaOut,
    openapi_extra={
        'parameters': [
            {
                'in': 'header',
                'name': 'X-AUTH-LOGIN',
                'shema': {'type': 'string'},
                'required': True,
                'description': 'Application name',
            },
            {
                'in': 'header',
                'name': 'X-AUTH-TOKEN',
                'shema': {'type': 'string'},
                'required': True,
                'description': 'Application key',
            },
        ]
    },
)
def get_products(request, filters: ProductFilters = Query(...)):
    pass
Image

Notice that id__in query parameter is gone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions