From ce04aa5947ab815be45e1a688ba47a46efef2561 Mon Sep 17 00:00:00 2001 From: Alexander Ng Date: Sat, 10 Jan 2026 02:29:52 -0800 Subject: [PATCH] chore: output openapi.json --- mod.just => Justfile | 2 +- openapi.json | 1 + src/main.rs | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) rename mod.just => Justfile (83%) create mode 100644 openapi.json diff --git a/mod.just b/Justfile similarity index 83% rename from mod.just rename to Justfile index d92dba8..3249df8 100644 --- a/mod.just +++ b/Justfile @@ -1,6 +1,6 @@ mod db _default: - just --list api + just --list migrate: sqlx migrate run diff --git a/openapi.json b/openapi.json new file mode 100644 index 0000000..94c1007 --- /dev/null +++ b/openapi.json @@ -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"}]} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index e6fdf71..e5705df 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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}");