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

Bump thiserror from 1.0.61 to 1.0.62
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.61 to 1.0.62.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/dtolnay/thiserror/releases">thiserror's releases</a>.</em></p>
<blockquote>
<h2>1.0.62</h2>
<ul>
<li>Support referring to nested tuple struct fields inside <code>#[error(&quot;…&quot;, …)]</code> attribute (<a href="https://redirect.github.com/dtolnay/thiserror/issues/309">#309</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/dtolnay/thiserror/commit/0bf6e3dd781409b62cbcf0816ffa1bb970d24833"><code>0bf6e3d</code></a> Release 1.0.62</li>
<li><a href="https://github.com/dtolnay/thiserror/commit/497793283934d9e514d903a14278af6babbfbb65"><code>4977932</code></a> Merge pull request <a href="https://redirect.github.com/dtolnay/thiserror/issues/310">#310</a> from dtolnay/nestedtuple</li>
<li><a href="https://github.com/dtolnay/thiserror/commit/40a7779b1793f2dce5f85abe8c03486cdb5eb640"><code>40a7779</code></a> Support .0.0 nested tuple index</li>
<li><a href="https://github.com/dtolnay/thiserror/commit/f1ca210cc4772f198af91886e3849dac68114f97"><code>f1ca210</code></a> Add regression test for issue 309</li>
<li><a href="https://github.com/dtolnay/thiserror/commit/479744ec288f9183b8849f013dcee226ac6588ee"><code>479744e</code></a> No need for dead code if struct fields are public</li>
<li><a href="https://github.com/dtolnay/thiserror/commit/4db08b10a39cfd189a36a88dee0fad578ac11cbe"><code>4db08b1</code></a> Ignore warning on unused struct in test</li>
<li><a href="https://github.com/dtolnay/thiserror/commit/f2824ae379ac2edee1fd687b9e56f18c048086cd"><code>f2824ae</code></a> Fill in ignore reasons in all #[ignore] attributes</li>
<li>See full diff in <a href="https://github.com/dtolnay/thiserror/compare/1.0.61...1.0.62">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=thiserror&package-manager=cargo&previous-version=1.0.61&new-version=1.0.62)](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..9b809a8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -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/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>"]