mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-16 16:01:05 +00:00
feat: add openapi generator and error schemas
This commit is contained in:
parent
55c45bfc12
commit
1ac5a0a23a
5 changed files with 348 additions and 0 deletions
12
engine/packages/openapi-gen/Cargo.toml
Normal file
12
engine/packages/openapi-gen/Cargo.toml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "openapi-gen"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
|
||||
[build-dependencies]
|
||||
sandbox-daemon = { path = "../sandbox-daemon" }
|
||||
serde_json = "1.0"
|
||||
utoipa = "4.2"
|
||||
20
engine/packages/openapi-gen/build.rs
Normal file
20
engine/packages/openapi-gen/build.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
use sandbox_daemon::router::ApiDoc;
|
||||
use utoipa::OpenApi;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=../sandbox-daemon/src/router.rs");
|
||||
println!("cargo:rerun-if-changed=../sandbox-daemon/src/lib.rs");
|
||||
|
||||
let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR not set");
|
||||
let out_path = Path::new(&out_dir).join("openapi.json");
|
||||
|
||||
let openapi = ApiDoc::openapi();
|
||||
let json = serde_json::to_string_pretty(&openapi)
|
||||
.expect("Failed to serialize OpenAPI spec");
|
||||
|
||||
fs::write(&out_path, json).expect("Failed to write OpenAPI spec");
|
||||
println!("cargo:warning=Generated OpenAPI spec at {}", out_path.display());
|
||||
}
|
||||
3
engine/packages/openapi-gen/src/lib.rs
Normal file
3
engine/packages/openapi-gen/src/lib.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
//! Generated OpenAPI schema output.
|
||||
|
||||
pub const OPENAPI_JSON: &str = include_str!(concat!(env!("OUT_DIR"), "/openapi.json"));
|
||||
Loading…
Add table
Add a link
Reference in a new issue