# Breadcrumb

A breadcrumb displays the sequential path of pages, indicating the complete path to the current page and offering a means to navigate back to previous points.

### Menu Item Schema

| **Field**        | **Data Type** | **Description**                                                                          |
| ---------------- | ------------- | ---------------------------------------------------------------------------------------- |
| `label`          | string        | User-friendly text for the URL.                                                          |
| `url`            | string        | The URL of the menu item.                                                                |
| `level`          | int           | The breadcrumb level.                                                                    |
| `pk`             | UUID          | The UUID of the menu item.                                                               |
| `sort_order`     | int           | The order from the oldest ancestor to the current menu item, equal to the `level` field. |
| `path`           | string        | The breadcrumb path, with each step encoded into 4 characters.                           |
| `parent_pk`      | Null          | Always null.                                                                             |
| `parent`         | Null          | Always null.                                                                             |
| `generator_name` | string        | Generator name, e.g., menu\_item.                                                        |
| `extra_context`  | JSON          | Additional information about the object, such as `numchild` and `attributes`.            |

### `GET` Generate Breadcrumb

The `path` field stores the complete breadcrumb path, where every 4 characters represent a distinct breadcrumb step. For example, if the `path` is `0001000N0002`, then `0001` is the first step, `000N` is the second, and `0002` is the third. This way, the objects with the values `0001` and `0001000N` of the `path` field become its ancestors.

**Path:** `https://{commerce_url}/menus/generate_breadcrumb/`

This method is used to fetch a menu with the given UUID and its ancestors.

**Query Parameters**

To generate a breadcrumb, the following query parameters must be provided:

| **Query String Params** | **Data Type** | **Description**                            |
| ----------------------- | ------------- | ------------------------------------------ |
| `item`                  | string        | Menu item UUID to generate the breadcrumb. |
| `generator_name`        | string        | Generator name, e.g., menu\_item.          |

**Example Response (200 OK)**

```json
{
    "menu": [
        {
            "label": null,
            "url": "/",
            "level": 0,
            "pk": "0ad242e3-90e4-421e-98c9-50f682cde230",
            "sort_order": 0,
            "path": "0001000N",
            "parent_pk": null,
            "parent": null,
            "generator_name": "menu_item",
            "extra_context": {
                "attributes": {
                    "category_id": null
                },
                "numchild": 2
            }
        },
        {
            "label": null,
            "url": "selamsmsm",
            "level": 1,
            "pk": "1a300982-a19d-457f-8d68-6a9dee448a56",
            "sort_order": 1,
            "path": "0001000N0002",
            "parent_pk": null,
            "parent": null,
            "generator_name": "menu_item",
            "extra_context": {
                "attributes": {
                    "category_id": null
                },
                "numchild": 1
            }
        }
    ]
}
```

**Example Response (400 Bad Request)**

If both `item` and `generator_name` are not sent as query parameters, the system will return a 400 bad request response, indicating the missing parameters like below:

```json
{
    "item": [
        "Bu alan gerekli."
    ],
    "generator_name": [
        "Bu alan gerekli."
    ]
}
```
