Skip to content

Parameters and Extra Information

You can add additional information for path and query parameters. It is mainly seen in Swagger and ReDoc.

Title and Description

If you want to add a title and description to a specific path or query parameter, you can use title and description.

from typing import Annotated

from nexify import Nexify, Path

app = Nexify()


@app.get("/items/{item_id}")
def read_item(
    item_id: Annotated[
        str,
        Path(
            title="Item ID",
            description="This is Item ID",
        ),
    ],
) -> dict:
    return {"item_id": item_id}

In this case, you can see the description provided for item_id.

Swagger UI Title and Description

Info

The title is displayed only in ReDoc.

Examples (openapi_examples)

from typing import Annotated

from nexify import Nexify, Path

app = Nexify()


@app.get("/items/{item_id}")
def read_item(
    item_id: Annotated[
        str,
        Path(
            openapi_examples={
                "Test item: Foo": {
                    "summary": "Item ID of a test item (Foo)",
                    "value": "2341",
                },
                "Test item: Bar": {
                    "summary": "Item ID of a test item (Bar)",
                    "value": "2342",
                },
            }
        ),
    ],
) -> dict:
    return {"item_id": item_id}

You can see the OpenAPI examples.

Swagger UI Example

Deprecated

If you need to deprecate a path or query parameter without removing it, you can use deprecated.

from typing import Annotated

from nexify import Nexify, Path, Query

app = Nexify()


@app.get("/items/{item_id}")
def read_item(
    item_id: Annotated[str | None, Path()] = None,
    itemId: Annotated[
        str | None,
        Query(deprecated=True, description="This parameter is deprecated"),
    ] = None,
) -> dict:
    if itemId:
        return {"item_id": itemId}
    return {"item_id": item_id}

In this case, you can see that itemId is marked with a red deprecated label, indicating that it is a deprecated query parameter.

Swagger UI Deprecated