Skip to content

net.pwall.json.pointer.JSONPointerException: Recursive $ref - /definitions/Extension for FHIR v4.0.1 schema #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tower-guidev2 opened this issue Feb 14, 2023 · 3 comments

Comments

@tower-guidev2
Copy link

I wish to generate kotlin data classe for the FHIR v4.0.1 draft v7 json schema (download) and executing

    val codeGenerator = CodeGenerator()
    codeGenerator.baseDirectoryName = "/Users/xxxxxx/IdeaProjects/Generation/src/output"
    codeGenerator.basePackageName = "com.example"
    codeGenerator.generate(File("/Users/xxxxxx/IdeaProjects/Generation/src/resource/fhir.schema.json")) 

gives


SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" net.pwall.json.pointer.JSONPointerException: Recursive $ref - /definitions/Extension
	at net.pwall.json.schema.parser.Parser.parseSchema(Parser.kt:175)
	at net.pwall.json.schema.parser.Parser.parseRef(Parser.kt:327)
	at net.pwall.json.schema.parser.Parser.parseSchema(Parser.kt:202)
	at net.pwall.json.schema.parser.Parser.parseItems(Parser.kt:336)
	at net.pwall.json.schema.parser.Parser.parseSchema(Parser.kt:223)
	at net.pwall.json.schema.parser.Parser.parseProperties(Parser.kt:342)
	at net.pwall.json.schema.parser.Parser.parseSchema(Parser.kt:215)
	at net.pwall.json.schema.parser.Parser.parseRef(Parser.kt:327)
	at net.pwall.json.schema.parser.Parser.parseSchema(Parser.kt:202)
	at net.pwall.json.schema.parser.Parser.parseItems(Parser.kt:336)
	at net.pwall.json.schema.parser.Parser.parseSchema(Parser.kt:223)
	at net.pwall.json.schema.parser.Parser.parseProperties(Parser.kt:342)
	at net.pwall.json.schema.parser.Parser.parseSchema(Parser.kt:215)
	at net.pwall.json.schema.parser.Parser.parseRef(Parser.kt:327)
	at net.pwall.json.schema.parser.Parser.parseSchema(Parser.kt:202)
	at net.pwall.json.schema.parser.Parser.parseProperties(Parser.kt:342)
	at net.pwall.json.schema.parser.Parser.parseSchema(Parser.kt:215)
	at net.pwall.json.schema.parser.Parser.parseRef(Parser.kt:327)
	at net.pwall.json.schema.parser.Parser.parseSchema(Parser.kt:202)
	at net.pwall.json.schema.parser.Parser.parseCombinationSchema(Parser.kt:309)
	at net.pwall.json.schema.parser.Parser.parseSchema(Parser.kt:208)
	at net.pwall.json.schema.parser.Parser.parse(Parser.kt:149)
	at net.pwall.json.schema.parser.Parser.parse(Parser.kt:120)
	at net.pwall.json.schema.codegen.CodeGenerator.addTarget(CodeGenerator.kt:478)
	at net.pwall.json.schema.codegen.CodeGenerator.addTargets(CodeGenerator.kt:370)
	at net.pwall.json.schema.codegen.CodeGenerator.addTargets$default(CodeGenerator.kt:364)
	at net.pwall.json.schema.codegen.CodeGenerator.generate(CodeGenerator.kt:354)
	at net.pwall.json.schema.codegen.CodeGenerator.generate(CodeGenerator.kt:344)
	at Generate_FHIR_schemaKt.main(Generate_FHIR_schema.kt:11)

@pwall567
Copy link
Owner

I think the message is self-explanatory - $ref doesn't allow recursion. Draft 2019-09 of JSON Schema introduced $recursiveRef, and draft 2020-12 introduced $dynamicRef, but json-kotlin-schema-codegen does not support either of these constructs. Sorry about that.

I have been working on a new version which supports the full draft 2020-12 spec., but I'm afraid that's still some months away from being ready.

Sorry I can't be more help.

@tower-guidev2
Copy link
Author

thanks for responding to my issue. and nice work on your library
i have managed to make some progress with a hacky approach

@milux
Copy link

milux commented Aug 14, 2024

@tower-guidev2 If that still has any relevance for you, you may try out my PR: #43
Feedback welcome!

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

No branches or pull requests

3 participants