Skip to content

Commit 83b26d4

Browse files
committed
Fix camel case types
1 parent 016ad23 commit 83b26d4

File tree

1 file changed

+10
-2
lines changed
  • src/asyncapi_python/contrib/codec

1 file changed

+10
-2
lines changed

src/asyncapi_python/contrib/codec/json.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,19 @@ def _to_class_name(self, message_name: str) -> str:
102102
# "user_created" -> "UserCreated"
103103
# "user.created" -> "UserCreated"
104104
# "user-created" -> "UserCreated"
105+
# "marketTick" -> "MarketTick"
105106

106107
# If it's already in PascalCase (starts with uppercase and has no separators)
107108
if message_name[0].isupper() and not any(c in message_name for c in "._-"):
108109
return message_name
109110

110-
# Convert to PascalCase
111-
parts = message_name.replace("-", "_").replace(".", "_").split("_")
111+
# Handle camelCase by splitting on uppercase letters (e.g., "marketTick" -> "Market" + "Tick")
112+
if not any(c in message_name for c in "._-"):
113+
# Split camelCase on uppercase letters
114+
import re
115+
parts = re.findall(r'[A-Z][a-z]*|[a-z]+', message_name)
116+
else:
117+
# Split on separators for snake_case, kebab-case, dot.case
118+
parts = message_name.replace("-", "_").replace(".", "_").split("_")
119+
112120
return "".join(part.capitalize() for part in parts if part)

0 commit comments

Comments
 (0)