Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Booking API Example

A sample booking API that demonstrates how Schemathesis automatically discovers various types of bugs that manual testing typically misses.

📚 The CLI Tutorial (20 minutes) and Pytest Tutorial (15 minutes) use this API.

Overview

  • Hotel booking creation and retrieval
  • Bearer token authentication
  • Room type validation with an intentional bug
  • Open API 3.1 schema provided by FastAPI

Quick Start

Start the API:

docker compose up -d

Verify it's running:

Open http://localhost:8080/docs to see the interactive API documentation.

The API will be available at:

Authentication

All booking endpoints require bearer token authentication.

Authorization: Bearer secret-token

Test with Schemathesis

uvx schemathesis run http://localhost:8080/openapi.json \
  --header 'Authorization: Bearer secret-token'

Schemathesis will discover an edge case that causes a 500 error.

Example Usage

Create a booking:

curl -X POST "http://localhost:8080/bookings" \
  -H "Authorization: Bearer secret-token" \
  -H "Content-Type: application/json" \
  -d '{
    "guest_name": "John Doe",
    "room_type": "deluxe",
    "nights": 3
  }'

Retrieve booking:

curl -H "Authorization: Bearer secret-token" \
  http://localhost:8080/bookings/42