Repository: oxidecomputer/typify
Pull request #629 (2024-07-15 13:45:40)

Bump clap from 4.5.8 to 4.5.9
Bumps [clap](https://github.com/clap-rs/clap) from 4.5.8 to 4.5.9.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/clap-rs/clap/releases">clap's releases</a>.</em></p>
<blockquote>
<h2>v4.5.9</h2>
<h2>[4.5.9] - 2024-07-09</h2>
<h3>Fixes</h3>
<ul>
<li><em>(error)</em> When defining a custom help flag, be sure to suggest it like we do the built-in one</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/clap-rs/clap/blob/master/CHANGELOG.md">clap's changelog</a>.</em></p>
<blockquote>
<h2>[4.5.9] - 2024-07-09</h2>
<h3>Fixes</h3>
<ul>
<li><em>(error)</em> When defining a custom help flag, be sure to suggest it like we do the built-in one</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/clap-rs/clap/commit/3a2fb2594793776583068f105c274716ba646187"><code>3a2fb25</code></a> Merge pull request <a href="https://redirect.github.com/clap-rs/clap/issues/5547">#5547</a> from tesuji/fish-list</li>
<li><a href="https://github.com/clap-rs/clap/commit/1e3681bfbcc896d9978c62095be410a29c6bbe89"><code>1e3681b</code></a> refactor: Pass list to __fish_seen_subcommand_from</li>
<li><a href="https://github.com/clap-rs/clap/commit/b1a0508cf926f04c1b73fab0e8ea2117d5a7be70"><code>b1a0508</code></a> refactor: Rewrite iterator for followup changes</li>
<li><a href="https://github.com/clap-rs/clap/commit/5cc44bb91ee3a13aad65a41fdf687fe7f30b8bdc"><code>5cc44bb</code></a> Merge pull request <a href="https://redirect.github.com/clap-rs/clap/issues/5548">#5548</a> from tesuji/fish-escape-tab</li>
<li><a href="https://github.com/clap-rs/clap/commit/181b9e0d9434a5aa7d9e9ef3bd76b3ad1a05d06f"><code>181b9e0</code></a> test: Ensure optional_value runs</li>
<li><a href="https://github.com/clap-rs/clap/commit/0724b7ba2b1d6de42a2647d747491b911fd07655"><code>0724b7b</code></a> chore: Remove tarpaulin support</li>
<li><a href="https://github.com/clap-rs/clap/commit/80242546e23dd390176cc06ea9a0725d0be6d351"><code>8024254</code></a> chore: Update deps to fix nightly</li>
<li><a href="https://github.com/clap-rs/clap/commit/b16f987ad7076c8a375c78efaea8f0b9a5e57817"><code>b16f987</code></a> style: Escaping tab as \t for more readability for fish</li>
<li><a href="https://github.com/clap-rs/clap/commit/cf151fd46b444d1afbda5c279f769b36e9ccc3ec"><code>cf151fd</code></a> Merge pull request <a href="https://redirect.github.com/clap-rs/clap/issues/5542">#5542</a> from casey/exit-without-flushing</li>
<li><a href="https://github.com/clap-rs/clap/commit/5da658c5a06e369a5dc4c073f3f043cab05c403a"><code>5da658c</code></a> Merge pull request <a href="https://redirect.github.com/clap-rs/clap/issues/5541">#5541</a> from rustco/master</li>
<li>Additional commits viewable in <a href="https://github.com/clap-rs/clap/compare/clap_complete-v4.5.8...v4.5.9">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=clap&package-manager=cargo&previous-version=4.5.8&new-version=4.5.9)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/Cargo.lock b/Cargo.lock
index 0427573..1513045 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -222,9 +222,9 @@ dependencies = [
 
 [[package]]
 name = "clap"
-version = "4.5.8"
+version = "4.5.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d"
+checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462"
 dependencies = [
  "clap_builder",
  "clap_derive",
@@ -232,9 +232,9 @@ dependencies = [
 
 [[package]]
 name = "clap_builder"
-version = "4.5.8"
+version = "4.5.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708"
+checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942"
 dependencies = [
  "anstream",
  "anstyle",
@@ -1038,18 +1038,18 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76"
 
 [[package]]
 name = "thiserror"
-version = "1.0.61"
+version = "1.0.62"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709"
+checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb"
 dependencies = [
  "thiserror-impl",
 ]
 
 [[package]]
 name = "thiserror-impl"
-version = "1.0.61"
+version = "1.0.62"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533"
+checksum = "d20468752b09f49e909e55a5d338caa8bedf615594e9d80bc4c565d30faf798c"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -1267,9 +1267,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
 
 [[package]]
 name = "uuid"
-version = "1.9.1"
+version = "1.10.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439"
+checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314"
 dependencies = [
  "serde",
 ]
diff --git a/cargo-typify/Cargo.toml b/cargo-typify/Cargo.toml
index ddd072e..d821172 100644
--- a/cargo-typify/Cargo.toml
+++ b/cargo-typify/Cargo.toml
@@ -14,7 +14,7 @@ default-run = "cargo-typify"
 [dependencies]
 typify = { version = "0.1.0", path = "../typify" }
 
-clap = { version = "4.5.8", features = ["derive"] }
+clap = { version = "4.5.9", features = ["derive"] }
 color-eyre = "0.6"
 env_logger = "0.10"
 rustfmt-wrapper = "0.2.1"
diff --git a/typify-impl/Cargo.toml b/typify-impl/Cargo.toml
index ac6782c..b8f6a7d 100644
--- a/typify-impl/Cargo.toml
+++ b/typify-impl/Cargo.toml
@@ -18,7 +18,7 @@ semver = "1.0.23"
 serde = "1.0.204"
 serde_json = "1.0.120"
 syn = { version = "2.0.69", features = ["full"] }
-thiserror = "1.0.61"
+thiserror = "1.0.62"
 unicode-ident = "1.0.12"
 
 
@@ -30,4 +30,4 @@ rustfmt-wrapper = "0.2.1"
 schema = "0.1.0"
 schemars = { version = "0.8.21", features = ["uuid1", "impl_json_schema"] }
 syn = { version = "2.0.69", features = ["full", "extra-traits"] }
-uuid = "1.9.1"
+uuid = "1.10.0"
diff --git a/typify-impl/src/convert.rs b/typify-impl/src/convert.rs
index ac8a7a0..553cd96 100644
--- a/typify-impl/src/convert.rs
+++ b/typify-impl/src/convert.rs
@@ -79,8 +79,8 @@ impl TypeSpace {
                     let enum_values = enum_values.clone().map(|values| {
                         values
                             .iter()
+                            .filter(|&value| !value.is_null())
                             .cloned()
-                            .filter(|value| !value.is_null())
                             .collect()
                     });
                     let ss = Schema::Object(SchemaObject {
@@ -515,8 +515,29 @@ impl TypeSpace {
                     else_schema: None,
                 } => self.convert_not(type_name, original_schema, metadata, subschema),
 
-                // Unknown
-                _ => todo!("{:#?}", subschemas),
+                // Multiple subschemas may be present at the same time; attempt
+                // to merge and then convert.
+                subschemas => {
+                    // Remove the subschemas so we can merge into the rest.
+                    let schema_object = SchemaObject {
+                        subschemas: None,
+                        ..schema.clone()
+                    };
+                    let merged_schema = try_merge_with_subschemas(
+                        schema_object,
+                        Some(subschemas),
+                        &self.definitions,
+                    );
+                    match merged_schema {
+                        Ok(s) => {
+                            let (type_entry, _) =
+                                self.convert_schema_object(type_name, original_schema, &s)?;
+                            Ok((type_entry, &None))
+                        }
+                        // An error indicates that the schema is unresolvable.
+                        Err(_) => self.convert_never(type_name, original_schema),
+                    }
+                }
             },
 
             // Subschemas with other stuff.
diff --git a/typify-impl/src/util.rs b/typify-impl/src/util.rs
index 4b92d68..06efe0f 100644
--- a/typify-impl/src/util.rs
+++ b/typify-impl/src/util.rs
@@ -243,7 +243,8 @@ fn schemas_mutually_exclusive(a: &Schema, b: &Schema) -> bool {
                     {
                         object_schemas_mutually_exclusive(a_validation, b_validation)
                     } else {
-                        todo!()
+                        // Could check further, but we'll be conservative.
+                        false
                     }
                 }
 
@@ -286,7 +287,8 @@ fn schemas_mutually_exclusive(a: &Schema, b: &Schema) -> bool {
                     {
                         array_schemas_mutually_exclusive(a_validation, b_validation)
                     } else {
-                        todo!()
+                        // Could check further, but we'll be conservative.
+                        false
                     }
                 }
 
diff --git a/typify/Cargo.toml b/typify/Cargo.toml
index 3f57c7d..25ac81a 100644
--- a/typify/Cargo.toml
+++ b/typify/Cargo.toml
@@ -29,4 +29,4 @@ schemars = "0.8.21"
 serde = "1.0.204"
 serde_json = "1.0.120"
 trybuild = "1.0.97"
-uuid = { version = "1.9.1", features = ["serde"] }
+uuid = { version = "1.10.0", features = ["serde"] }


Test patch:
diff --git a/typify/tests/schemas/merged-schemas.json b/typify/tests/schemas/merged-schemas.json
index bbdb512..a98e937 100644
--- a/typify/tests/schemas/merged-schemas.json
+++ b/typify/tests/schemas/merged-schemas.json
@@ -417,6 +417,36 @@
           }
         }
       ]
+    },
+    "HereAndThere": {
+      "allOf": [
+        {
+          "type": "object",
+          "properties": {
+            "foo": {
+              "type": "string"
+            }
+          }
+        }
+      ],
+      "oneOf": [
+        {
+          "type": "object",
+          "properties": {
+            "bar": {
+              "type": "string"
+            }
+          }
+        },
+        {
+          "type": "object",
+          "properties": {
+            "baz": {
+              "type": "string"
+            }
+          }
+        }
+      ]
     }
   }
-}
\ No newline at end of file
+}
diff --git a/typify/tests/schemas/merged-schemas.rs b/typify/tests/schemas/merged-schemas.rs
index ea090cf..aae6261 100644
--- a/typify/tests/schemas/merged-schemas.rs
+++ b/typify/tests/schemas/merged-schemas.rs
@@ -113,6 +113,64 @@ impl From<&CommentedTypeMerged> for CommentedTypeMerged {
         value.clone()
     }
 }
