Skip to content

Commit 17ca650

Browse files
committed
Address review comments
1 parent 3c71575 commit 17ca650

File tree

1 file changed

+6
-6
lines changed
  • compiler-rs/openapi_to_clients_schema/src

1 file changed

+6
-6
lines changed

compiler-rs/openapi_to_clients_schema/src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,25 @@ fn main() -> anyhow::Result<()> {
3030
// let path = "./fixtures/kibana.serverless.yaml";
3131

3232
info!("Loading OpenAPI from {path}");
33-
let file = std::fs::File::open(path)?;
33+
let data = std::fs::read_to_string(path)?;
3434

3535
// Track unused fields, to find any additional stuff the OpenAPI model would miss
3636
let mut unused = BTreeSet::new();
3737

3838
let open_api = match Path::new(path).extension() {
3939
Some(ext) if ext == "json" => {
40-
let deser = &mut serde_json::Deserializer::from_reader(file);
41-
serde_ignored::deserialize(deser, |path| {
40+
let mut deser = serde_json::Deserializer::from_str(&data);
41+
serde_ignored::deserialize(&mut deser, |path| {
4242
unused.insert(path.to_string());
4343
})
44-
.map_err(|err| From::from(err))
44+
.map_err(From::from)
4545
}
4646
Some(ext) if ext == "yml" || ext == "yaml" => {
47-
let deser = serde_yml::Deserializer::from_reader(file);
47+
let deser = serde_yml::Deserializer::from_str(&data);
4848
serde_ignored::deserialize(deser, |path| {
4949
unused.insert(path.to_string());
5050
})
51-
.map_err(|err| From::from(err))
51+
.map_err(From::from)
5252
}
5353
_ => Err(anyhow::anyhow!(format!("Unsupported file extension {:?}", path))),
5454
}?;

0 commit comments

Comments
 (0)