chore: output openapi.json

This commit is contained in:
2026-01-10 02:29:52 -08:00
parent 4251f6981d
commit ce04aa5947
3 changed files with 4 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
mod db
_default:
just --list api
just --list
migrate:
sqlx migrate run

1
openapi.json Normal file
View File

@@ -0,0 +1 @@
{"openapi":"3.1.0","info":{"title":"api","description":"","license":{"name":""},"version":"0.1.0"},"paths":{"/":{"get":{"operationId":"index","responses":{"200":{"description":"Success","content":{"text/plain":{"schema":{"type":"string"}}}}}}},"/.well-known/health-check":{"get":{"summary":"Get health of the API.","operationId":"health_check","responses":{"200":{"description":"Success","content":{"text/plain":{"schema":{"type":"string"}}}}}}},"/api/v1/auth/login":{"post":{"tags":["auth"],"summary":"Login","operationId":"login","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginBody"}}},"required":true},"responses":{"200":{"description":"","content":{"text/plain":{"schema":{"type":"string"}}}}}}},"/api/v1/auth/signup":{"post":{"tags":["auth"],"summary":"Sign up","operationId":"signup","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignupBody"}}},"required":true},"responses":{"200":{"description":"","content":{"text/plain":{"schema":{"type":"string"}}}}}}},"/api/v1/exercises/create":{"post":{"tags":["exercises"],"operationId":"create","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateExerciseBody"}}},"required":true},"responses":{"200":{"description":"","content":{"text/plain":{"schema":{"type":"string"}}}}}}},"/api/v1/muscles/all":{"get":{"tags":["muscles"],"operationId":"get_all","responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Muscle"}}}}}}},"/api/v1/muscles/create":{"post":{"tags":["muscles"],"operationId":"create","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateMuscleBody"}}},"required":true},"responses":{"200":{"description":"","content":{"text/plain":{"schema":{"type":"string"}}}}}}}},"components":{"schemas":{"CreateExerciseBody":{"type":"object","required":["name","exercise_type","description","body_parts","primary_muscles","secondary_muscles"],"properties":{"body_parts":{"type":"array","items":{"type":"string"}},"description":{"type":"string"},"exercise_type":{"$ref":"#/components/schemas/ExerciseType"},"name":{"type":"string"},"primary_muscles":{"type":"array","items":{"type":"string"}},"secondary_muscles":{"type":"array","items":{"type":"string"}}}},"CreateMuscleBody":{"type":"object","required":["name","scientific_name","major_group","minor_group"],"properties":{"major_group":{"type":"string"},"minor_group":{"type":"string"},"name":{"type":"string"},"scientific_name":{"type":"string"}}},"ExerciseType":{"type":"string","enum":["Dumbbell","Barbell","Bodyweight","Machine","Kettlebell","ResistanceBand","Cable","MedicineBall","Plyometric","PlateLoadedMachine"]},"LoginBody":{"type":"object","required":["username","password"],"properties":{"password":{"type":"string"},"username":{"type":"string"}}},"Muscle":{"type":"object","required":["id","name","minor_group"],"properties":{"id":{"type":"string"},"major_group":{"type":["string","null"]},"minor_group":{"type":"string"},"name":{"type":"string"},"scientific_name":{"type":["string","null"]}}},"SignupBody":{"type":"object","required":["real_name","username","email","password"],"properties":{"email":{"type":"string"},"password":{"type":"string"},"real_name":{"type":"string"},"username":{"type":"string"}}}}},"tags":[{"name":"auth","description":"Authentication API endpoints"},{"name":"exercises","description":"Exercise API endpoints"},{"name":"muscles","description":"Muscle API endpoints"}]}

View File

@@ -76,6 +76,8 @@ async fn main() -> anyhow::Result<()> {
.nest("/api/v1", v1::router(state.clone()))
.split_for_parts();
tokio::fs::write("openapi.json", api.to_json()?).await?;
let router = router.merge(SwaggerUi::new("/docs").url("/docs/openapi.json", api));
println!("Listening on http://localhost:{port}");