Skip to content
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

Unable to generate from schema due to "Path not present" #1588

Closed
perNyfelt opened this issue Feb 13, 2024 · 5 comments
Closed

Unable to generate from schema due to "Path not present" #1588

perNyfelt opened this issue Feb 13, 2024 · 5 comments

Comments

@perNyfelt
Copy link

Using the attached schema: falsstprv_schema.json the jsonSchema2Pojo fails with the following error "Path not present: fals"

the gradle build script calls the plugin as follows

plugins {
  id 'java'
  id "org.jsonschema2pojo" version "1.2.1"
}

jsonSchema2Pojo {
   source = files("${sourceSets.main.output.resourcesDir}/falsstprv_schema.json")
   targetDirectory = file("${project.buildDir}/generated/sources/js2p")
   targetPackage = 'sample'
}

I noticed that it is possible to process and generate Java pojos at https://json2csharp.com/code-converters/json-to-pojo so I suspect the problem is due to some bug in the jsonschema2pojo plugin.

@perNyfelt
Copy link
Author

Generating java classes from a sample json on https://www.jsonschema2pojo.org/ also works. I attach the sample here.
example_report_sample.json

@unkish
Copy link
Collaborator

unkish commented Feb 14, 2024

Hi

As a workaround you could try set refFragmentPathDelimiters to #/ (default being #/.)

jsonSchema2Pojo {
   source = files("${sourceSets.main.output.resourcesDir}/falsstprv_schema.json")
   targetDirectory = file("${project.buildDir}/generated/sources/js2p")
   targetPackage = 'sample'
   refFragmentPathDelimiters = '#/'
}

@perNyfelt
Copy link
Author

Thanks, i got further using refFragmentPathDelimiters. Generation completes but cannot compile due to lots of "duplicate class" errors e.g.

error: duplicate class: sample.Deposit
public class Deposit {

Is there a config i can do to address that?

@unkish
Copy link
Collaborator

unkish commented Feb 14, 2024

I'm not sure if it has anything to do with jsonSchema2Pojo plugin.
Please check if you have duplicate class definitions on compile classpath.
Alternatively provide a SSCCE that is reproduces given issue.

@perNyfelt
Copy link
Author

OK thank you! In the process of creating a SSCCE i found an issue on my side and the problem with duplicate classes was resolved. The working SSCCE can be found here: https://github.com/perNyfelt/jsonSchema-path-not-present.

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

2 participants