Skip to content

Conversation

wuseal
Copy link
Owner

@wuseal wuseal commented Apr 19, 2025

Problem

When using newer JSON Schema formats that use `` instead of definitions, the plugin crashes with error: "Cannot resolve ref path: #//...".

kotlin.NotImplementedError: Cannot resolve ref path: #/$defs/CreditTransferTransaction39
	at wu.seal.jsontokotlin.model.jsonschema.JsonSchema.resolveDefinition(JsonSchema.kt:41)
	at wu.seal.jsontokotlin.utils.classgenerator.DataClassGeneratorByJSONSchema.getRealDefinition(DataClassGeneratorByJSONSchema.kt:212)
	at wu.seal.jsontokotlin.utils.classgenerator.DataClassGeneratorByJSONSchema.resolveProperty(DataClassGeneratorByJSONSchema.kt:59)
	at wu.seal.jsontokotlin.utils.classgenerator.DataClassGeneratorByJSONSchema.resolveProperty$default(DataClassGeneratorByJSONSchema.kt:53)
	at wu.seal.jsontokotlin.utils.classgenerator.DataClassGeneratorByJSONSchema.getProperties(DataClassGeneratorByJSONSchema.kt:34)
	at wu.seal.jsontokotlin.utils.classgenerator.DataClassGeneratorByJSONSchema.generateClass(DataClassGeneratorByJSONSchema.kt:21)
	at wu.seal.jsontokotlin.utils.classgenerator.DataClassGeneratorByJSONSchema.generate(DataClassGeneratorByJSONSchema.kt:16)
	at wu.seal.jsontokotlin.utils.KotlinClassMaker.makeKotlinClass(KotlinClassMaker.kt:18)
	at wu.seal.jsontokotlin.InsertKotlinClassAction.insertKotlinCode(InsertKotlinClassAction.kt:132)
	at wu.seal.jsontokotlin.InsertKotlinClassAction.actionPerformed(InsertKotlinClassAction.kt:76)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.doPerformActionOrShowPopup(ActionUtil.kt:345)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAwareWithCallbacks$lambda$4(ActionUtil.kt:316)

Solution

  • Added support for newer JSON Schema format using `` instead of definitions
  • Created helper method to combine both definitions and into a single map
  • Enhanced JSON Schema detection to recognize schemas with ``
  • Added comprehensive test cases for `` support
  • Fixed crash when resolving references to #// paths

This PR resolves the crash reported in the logs where the plugin was unable to parse JSON Schema using the newer `` format.

- Add support for newer JSON Schema format using  instead of definitions

- Create helper method to combine both definitions and  into a single map

- Enhance JSON Schema detection to recognize schemas with

- Add comprehensive test cases for  support

- Fix crash when resolving references to #// paths
@wuseal wuseal added the bug fix For PR means this PR is used to fix bugs label Apr 19, 2025
@wuseal wuseal changed the title Fix JSON Schema reference resolution Fix JSON Schema reference resolution: kotlin.NotImplementedError: Cannot resolve ref path: #/$defs/CreditTransferTransaction39 Apr 19, 2025
@wuseal wuseal merged commit 7c3a239 into master Apr 19, 2025
2 checks passed
@wuseal wuseal deleted the fix/json-schema-defs-support branch April 19, 2025 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix For PR means this PR is used to fix bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant