Skip to main content

max / makenotwork

4.0 KB · 94 lines History Blame Raw
1 //! OpenAPI spec generation and endpoint.
2 //!
3 //! Collects documented API operations into a single spec served at
4 //! `/api/openapi.json`. Only public/stable endpoints are included —
5 //! internal dashboard and HTMX endpoints are intentionally excluded.
6
7 use axum::{Json, response::IntoResponse};
8 use utoipa::OpenApi;
9
10 /// OpenAPI spec collecting all documented endpoints.
11 ///
12 /// Add new handler paths and schema types here as endpoints are annotated.
13 #[derive(OpenApi)]
14 #[openapi(
15 info(
16 title = "MakeNotWork API",
17 description = "Creator marketplace API. Only public and stable endpoints are documented.",
18 version = env!("CARGO_PKG_VERSION"),
19 license(name = "PolyForm Noncommercial 1.0.0"),
20 ),
21 paths(
22 // License Keys
23 crate::routes::api::license_keys::validate_key,
24 crate::routes::api::license_keys::deactivate_key,
25 crate::routes::api::license_keys::key_status,
26 crate::routes::api::license_keys::license_verify,
27 crate::routes::api::license_keys::license_deactivate,
28 crate::routes::api::license_keys::license_text,
29 // SyncKit — Auth
30 crate::routes::synckit::auth::sync_auth,
31 crate::routes::synckit::auth::validate_app,
32 // SyncKit — Sync
33 crate::routes::synckit::sync::sync_push,
34 crate::routes::synckit::sync::sync_pull,
35 crate::routes::synckit::sync::sync_status,
36 crate::routes::synckit::sync::register_device,
37 crate::routes::synckit::sync::list_devices,
38 crate::routes::synckit::sync::delete_device,
39 crate::routes::synckit::sync::put_sync_key,
40 crate::routes::synckit::sync::get_sync_key,
41 // SyncKit — Blobs
42 crate::routes::synckit::blobs::blob_upload_url,
43 crate::routes::synckit::blobs::blob_confirm_upload,
44 crate::routes::synckit::blobs::blob_download_url,
45 ),
46 components(schemas(
47 // License Keys
48 crate::routes::api::license_keys::ValidateKeyRequest,
49 crate::routes::api::license_keys::ValidateKeyResponse,
50 crate::routes::api::license_keys::ValidateKeyLicense,
51 crate::routes::api::license_keys::DeactivateKeyRequest,
52 crate::routes::api::license_keys::DeactivateKeyResponse,
53 crate::routes::api::license_keys::KeyStatusResponse,
54 crate::routes::api::license_keys::KeyStatusLicense,
55 crate::routes::api::license_keys::LicenseVerifyRequest,
56 crate::routes::api::license_keys::LicenseVerifyResponse,
57 crate::routes::api::license_keys::LicenseDeactivateRequest,
58 // SyncKit
59 crate::routes::synckit::SyncAuthRequest,
60 crate::routes::synckit::SyncAuthResponse,
61 crate::routes::synckit::ValidateAppQuery,
62 crate::routes::synckit::ValidateAppResponse,
63 crate::routes::synckit::PushRequest,
64 crate::routes::synckit::ChangeEntry,
65 crate::routes::synckit::PushResponse,
66 crate::routes::synckit::PullRequest,
67 crate::routes::synckit::PullResponse,
68 crate::routes::synckit::PullChangeEntry,
69 crate::routes::synckit::SyncDeviceResponse,
70 crate::routes::synckit::RegisterDeviceRequest,
71 crate::routes::synckit::SyncStatusResponse,
72 crate::routes::synckit::PutKeyRequest,
73 crate::routes::synckit::GetKeyResponse,
74 crate::routes::synckit::BlobUploadUrlRequest,
75 crate::routes::synckit::BlobUploadUrlResponse,
76 crate::routes::synckit::BlobConfirmRequest,
77 crate::routes::synckit::BlobDownloadUrlRequest,
78 crate::routes::synckit::BlobDownloadUrlResponse,
79 )),
80 tags(
81 (name = "License Keys", description = "Public license key validation, activation, and deactivation. Stable API — response shapes are frozen."),
82 (name = "SyncKit", description = "E2E encrypted cloud sync for indie apps. JWT auth via /api/v1/sync/auth, then Bearer token on all other endpoints."),
83 ),
84 security(
85 ("bearer" = []),
86 ),
87 )]
88 struct ApiDoc;
89
90 /// Serve the OpenAPI spec as JSON.
91 pub async fn openapi_json() -> impl IntoResponse {
92 Json(ApiDoc::openapi())
93 }
94