Skip to content

Commit

Permalink
feat: add the management API (readonly). Generate the OpenAPI spec (#154
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Angelmmiguel authored Jun 12, 2023
1 parent 0d70c87 commit 5941d1f
Show file tree
Hide file tree
Showing 20 changed files with 518 additions and 26 deletions.
99 changes: 79 additions & 20 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ openssl = { version = "=0.10.48", features = ["vendored"] }

[workspace]
members = [
"crates/api-manage",
"crates/api-manage-openapi",
"crates/config",
"crates/data-kv",
"crates/project",
Expand Down Expand Up @@ -79,6 +81,8 @@ wws-server = { path = "./crates/server" }
wws-store = { path = "./crates/store" }
wws-worker = { path = "./crates/worker" }
wws-project = { path = "./crates/project" }
wws-api-manage = { path = "./crates/api-manage" }
wws-api-manage-openapi = { path = "./crates/api-manage-openapi" }
wasmtime = "6.0.2"
wasmtime-wasi = "6.0.2"
wasi-common = "6.0.2"
Expand Down
13 changes: 13 additions & 0 deletions crates/api-manage-openapi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "wws-api-manage-openapi"
version = { workspace = true }
edition = { workspace = true }
authors = { workspace = true }
license = { workspace = true }
repository = { workspace = true }

[dependencies]

[build-dependencies]
utoipa = { version = "3.3.0", features = ["actix_extras"] }
wws-api-manage = { path = "../api-manage" }
14 changes: 14 additions & 0 deletions crates/api-manage-openapi/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2023 VMware, Inc.
// SPDX-License-Identifier: Apache-2.0

// Trick to generate the OpenAPI spec on build time.
// See: https://github.com/juhaku/utoipa/issues/214#issuecomment-1179589373

use std::fs;
use utoipa::OpenApi;
use wws_api_manage::ApiDoc;

fn main() {
let spec = ApiDoc::openapi().to_pretty_json().unwrap();
fs::write("./src/openapi.json", spec).expect("Error writing the OpenAPI documentation");
}
5 changes: 5 additions & 0 deletions crates/api-manage-openapi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright 2023 VMware, Inc.
// SPDX-License-Identifier: Apache-2.0

/// Contains the Open API Spec of the wws management API.
pub static OPEN_API_SPEC: &str = include_str!("./openapi.json");
Loading

0 comments on commit 5941d1f

Please sign in to comment.