Uploaded image for project: 'RAML Module Builder'
  1. RAML Module Builder
  2. RMB-933

Fail to generate POJO by schema with self reference elements

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • P2
    • Resolution: Done
    • None
    • 35.0.0
    • None
    • ACQ Sprint 146
    • 1
    • Thunderjet
    • Nolana (R3 2022)
    • Third party component integration

    Description

      Overview:
      Steps to Reproduce:

      1. Generate interface based on schema with self reference elements
        ...
        "defaultMapping": {
        "$ref": "#",
        "description": "default value found from the mapping of another node"
        },
        "fromOtherField": {
        "$ref": "#properties/field",
        "description": "default value found from another field",
        "$comment": "in the config json, the order of dataSource is important as this field refers to previous dataSource objects."
        },
        ...
        

      Expected Results:
      All json schemas copied into target folder with unmodified self-reference elements. POJOs generated succesfully
      Actual Results:

      json schema content modified after copying it into target folder

      "defaultMapping" : {
      "type" : "#",
      "description" : "default value found from the mapping of another node"
      },
      "fromOtherField" : {
      "$ref" : "file:///home/grabse/IdeaProjects/raml-module-builder/domain-models-maven-plugin/target/GenerateRunnerTest/target/classes/ramls/%23properties/field",
      "description" : "default value found from another field",
      "$comment" : "in the config json, the order of dataSource is important as this field refers to previous dataSource objects."
      },
      
      java.lang.IllegalArgumentException: Unrecognised URI, can't resolve this: file:///home/grabse/IdeaProjects/raml-module-builder/domain-models-maven-plugin/target/GenerateRunnerTest/target/classes/ramls/%23properties/field
      
      	at org.jsonschema2pojo.ContentResolver.resolve(ContentResolver.java:83)
      	at org.jsonschema2pojo.SchemaStore.create(SchemaStore.java:58)
      	at org.jsonschema2pojo.SchemaStore.create(SchemaStore.java:128)
      	at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:59)
      	at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:30)
      	at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:75)
      	at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:43)
      	at org.jsonschema2pojo.rules.PropertiesRule.apply(PropertiesRule.java:70)
      	at org.jsonschema2pojo.rules.PropertiesRule.apply(PropertiesRule.java:38)
      	at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:119)
      	at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:70)
      	at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:90)
      	at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:40)
      	at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:73)
      	at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:30)
      	at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:75)
      	at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:43)
      	at org.jsonschema2pojo.rules.PropertiesRule.apply(PropertiesRule.java:70)
      	at org.jsonschema2pojo.rules.PropertiesRule.apply(PropertiesRule.java:38)
      	at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:119)
      	at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:70)
      	at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:90)
      	at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:40)
      	at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:73)
      	at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:66)
      	at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:30)
      	at org.jsonschema2pojo.SchemaMapper.generate(SchemaMapper.java:92)
      	at org.raml.jaxrs.generator.JsonSchemaTypeGenerator.output(JsonSchemaTypeGenerator.java:74)
      	at org.raml.jaxrs.generator.builders.AbstractTypeGenerator.output(AbstractTypeGenerator.java:27)
      	at org.raml.jaxrs.generator.CurrentBuild.generate(CurrentBuild.java:177)
      	at org.raml.jaxrs.generator.RamlScanner.handleRamlFile(RamlScanner.java:84)
      	at org.raml.jaxrs.generator.RamlScanner.handle(RamlScanner.java:62)
      	at org.raml.jaxrs.generator.RamlScanner.handle(RamlScanner.java:45)
      	at org.folio.rest.tools.GenerateRunner.generate(GenerateRunner.java:174)
      	at org.folio.rest.tools.GenerateRunner.main(GenerateRunner.java:126)
      	at org.folio.rest.tools.GenerateRunnerTest.canRunMain(GenerateRunnerTest.java:114)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
      	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
      	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
      	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
      	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
      	at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
      	at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
      	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
      	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
      	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
      Caused by: java.io.FileNotFoundException: /home/grabse/IdeaProjects/raml-module-builder/domain-models-maven-plugin/target/GenerateRunnerTest/target/classes/ramls/#properties/field (No such file or directory)
      	at java.base/java.io.FileInputStream.open0(Native Method)
      	at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
      	at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
      	at java.base/java.io.FileInputStream.<init>(FileInputStream.java:112)
      	at java.base/sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:86)
      	at java.base/sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:184)
      	at java.base/java.net.URL.openStream(URL.java:1165)
      	at com.fasterxml.jackson.core.TokenStreamFactory._optimizedStreamFromURL(TokenStreamFactory.java:211)
      	at com.fasterxml.jackson.core.JsonFactory.createParser(JsonFactory.java:1055)
      	at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:3125)
      	at org.jsonschema2pojo.ContentResolver.resolve(ContentResolver.java:77)
      	... 66 more
      

      Additional Information:
      URL:
      Interested parties:

      TestRail: Results

        Attachments

          Issue Links

            Activity

              People

                siarhei_hrabko Siarhei Hrabko
                siarhei_hrabko Siarhei Hrabko
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  TestRail: Runs

                    TestRail: Cases