Skip to content

[Bugfix] Adjust $ref handling logic in DefaultJsonSchemaFactory#613

Open
mSobhy90 wants to merge 1 commit into
restatedev:mainfrom
mSobhy90:mo/fix/kotlinx-json-schema-ref-handling
Open

[Bugfix] Adjust $ref handling logic in DefaultJsonSchemaFactory#613
mSobhy90 wants to merge 1 commit into
restatedev:mainfrom
mSobhy90:mo/fix/kotlinx-json-schema-ref-handling

Conversation

@mSobhy90
Copy link
Copy Markdown

To avoid replacing nested type name if it shares the prefix of the root class name.

When you have a type that shares the name of it's parent type (eg: Task & TaskType), with the way the current fixRefsPrefix works (recurses through all subtypes to handle nested types) you end up replacing the def path of the subtype and it becomes unserialisable and crashes at runtime, and you have to use custom serialisers or rename your class. This checks that the root definition is followed by a / (to indicate nesting) before replacing it).

image

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 31, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

…o avoid replacing nested type name if it shares the prefix of the root class name

When you have a type that shares the name of it's parent type (eg: Task & TaskType), with the way the current `fixRefsPrefix` works (recurses through all subtypes to handle nested types) you end up replacing the def path of the subtype and it becomes unserialisable and crashes at runtime, and you have to use custom serialisers or rename your class. This checks that the root definition is followed by a / (to indicate nesting) before replacing it).
@mSobhy90 mSobhy90 force-pushed the mo/fix/kotlinx-json-schema-ref-handling branch from 72898fc to f74f6f7 Compare May 31, 2026 22:25
@mSobhy90
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

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.

1 participant