Skip to content

Pass through f64 field descriptions#974

Open
jayvdb wants to merge 1 commit intooxidecomputer:mainfrom
jayvdb:f64-docs
Open

Pass through f64 field descriptions#974
jayvdb wants to merge 1 commit intooxidecomputer:mainfrom
jayvdb:f64-docs

Conversation

@jayvdb
Copy link
Contributor

@jayvdb jayvdb commented Feb 11, 2026

No description provided.

@ahl
Copy link
Collaborator

ahl commented Feb 11, 2026

Thanks for this; do you have an example of how this manifests in generated output?

@jayvdb
Copy link
Contributor Author

jayvdb commented Feb 11, 2026

Sure, the description appears in the Rust for floats, which already occurs for every other type.
I can add this if you like:

diff --git a/typify/tests/schemas/merged-schemas.json b/typify/tests/schemas/merged-schemas.json
index 16b42cd..61cbf38 100644
--- a/typify/tests/schemas/merged-schemas.json
+++ b/typify/tests/schemas/merged-schemas.json
@@ -411,6 +411,15 @@
         "x"
       ]
     },
+    "float-description": {
+      "type": "object",
+      "properties": {
+        "x": {
+          "description": "we need this",
+          "type": "number"
+        }
+      }
+    },
     "CommentedTypeMerged": {
       "description": "if we don't see this, we dropped the metadata",
       "type": "object",
diff --git a/typify/tests/schemas/merged-schemas.rs b/typify/tests/schemas/merged-schemas.rs
index e1b6826..461e142 100644
--- a/typify/tests/schemas/merged-schemas.rs
+++ b/typify/tests/schemas/merged-schemas.rs
@@ -134,6 +134,40 @@ impl CommentedTypeMerged {
         Default::default()
     }
 }
+#[doc = "`FloatDescription`"]
+#[doc = r""]
+#[doc = r" <details><summary>JSON schema</summary>"]
+#[doc = r""]
+#[doc = r" ```json"]
+#[doc = "{"]
+#[doc = "  \"type\": \"object\","]
+#[doc = "  \"properties\": {"]
+#[doc = "    \"x\": {"]
+#[doc = "      \"description\": \"we need this\","]
+#[doc = "      \"type\": \"number\""]
+#[doc = "    }"]
+#[doc = "  }"]
+#[doc = "}"]
+#[doc = r" ```"]
+#[doc = r" </details>"]
+#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)]
+pub struct FloatDescription {
+    #[doc = "we need this"]
+    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
+    pub x: ::std::option::Option<f64>,
+}
+impl ::std::default::Default for FloatDescription {
+    fn default() -> Self {
+        Self {
+            x: Default::default(),
+        }
+    }
+}
+impl FloatDescription {
+    pub fn builder() -> builder::FloatDescription {
+        Default::default()
+    }
+}

@ahl
Copy link
Collaborator

ahl commented Feb 12, 2026

It's fine. Without your change, we get the same code but without the doc comment on the struct field?

@jayvdb
Copy link
Contributor Author

jayvdb commented Feb 12, 2026

Yes, the only change is the description comes through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants