Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 72 additions & 11 deletions out/openapi.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/core/api-public/src/actors/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub struct DeleteResponse {}
responses(
(status = 200, body = DeleteResponse),
),
security(("bearer_auth" = [])),
)]
pub async fn delete(
Extension(ctx): Extension<ApiCtx>,
Expand Down
1 change: 1 addition & 0 deletions packages/core/api-public/src/actors/list_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use crate::ctx::ApiCtx;
responses(
(status = 200, body = ListNamesResponse),
),
security(("bearer_auth" = [])),
)]
pub async fn list_names(
Extension(ctx): Extension<ApiCtx>,
Expand Down
1 change: 1 addition & 0 deletions packages/core/api-public/src/datacenters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::ctx::ApiCtx;
responses(
(status = 200, body = ListResponse),
),
security(("bearer_auth" = [])),
)]
pub async fn list(Extension(ctx): Extension<ApiCtx>) -> Response {
match list_inner(ctx).await {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/api-public/src/namespaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::ctx::ApiCtx;
responses(
(status = 200, body = ListResponse),
),
security(("bearer_auth" = [])),
)]
pub async fn list(
Extension(ctx): Extension<ApiCtx>,
Expand Down Expand Up @@ -59,6 +60,7 @@ async fn list_inner(ctx: ApiCtx, headers: HeaderMap, query: ListQuery) -> Result
responses(
(status = 200, body = CreateResponse),
),
security(("bearer_auth" = [])),
)]
pub async fn create(
Extension(ctx): Extension<ApiCtx>,
Expand Down
54 changes: 38 additions & 16 deletions packages/core/api-public/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,28 @@ use utoipa::OpenApi;
use crate::{actors, ctx, datacenters, namespaces, runner_configs, runners, ui};

#[derive(OpenApi)]
#[openapi(paths(
actors::list::list,
actors::create::create,
actors::delete::delete,
actors::list_names::list_names,
actors::get_or_create::get_or_create,
runners::list,
runners::list_names,
namespaces::list,
namespaces::create,
runner_configs::list,
runner_configs::upsert,
runner_configs::delete,
datacenters::list,
))]
#[openapi(components(schemas(namespace::keys::RunnerConfigVariant)))]
#[openapi(
paths(
actors::list::list,
actors::create::create,
actors::delete::delete,
actors::list_names::list_names,
actors::get_or_create::get_or_create,
runners::list,
runners::list_names,
namespaces::list,
namespaces::create,
runner_configs::list,
runner_configs::upsert,
runner_configs::delete,
datacenters::list,
),
components(
schemas(namespace::keys::RunnerConfigVariant)
),
security( ("bearer_auth" = []) ),
modifiers(&SecurityAddon),
)]
pub struct ApiDoc;

pub async fn router(
Expand Down Expand Up @@ -118,3 +124,19 @@ async fn auth_middleware(

Ok(res)
}

struct SecurityAddon;

impl utoipa::Modify for SecurityAddon {
fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) {
openapi.components.as_mut().unwrap().add_security_scheme(
"bearer_auth",
utoipa::openapi::security::SecurityScheme::Http(
utoipa::openapi::security::HttpBuilder::new()
.scheme(utoipa::openapi::security::HttpAuthScheme::Bearer)
// .bearer_format("Rivet")
.build(),
),
);
}
}
3 changes: 3 additions & 0 deletions packages/core/api-public/src/runner_configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::ctx::ApiCtx;
responses(
(status = 200, body = ListResponse),
),
security(("bearer_auth" = [])),
)]
pub async fn list(
Extension(ctx): Extension<ApiCtx>,
Expand Down Expand Up @@ -71,6 +72,7 @@ async fn list_inner(
responses(
(status = 200, body = UpsertResponse),
),
security(("bearer_auth" = [])),
)]
pub async fn upsert(
Extension(ctx): Extension<ApiCtx>,
Expand Down Expand Up @@ -122,6 +124,7 @@ async fn upsert_inner(
responses(
(status = 200, body = DeleteResponse),
),
security(("bearer_auth" = [])),
)]
pub async fn delete(
Extension(ctx): Extension<ApiCtx>,
Expand Down
18 changes: 10 additions & 8 deletions packages/core/api-public/src/runners.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use crate::ctx::ApiCtx;
responses(
(status = 200, body = ListResponse),
),
security(("bearer_auth" = [])),
)]
pub async fn list(
Extension(ctx): Extension<ApiCtx>,
Expand Down Expand Up @@ -85,14 +86,15 @@ pub struct ListNamesResponse {
/// - GET /runners/names (fanout)
/// - [api-peer] namespace::ops::resolve_for_name_global
#[utoipa::path(
get,
operation_id = "runners_list_names",
path = "/runners/names",
params(ListNamesQuery),
responses(
(status = 200, body = ListNamesResponse),
),
)]
get,
operation_id = "runners_list_names",
path = "/runners/names",
params(ListNamesQuery),
responses(
(status = 200, body = ListNamesResponse),
),
security(("bearer_auth" = [])),
)]
pub async fn list_names(
Extension(ctx): Extension<ApiCtx>,
headers: HeaderMap,
Expand Down
Loading