-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Recursive $ref failed #250
Comments
line 98 seems return false |
@princehaku Are you using the web ui at www.jsonschema2pojo.org or generating this locally? The web UI has a problem with local references (see #183). This is fixed in the current head version, we just need to update the web UI. |
thanks very much .. i'm using your online version run your sample code. generating this locally from the code below depends on jsonschema2pojo-core head version package com.test;
import java.io.File;
import java.io.IOException;
import com.sun.codemodel.CodeWriter;
import com.sun.codemodel.JCodeModel;
import org.jsonschema2pojo.*;
import org.jsonschema2pojo.rules.*;
class Test {
public static void main(String[] args) throws IOException {
String source = "{\n" +
" \"type\": \"object\",\n" +
" \"definitions\": \n" +
" {\n" +
" \"location\": \n" +
" {\n" +
" \"type\": \"object\",\n" +
" \"properties\": \n" +
" {\n" +
" \"lat\": \n" +
" {\n" +
" \"type\": \"number\"\n" +
" },\n" +
" \"cat\": \n" +
" {\n" +
" \"$ref\": \"#/definitions/cat\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"cat\" : \n" +
" {\n" +
" \"type\" : \"number\"\n" +
" }\n" +
" },\n" +
"\n" +
" \"properties\": \n" +
" {\n" +
" \"location\": \n" +
" {\n" +
" \"$ref\": \"#/definitions/location\"\n" +
" }\n" +
" }\n" +
"}";
RuleFactory mockRuleFactory = new RuleFactory();
DefaultGenerationConfig gcfg = new DefaultGenerationConfig();
JCodeModel codeModel = new JCodeModel();
new SchemaMapper(mockRuleFactory, new SchemaGenerator()).generate(codeModel, "ABC", "com.test", source);
File directory = new File("/home/admin/");
System.out.println("exporting to : " + directory.getAbsolutePath());
CodeWriter resourcesWriter = new FileCodeWriterWithEncoding(directory, gcfg.getOutputEncoding());
codeModel.build(resourcesWriter);
}
} Recurisly calling $ref |
I can see that this issue is kind of old but I'm running in the same problem. Is there a plan to fix it ? |
So it looks like the original example works correctly (the simple case) - that issue was fixed a long time ago. There is a more complicated example here: #250 (comment) and this does not work. This is not a problem with simple recursive refs but a problem with having an inner schema that is referred to by a fragment ref then using another fragment ref to refer outside the inner schema. This only seems to affect the case where there is no parent file (the schema is supplied as a string), and jsonschema2pojo.org is one such place. |
the sample
it doesn't work
got error There's a problem: URI is not absolute
The text was updated successfully, but these errors were encountered: