Skip to content

Commit c5b2bb2

Browse files
committed
Remove .codegen.json logic
This was only used to tell us which `openapi.json` was used to generate each file. But new we use 'lib-openapi.json' that is in webhooks
1 parent 09781fc commit c5b2bb2

File tree

2 files changed

+0
-33
lines changed

2 files changed

+0
-33
lines changed

src/main.rs

-25
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ struct GenerateFlags {
6060
/// Write api.ron and types.ron files, as a debugging aid.
6161
#[clap(long)]
6262
debug: bool,
63-
64-
/// Write `.codegen.json` file
65-
#[clap(long)]
66-
write_codegen_metadata: bool,
6763
}
6864

6965
fn main() -> anyhow::Result<()> {
@@ -78,16 +74,12 @@ fn main() -> anyhow::Result<()> {
7874
} = args.command;
7975

8076
let spec = fs::read_to_string(&input_file)?;
81-
let input_sha256sum = util::sha256sum_string(&spec);
8277

8378
let spec: OpenApi = serde_json::from_str(&spec).context("failed to parse OpenAPI spec")?;
8479

8580
match &output_dir {
8681
Some(path) => {
8782
analyze_and_generate(spec, template.into(), path, flags)?;
88-
if flags.write_codegen_metadata {
89-
write_codegen_metadata(input_sha256sum, path)?;
90-
}
9183
}
9284
None => {
9385
let output_dir_root = PathBuf::from("out");
@@ -110,9 +102,6 @@ fn main() -> anyhow::Result<()> {
110102
.try_into()
111103
.context("non-UTF8 tempdir path")?;
112104
analyze_and_generate(spec, template.into(), path, flags)?;
113-
if flags.write_codegen_metadata {
114-
write_codegen_metadata(input_sha256sum, path)?;
115-
}
116105
// Persist the TempDir if everything was successful
117106
_ = output_dir.into_path();
118107
}
@@ -148,20 +137,6 @@ fn analyze_and_generate(
148137
Ok(())
149138
}
150139

151-
fn write_codegen_metadata(input_sha256sum: String, output_dir: &Utf8Path) -> anyhow::Result<()> {
152-
let metadata_path = output_dir.join(".codegen.json");
153-
let current_timestamp = chrono::Utc::now().to_rfc3339();
154-
let codegen_metadata = serde_json::json!({
155-
"openapi-codegen-version": env!("CARGO_PKG_VERSION"),
156-
"openapi.json-sha256": input_sha256sum,
157-
"git-rev": env!("VERGEN_GIT_SHA"),
158-
"file-generated-at": current_timestamp,
159-
});
160-
let encoded_metadata = serde_json::to_vec_pretty(&codegen_metadata)?;
161-
std::fs::write(metadata_path, &encoded_metadata)?;
162-
Ok(())
163-
}
164-
165140
fn get_webhooks(spec: &OpenApi) -> Vec<String> {
166141
let empty_obj = serde_json::json!({});
167142
let empty_obj = empty_obj.as_object().unwrap();

src/util.rs

-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use sha2::{Digest, Sha256};
21
use std::collections::BTreeMap;
32

43
use serde::ser::{Serialize, SerializeSeq as _, Serializer};
@@ -29,10 +28,3 @@ where
2928
}
3029
seq.end()
3130
}
32-
33-
pub(crate) fn sha256sum_string(s: &str) -> String {
34-
let mut hasher = Sha256::new();
35-
hasher.update(s.as_bytes());
36-
let hash = hasher.finalize();
37-
format!("{hash:x}")
38-
}

0 commit comments

Comments
 (0)