diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ddf39c28..24c5287c 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -101,7 +101,6 @@ jobs: # execution so this value is required for preventing meta tests from # panicking GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 - OPEN_API_DOCS: 8e77345f1597e40c2e266cb4e6dee74888918a61 CACHE_BUSTER_FILE_MAP: '{"map":{"./static/bundle/main.js":"./prod/bundle/main.1417115E59909BE0A01040A45A398ADB09D928DF89CCF038FA44B14850442096.js"},"base_dir":"./prod"}' COMPILED_DATE: "2021-07-21" diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 25260cf8..d171f525 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -95,7 +95,6 @@ jobs: env: DATABASE_URL: postgres://postgres:password@localhost:5432/postgres GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value - OPEN_API_DOCS: 8e77345f1597e40c2e266cb4e6dee74888918a61 COMPILED_DATE: "2021-07-21" - name: Deploy to GitHub Pages diff --git a/Cargo.lock b/Cargo.lock index bb1ccb59..31b6ee17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1608,12 +1608,10 @@ dependencies = [ "sailfish", "serde 1.0.127", "serde_json", - "serde_yaml", "sqlx", "tokio", "url", "validator", - "yaml-rust", ] [[package]] @@ -2627,18 +2625,6 @@ dependencies = [ "serde 1.0.127", ] -[[package]] -name = "serde_yaml" -version = "0.8.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "039ba818c784248423789eec090aab9fb566c7b94d6ebbfa1814a9fd52c8afb2" -dependencies = [ - "dtoa", - "linked-hash-map", - "serde 1.0.127", - "yaml-rust", -] - [[package]] name = "sha-1" version = "0.9.7" diff --git a/Cargo.toml b/Cargo.toml index 0ad241c9..957f3243 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,7 +55,6 @@ derive_more = "0.99" serde = "1" serde_json = "1" -serde_yaml = "0.8.17" url = "2.2" @@ -85,9 +84,7 @@ openssl = { version = "0.10.29", features = ["vendored"] } [build-dependencies] -serde_yaml = "0.8.17" serde_json = "1" -yaml-rust = "0.4.5" cache-buster = { version = "0.2.0", git = "https://github.com/realaravinth/cache-buster" } mime = "0.3.16" sqlx = { version = "0.5.5", features = [ "runtime-actix-rustls", "postgres", "time", "offline" ] } diff --git a/build.rs b/build.rs index fafd88a4..60d504f9 100644 --- a/build.rs +++ b/build.rs @@ -28,13 +28,6 @@ fn main() { let git_hash = String::from_utf8(output.stdout).unwrap(); println!("cargo:rustc-env=GIT_HASH={}", git_hash); - let yml = include_str!("./openapi.yaml"); - let api_json: serde_json::Value = serde_yaml::from_str(yml).unwrap(); - println!( - "cargo:rustc-env=OPEN_API_DOCS={}", - serde_json::to_string(&api_json).unwrap() - ); - let now = OffsetDateTime::now_utc().format("%y-%m-%d"); println!("cargo:rustc-env=COMPILED_DATE={}", &now); diff --git a/src/docs.rs b/src/docs.rs index fad45a95..da052404 100644 --- a/src/docs.rs +++ b/src/docs.rs @@ -36,7 +36,7 @@ pub mod routes { pub const fn new() -> Self { Docs { home: "/docs/", - spec: "/docs/openapi.json", + spec: "/docs/openapi.yaml", assets: "/docs/{_:.*}", } } @@ -73,12 +73,13 @@ pub fn handle_embedded_file(path: &str) -> HttpResponse { async fn dist(path: web::Path) -> impl Responder { handle_embedded_file(&path) } +const OPEN_API_SPEC: &str = include_str!("../openapi.yaml"); #[my_codegen::get(path = "DOCS.spec")] async fn spec() -> HttpResponse { HttpResponse::Ok() - .content_type("appilcation/json") - .body(&*crate::OPEN_API_DOC) + .content_type("text/yaml") + .body(OPEN_API_SPEC) } #[my_codegen::get(path = "&DOCS.home[0..DOCS.home.len() -1]")] diff --git a/src/main.rs b/src/main.rs index 57214870..88bbcd39 100644 --- a/src/main.rs +++ b/src/main.rs @@ -86,7 +86,6 @@ lazy_static! { } -pub const OPEN_API_DOC: &str = env!("OPEN_API_DOCS"); pub const COMPILED_DATE: &str = env!("COMPILED_DATE"); pub const GIT_COMMIT_HASH: &str = env!("GIT_HASH"); pub const VERSION: &str = env!("CARGO_PKG_VERSION"); diff --git a/src/tests-migrate.rs b/src/tests-migrate.rs index 5e592924..81f7666b 100644 --- a/src/tests-migrate.rs +++ b/src/tests-migrate.rs @@ -59,12 +59,6 @@ fn build() { let git_hash = String::from_utf8(output.stdout).unwrap(); println!("cargo:rustc-env=GIT_HASH={}", git_hash); - let yml = include_str!("../openapi.yaml"); - let api_json: serde_json::Value = serde_yaml::from_str(yml).unwrap(); - println!( - "cargo:rustc-env=OPEN_API_DOCS={}", - serde_json::to_string(&api_json).unwrap() - ); cache_bust(); } diff --git a/static/openapi/index.html b/static/openapi/index.html index 4116f441..529b3ace 100644 --- a/static/openapi/index.html +++ b/static/openapi/index.html @@ -39,7 +39,7 @@ window.onload = function() { // Begin Swagger UI call region const ui = SwaggerUIBundle({ - url: "/docs/openapi.json", + url: "/docs/openapi.yaml", dom_id: '#swagger-ui', deepLinking: true, presets: [