Visitar URL original
GitHub - api2spec/api2spec-fixture-axum: api for testing and validating api2spec · GitHub
Skip to content

About

api for testing and validating api2spec

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

api2spec-fixture-axum

A TIF-compliant Tea Brewing API built with Axum. This is a target fixture for api2spec with no native OpenAPI generation.

Quick Start

# Build the project
cargo build

# Run the server
cargo run

# Run tests
cargo test

The server runs on http://localhost:3000 by default. Set the PORT environment variable to change it.

Tech Stack

Property Value
Language Rust 1.75+
Framework Axum 0.7+
Runtime Tokio
Schema Library serde + validator
Test Runner cargo test

API Endpoints

Health

Method Path Description
GET /health Basic health check
GET /health/live Liveness probe
GET /health/ready Readiness probe
GET /brew TIF 418 signature endpoint

Teapots

Method Path Description
GET /teapots List all teapots
POST /teapots Create a teapot
GET /teapots/:id Get a teapot
PUT /teapots/:id Update a teapot (full)
PATCH /teapots/:id Update a teapot (partial)
DELETE /teapots/:id Delete a teapot
GET /teapots/:id/brews List brews for a teapot

Teas

Method Path Description
GET /teas List all teas
POST /teas Create a tea
GET /teas/:id Get a tea
PUT /teas/:id Update a tea (full)
PATCH /teas/:id Update a tea (partial)
DELETE /teas/:id Delete a tea

Brews

Method Path Description
GET /brews List all brews
POST /brews Create a brew
GET /brews/:id Get a brew
PATCH /brews/:id Update a brew
DELETE /brews/:id Delete a brew
GET /brews/:id/steeps List steeps for a brew
POST /brews/:id/steeps Create a steep

Examples

# Health check
curl http://localhost:3000/health

# TIF 418 endpoint (returns "I'm a teapot")
curl http://localhost:3000/brew

# Create a teapot
curl -X POST http://localhost:3000/teapots \
  -H "Content-Type: application/json" \
  -d '{"name":"My Kyusu","material":"clay","capacityMl":350,"style":"kyusu"}'

# List teapots
curl http://localhost:3000/teapots

# Create a tea
curl -X POST http://localhost:3000/teas \
  -H "Content-Type: application/json" \
  -d '{"name":"Dragon Well","type":"green","steepTempCelsius":80,"steepTimeSeconds":120}'

# Create a brew
curl -X POST http://localhost:3000/brews \
  -H "Content-Type: application/json" \
  -d '{"teapotId":"<uuid>","teaId":"<uuid>"}'

# Record a steep
curl -X POST http://localhost:3000/brews/<brew-id>/steeps \
  -H "Content-Type: application/json" \
  -d '{"durationSeconds":60,"rating":4}'

Project Structure

api2spec-fixture-axum/
├── docs/
│   └── SPEC.md                  # Full specification
├── src/
│   ├── main.rs                  # Entry point
│   ├── lib.rs                   # Library root
│   ├── app.rs                   # Router setup
│   ├── error.rs                 # Error types
│   ├── handlers/
│   │   ├── mod.rs
│   │   ├── teapots.rs
│   │   ├── teas.rs
│   │   ├── brews.rs
│   │   └── health.rs
│   ├── models/
│   │   ├── mod.rs
│   │   ├── teapot.rs
│   │   ├── tea.rs
│   │   ├── brew.rs
│   │   ├── steep.rs
│   │   └── common.rs
│   └── store/
│       ├── mod.rs
│       └── memory.rs
├── tests/
│   └── integration_tests.rs
├── api2spec.config.toml
├── Cargo.toml
└── README.md

License

See LICENSE.md

About

api for testing and validating api2spec

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages