내가 JSON 스키마에 자바 인터페이스를 변환하기 위해 노력하고 있지만 오류
public interface Contributors {
public List<Contributor> contributors();
public interface Contributor {
public String name();
public String contributorUrl();
public List<String> roles();
}
}
편집 2 NullPointerException이
을주고있다 : 를 나는 다음과 같은 출력을 얻고있다 :{"type":"object","$schema":"http://json-schema.org/draft-04/schema#"}
을
편집 3 :
다음은 SchemaGeneratorTest 코드입니다.
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.github.reinert.jjschema.exception.TypeException;
import com.github.reinert.jjschema.v1.JsonSchemaFactory;
import com.github.reinert.jjschema.v1.JsonSchemaV4Factory;
public class SchemaGeneratorTest {
private static ObjectMapper mapper = new ObjectMapper();
public static final String JSON_$SCHEMA_DRAFT4_VALUE = "http://json-schema.org/draft-04/schema#";
public static final String JSON_$SCHEMA_ELEMENT = "$schema";
static {
// required for pretty printing
mapper.enable(SerializationFeature.INDENT_OUTPUT);
}
public static void main(String[] args) throws JsonProcessingException, TypeException {
JsonSchemaFactory schemaFactory = new JsonSchemaV4Factory();
schemaFactory.setAutoPutDollarSchema(true);
JsonNode productSchema = schemaFactory.createSchema(Contributors.class);
System.out.println(productSchema);
}
}
SchemaGeneratorTest를 작성 했습니까? 그렇다면 해당 코드를 게시하십시오. – Nulano
디버깅을 시도 했습니까? NullPointerException은 찾기 쉽습니다. –
@ Nulano 업데이트. –