+#[doc = "HereAndThere"]
+#[doc = r""]
+#[doc = r" <details><summary>JSON schema</summary>"]
+#[doc = r""]
+#[doc = r" ```json"]
+#[doc = "{"]
+#[doc = "  \"allOf\": ["]
+#[doc = "    {"]
+#[doc = "      \"type\": \"object\","]
+#[doc = "      \"properties\": {"]
+#[doc = "        \"foo\": {"]
+#[doc = "          \"type\": \"string\""]
+#[doc = "        }"]
+#[doc = "      }"]
+#[doc = "    }"]
+#[doc = "  ],"]
+#[doc = "  \"oneOf\": ["]
+#[doc = "    {"]
+#[doc = "      \"type\": \"object\","]
+#[doc = "      \"properties\": {"]
+#[doc = "        \"bar\": {"]
+#[doc = "          \"type\": \"string\""]
+#[doc = "        }"]
+#[doc = "      }"]
+#[doc = "    },"]
+#[doc = "    {"]
+#[doc = "      \"type\": \"object\","]
+#[doc = "      \"properties\": {"]
+#[doc = "        \"baz\": {"]
+#[doc = "          \"type\": \"string\""]
+#[doc = "        }"]
+#[doc = "      }"]
+#[doc = "    }"]
+#[doc = "  ]"]
+#[doc = "}"]
+#[doc = r" ```"]
+#[doc = r" </details>"]
+#[derive(Clone, Debug, Deserialize, Serialize)]
+#[serde(untagged)]
+pub enum HereAndThere {
+    Variant0 {
+        #[serde(default, skip_serializing_if = "Option::is_none")]
+        bar: Option<String>,
+        #[serde(default, skip_serializing_if = "Option::is_none")]
+        foo: Option<String>,
+    },
+    Variant1 {
+        #[serde(default, skip_serializing_if = "Option::is_none")]
+        baz: Option<String>,
+        #[serde(default, skip_serializing_if = "Option::is_none")]
+        foo: Option<String>,
+    },
+}
+impl From<&HereAndThere> for HereAndThere {
+    fn from(value: &HereAndThere) -> Self {
+        value.clone()
+    }
+}
 #[doc = "JsonResponseBase"]
 #[doc = r""]
 #[doc = r" <details><summary>JSON schema</summary>"]