diff --git a/.github/workflows/check-format.yaml b/.github/workflows/check-format.yaml index c371591c4..3fd647227 100644 --- a/.github/workflows/check-format.yaml +++ b/.github/workflows/check-format.yaml @@ -17,10 +17,6 @@ jobs: run: | rustup show - - uses: Swatinem/rust-cache@v2 - with: - shared-key: "build" # share the cache across jobs - - name: check formatting run: | cargo fmt --all --check diff --git a/.github/workflows/schema-definitions.yaml b/.github/workflows/schema-definitions.yaml index a1c67196d..9b2f77e45 100644 --- a/.github/workflows/schema-definitions.yaml +++ b/.github/workflows/schema-definitions.yaml @@ -13,11 +13,14 @@ jobs: - uses: actions/checkout@v4 - name: install tools - run: rustup show + run: | + rustup show + # install cargo-nextest + curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin - uses: Swatinem/rust-cache@v2 with: shared-key: "build" # share the cache across jobs - name: OpenAPI Definitions - run: cargo test --bin openapi-generator + run: cargo nextest run --no-fail-fast --release --bin openapi-generator diff --git a/crates/documentation/openapi/src/main.rs b/crates/documentation/openapi/src/main.rs index 73d97c355..7b5e5135e 100644 --- a/crates/documentation/openapi/src/main.rs +++ b/crates/documentation/openapi/src/main.rs @@ -1,31 +1,30 @@ +use std::io; + use ndc_postgres::configuration::RawConfiguration; use schemars::{gen::SchemaSettings, schema::RootSchema}; -fn main() { - let schema: RootSchema = SchemaSettings::openapi3() - .into_generator() - .into_root_schema_for::(); +fn main() -> io::Result<()> { + let schema = generate_schema(); + serde_json::to_writer_pretty(io::stdout(), &schema)?; + Ok(()) +} - println!("{}", serde_json::to_string_pretty(&schema).unwrap()); +fn generate_schema() -> RootSchema { + SchemaSettings::openapi3() + .into_generator() + .into_root_schema_for::() } #[cfg(test)] mod tests { - use std::process::Command; + use super::*; #[test] - fn main() { - let command_output = Command::new("cargo") - .arg("run") - .arg("--bin") - .arg("openapi-generator") - .output() - .expect("Failed to run schema generation") - .stdout; - - let generated_schema: String = - String::from_utf8(command_output).expect("Failed to read snapshot"); + fn main() -> io::Result<()> { + let generated_schema = generate_schema(); + let generated_schema_json = serde_json::to_string_pretty(&generated_schema)?; - insta::assert_snapshot!(generated_schema); + insta::assert_snapshot!(generated_schema_json); + Ok(()) } }