add command line flag to easily dump the api spec

This commit is contained in:
judge 2025-11-22 14:11:11 +01:00
parent 08986aa837
commit 392d48a356
No known key found for this signature in database
GPG key ID: 6512C30DD8E017B5
2 changed files with 13 additions and 4 deletions

View file

@ -1,9 +1,10 @@
use std::{path::Path, process::exit};
use std::{env::args, path::Path, process::exit};
use clap::Parser;
use config::{Config, OverlayConfig};
use paperless_api_client::Client;
use server::run_server;
use utoipa::OpenApi;
mod config;
mod extract;
@ -37,14 +38,22 @@ compile_error!(
#[clap(author, version, about, long_about = None)]
struct Args {
#[clap(long, default_value_t = false, action)]
dry_run: bool,
gen_api_spec: bool,
}
#[tokio::main]
async fn main() {
let _args = Args::parse();
let args = Args::parse();
colog::init();
if args.gen_api_spec {
println!(
"{}",
serde_json::to_string_pretty(&server::DocumentProcessingApiSpec::openapi()).unwrap()
);
exit(0);
}
let config = Config::default()
.overlay_config(OverlayConfig::read_config_toml(Path::new(
"/etc/paperless-field-extractor/config.toml",

View file

@ -351,7 +351,7 @@ async fn custom_field_prediction(
paths(suggest_correspondent, custom_field_prediction),
components(schemas(WebhookParams))
)]
struct DocumentProcessingApiSpec;
pub(crate) struct DocumentProcessingApiSpec;
struct DocumentProcessingApi;