diff --git a/.github/workflows/gen-openapi.yml b/.github/workflows/gen-openapi.yml index 880772b0..4cbbe486 100644 --- a/.github/workflows/gen-openapi.yml +++ b/.github/workflows/gen-openapi.yml @@ -17,7 +17,7 @@ jobs: - uses: actions-rs/cargo@v1 with: command: run - args: --bin gen-openapi --features "swagger gen_api" --no-default-features + args: -p utils --bin gen-openapi - uses: actions/upload-artifact@v3 with: name: API schemas diff --git a/Cargo.toml b/Cargo.toml index 5dc6f159..a01413c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ license-file = "./LICENSE" edition = "2021" [workspace] -members = [ "cli", "frontend", "backend" ] +members = [ "cli", "frontend", "backend", "utils" ] default-members = [ "frontend", "backend"] resolver = "2" diff --git a/backend/Cargo.toml b/backend/Cargo.toml index ed3d0900..0043e8d7 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -10,11 +10,6 @@ edition.workspace = true readme.workspace = true repository.workspace = true -[[bin]] -name = "gen-openapi" -path = "gen_openapi.rs" -required-features = [ "swagger", "gen_api" ] - [dependencies] # Backend (lib.rs) ## Axum related diff --git a/utils/Cargo.toml b/utils/Cargo.toml new file mode 100644 index 00000000..dd9acc3d --- /dev/null +++ b/utils/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "utils" +description = "Bob Management GUI: Utility tools" +publish = false +keywords = [ "BOB", "Management", "GUI" ] +version.workspace = true +authors.workspace = true +license-file.workspace = true +edition.workspace = true +readme.workspace = true +repository.workspace = true + +[[bin]] +name = "gen-openapi" +path = "gen_openapi.rs" +required-features = [ "gen_api" ] + +[dependencies] +backend = { path = "../backend/", optional = true } + +## OpenAPI + Swagger +utoipa = { version = "4.0", features = ["yaml"], optional = true } + +[features] +default = [ "gen_api" ] +gen_api = [ "dep:utoipa", "backend/swagger"] diff --git a/backend/gen_openapi.rs b/utils/gen_openapi.rs similarity index 85% rename from backend/gen_openapi.rs rename to utils/gen_openapi.rs index 8f8e4cf8..324f9cfb 100644 --- a/backend/gen_openapi.rs +++ b/utils/gen_openapi.rs @@ -1,6 +1,5 @@ use std::fs; use utoipa::OpenApi; -// in ./src/gen_openapi.rs fn main() { let doc = backend::ApiDoc::openapi().to_yaml().unwrap(); let _ = fs::write("./api/openapi.yaml", doc);