Skip to content

Commit

Permalink
Merge branch 'main' into refactor/drop-json-yaml-support
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath authored Dec 9, 2024
2 parents 38ff5b6 + 858ac97 commit 30691fd
Show file tree
Hide file tree
Showing 10 changed files with 323 additions and 166 deletions.
91 changes: 44 additions & 47 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions npm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions src/cli/generator/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,13 @@ pub enum Source<Status = UnResolved> {
is_mutation: Option<bool>,
field_name: String,
},
#[serde(rename_all = "camelCase")]
Proto {
src: Location<Status>,
url: String,
#[serde(skip_serializing_if = "Option::is_none")]
proto_paths: Option<Vec<Location<Status>>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "connectRPC")]
connect_rpc: Option<bool>,
},
Expand Down Expand Up @@ -220,9 +223,20 @@ impl Source<UnResolved> {
is_mutation,
})
}
Source::Proto { src, url, connect_rpc } => {
Source::Proto { src, url, proto_paths, connect_rpc } => {
let resolved_path = src.into_resolved(parent_dir);
Ok(Source::Proto { src: resolved_path, url, connect_rpc })
let resolved_proto_paths = proto_paths.map(|paths| {
paths
.into_iter()
.map(|path| path.into_resolved(parent_dir))
.collect()
});
Ok(Source::Proto {
src: resolved_path,
url,
proto_paths: resolved_proto_paths,
connect_rpc,
})
}
Source::Config { src } => {
let resolved_path = src.into_resolved(parent_dir);
Expand Down
6 changes: 4 additions & 2 deletions src/cli/generator/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,11 @@ impl Generator {
headers: headers.into_btree_map(),
});
}
Source::Proto { src, url, connect_rpc } => {
Source::Proto { src, url, proto_paths, connect_rpc } => {
let path = src.0;
let mut metadata = proto_reader.read(&path).await?;
let proto_paths =
proto_paths.map(|paths| paths.into_iter().map(|l| l.0).collect::<Vec<_>>());
let mut metadata = proto_reader.read(&path, proto_paths.as_deref()).await?;
if let Some(relative_path_to_proto) = to_relative_path(output_dir, &path) {
metadata.path = relative_path_to_proto;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/config/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl ConfigReader {
}
}
LinkType::Protobuf => {
let meta = self.proto_reader.read(path).await?;
let meta = self.proto_reader.read(path, None).await?;
extensions.add_proto(meta);
}
LinkType::Script => {
Expand Down
Loading

0 comments on commit 30691fd

Please sign in to comment.