# Open API and Swagger UI Docs

This makes it easier to understand available routes, request bodies, path parameters, and validation schemas.

## OpenAPI Schema

The OpenAPI schema is available at:

```
/openapi.json
```

This endpoint returns a JSON specification generated from your registered routes, route metadata, path parameters, and Pydantic models.

## Swagger UI

Slush also provides an interactive API documentation page at:

```
/docs
```

You can open this URL in your browser to view and test your API endpoints.

## Example

```python
from pydantic import BaseModel
from slush.app import Slush

app = Slush()

class UserCreate(BaseModel):
    name: str
    age: int

@app.route("/users", methods=["POST"])
def create_user(request, body: UserCreate):
    return {
        "name": body.name,
        "age": body.age
    }
```

This route will appear in the generated OpenAPI schema, and the `UserCreate` model will be included as a request body schema.

## Summary

OpenAPI and Swagger UI support in Slush allows you to:

* Generate API schemas automatically
* View API documentation in the browser
* Test endpoints from an interactive interface
* Document Pydantic request models automatically


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://slush.gitbook.io/docs/documentation/basics/open-api-and-swagger-ui-docs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
