Pass through f64 field descriptions#974
Open
jayvdb wants to merge 1 commit intooxidecomputer:mainfrom
Open
Conversation
Collaborator
|
Thanks for this; do you have an example of how this manifests in generated output? |
Contributor
Author
|
Sure, the description appears in the Rust for floats, which already occurs for every other type. 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()
+ }
+} |
Collaborator
|
It's fine. Without your change, we get the same code but without the doc comment on the struct field? |
ahl
approved these changes
Feb 12, 2026
Contributor
Author
|
Yes, the only change is the description comes through. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.