Skip to content

Commit

Permalink
add support for oauth2 flows. make ${service}Client much cheaper to c…
Browse files Browse the repository at this point in the history
…lone

now requires httpclient 0.20
  • Loading branch information
kurtbuilds committed Dec 25, 2023
1 parent dbbce5b commit c8876a1
Show file tree
Hide file tree
Showing 19 changed files with 499 additions and 388 deletions.
84 changes: 41 additions & 43 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ name = "ln_core"
anyhow = "1.0.71"
clap = { version = "4.3.11", features = ["derive"] }
convert_case = "0.6.0"
openapiv3-extended = "3"
openapiv3-extended = "4"
serde = { version = "1.0.166", features = ["derive"] }
quote = "1.0.29"
serde_json = "1.0.100"
Expand Down
25 changes: 12 additions & 13 deletions core/src/child_schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,22 @@ pub trait ChildSchemas {

impl ChildSchemas for Schema {
fn add_child_schemas<'a>(&'a self, acc: &mut HashMap<String, &'a Schema>) {
match &self.schema_kind {
match &self.kind {
SchemaKind::Type(Type::Array(a)) => {
let Some(items) = &a.items else { return; };
let Some(items) = items.as_item() else { return; };
let items = items.as_ref();
if let Some(title) = &items.schema_data.title {
acc.entry(title.clone()).or_insert(items);
let Some(item) = items.as_item() else { return; };
if let Some(title) = &item.title {
acc.entry(title.clone()).or_insert(item);
}
items.add_child_schemas(acc);
item.add_child_schemas(acc);
}
SchemaKind::Type(Type::Object(o)) => {
if let Some(title) = &self.schema_data.title {
if let Some(title) = &self.title {
acc.entry(title.clone()).or_insert(self);
}
for (_name, prop) in &o.properties {
let Some(prop) = prop.as_item() else { continue; };
if let Some(title) = &prop.schema_data.title {
if let Some(title) = &prop.title {
acc.entry(title.clone()).or_insert(prop);
}
prop.add_child_schemas(acc);
Expand All @@ -36,7 +35,7 @@ impl ChildSchemas for Schema {
| SchemaKind::AnyOf { any_of: schemas} => {
for schema in schemas {
let Some(schema) = schema.as_item() else { continue; };
if let Some(title) = &schema.schema_data.title {
if let Some(title) = &schema.title {
acc.entry(title.clone()).or_insert(schema);
}
schema.add_child_schemas(acc);
Expand All @@ -57,7 +56,7 @@ impl ChildSchemas for Operation {
}
for par in &self.parameters {
let Some(par) = par.as_item() else { continue; };
let Some(schema) = par.parameter_data_ref().schema() else { continue; };
let Some(schema) = par.data.schema() else { continue; };
let Some(schema) = schema.as_item() else { continue; };
schema.add_child_schemas(acc);
}
Expand All @@ -73,7 +72,7 @@ impl ChildSchemas for RequestBody {
for (_key, content) in &self.content {
let Some(schema) = &content.schema else { continue; };
let Some(schema) = schema.as_item() else { continue; };
if let Some(title) = &schema.schema_data.title {
if let Some(title) = &schema.title {
acc.entry(title.clone()).or_insert(schema);
}
schema.add_child_schemas(acc);
Expand All @@ -86,7 +85,7 @@ impl ChildSchemas for Response {
for (k, content) in &self.content {
let Some(schema) = &content.schema else { continue; };
let Some(schema) = schema.as_item() else { continue; };
if let Some(title) = &schema.schema_data.title {
if let Some(title) = &schema.title {
acc.entry(title.clone()).or_insert(schema);
}
schema.add_child_schemas(acc);
Expand All @@ -99,7 +98,7 @@ impl ChildSchemas for OpenAPI {
for (_path, _method, op, _item) in self.operations() {
op.add_child_schemas(acc);
}
for (name, schema) in self.schemas() {
for (name, schema) in &self.schemas {
let Some(schema) = schema.as_item() else { continue; };
acc.entry(name.clone()).or_insert(schema);
schema.add_child_schemas(acc);
Expand Down
Loading

0 comments on commit c8876a1

Please sign in to comment.