# Exporting API Schema

The backend uses `drf-spectacular` to generate OpenAPI 3.0 schemas. This documentation explains how to export the current API schema to a YAML file for documentation or client generation purposes.

## Command

Run the following command from the `backend/` directory:

```bash
python manage.py spectacular --file docs/api-schema.yaml
```

## detailed Steps

1.  **Navigate to Backend:**
    ```bash
    cd backend
    ```

2.  **Run Export:**
    ```bash
    python manage.py spectacular --file docs/api-schema.yaml
    ```
    *Note: The `docs/` directory inside `backend/` must exist. If it doesn't, create it first: `mkdir -p docs`.*

3.  **Verify:**
    The file `backend/docs/api-schema.yaml` will be created or updated with the latest schema definition based on your Django views and serializers.

## Viewing the Schema

You can view the generated YAML file in any text editor, or import it into tools like:
-   [Swagger Editor](https://editor.swagger.io/)
-   Postman (Import -> OpenAPI)
-   Stoplight

## Live Documentation

Instead of exporting to a file, you can also view the auto-generated documentation live in your browser when the server is running (`python manage.py runserver`):

-   **Swagger UI:** [http://localhost:8000/api/docs](http://localhost:8000/api/docs)
-   **Redoc:** [http://localhost:8000/api/docs/redoc](http://localhost:8000/api/docs/redoc)
