Skip to content

Commit 73d8e1b

Browse files
danadajianclaude
andauthored
fix: preserve descriptions that don't start with an ASCII letter (#177)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 46b2c2e commit 73d8e1b

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

src/annotations/build-annotations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,6 @@ export function trimDescription(description?: string) {
8686
description
8787
?.split("\n")
8888
.map((str) => str.trim().replaceAll('"', "").replaceAll("\\", ""))
89-
.find((str) => str.match(/^[a-zA-Z]/)) ?? ""
89+
.find((str) => str.length > 0) ?? ""
9090
);
9191
}

test/unit/should_annotate_types_properly/expected.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@ data class TypeThatShouldBeProperlyAnnotated(
2626
@Deprecated("It uses the @Deprecated annotation for the reason")
2727
val deprecated7: UnionThatShouldBeProperlyAnnotated? = null,
2828
@Deprecated("Multiline reason")
29-
val deprecated8: String? = null
29+
val deprecated8: String? = null,
30+
@param:GraphQLDescription("(parenthesis) description.")
31+
val nonLetterDescription1: String? = null,
32+
@param:GraphQLDescription("`backtick` description.")
33+
val nonLetterDescription2: String? = null,
34+
@param:GraphQLDescription("42 numeric description.")
35+
val nonLetterDescription3: String? = null,
36+
@param:GraphQLDescription("(Deprecated) Use something else.")
37+
@Deprecated("(internal) replaced in v3")
38+
val nonLetterDeprecated: String? = null
3039
) : UnionThatShouldBeProperlyAnnotated
3140

3241
interface UnionThatShouldBeProperlyAnnotated

test/unit/should_annotate_types_properly/schema.graphql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@ type TypeThatShouldBeProperlyAnnotated {
3131
@deprecated(
3232
reason: "\n Multiline reason\n with spaces\n "
3333
)
34+
"""
35+
(parenthesis) description.
36+
"""
37+
nonLetterDescription1: String
38+
"""
39+
`backtick` description.
40+
"""
41+
nonLetterDescription2: String
42+
"""
43+
42 numeric description.
44+
"""
45+
nonLetterDescription3: String
46+
"""
47+
(Deprecated) Use something else.
48+
"""
49+
nonLetterDeprecated: String @deprecated(reason: "(internal) replaced in v3")
3450
}
3551

3652
union UnionThatShouldBeProperlyAnnotated = TypeThatShouldBeProperlyAnnotated

0 commit comments

Comments
 (0)