2014-04-21 11 views
2

내 데이터 모델의 스키마 생성을 자동화하기 위해 Jackson jsonSchema (https://github.com/FasterXML/jackson-module-jsonSchema)를 사용하고 있습니다.Jackson HyperSchema를 사용하여 스키마 링크 참조를 생성하는 방법

http://json-schema.org/과 jsonSchema에서 제공하는 샘플에 따르면, JSON 쉐마에서 사용하는 형식 링크

{ 
    "name":"Product", 
    "properties":{ 
    "id":{ 
     "type":"number", 
     "description":"Product identifier", 
     "required":true 
    }, 
    "name":{ 
     "description":"Name of the product", 
     "type":"string", 
     "required":true 
    }, 
    "price":{ 
     "required":true, 
     "type": "number", 
     "minimum":0, 
     "required":true 
    }, 
    "tags":{ 
     "type":"array", 
     "items":{ 
     "type":"string" 
     } 
    } 
    }, 
    "links":[ 
    { 
     "rel":"full", 
     "href":"{id}" 
    }, 
    { 
     "rel":"comments", 
     "href":"comments/?id={id}" 
    } 
    ] 
} 

을 포함하지만이 있지만 나는, 생성 된 스키마에 추가 할 수있는 방법을 찾을 수 없습니다 HyperSchema 개체, 필요한 것 같지만 사용 방법을 찾을 수 없습니다.

답변

1

https://github.com/FasterXML/jackson-module-jsonSchema/issues/35

public class Pet { 
    public String genus; 
} 

@JsonHyperSchema(pathStart = "/persons/", links = { 
    @Link(href = "{name}", rel = "self"), 
    @Link(href = "{name}/pet", rel = "pet", targetSchema = Pet.class) 
}) 
public class Person { 
    public String name; 
    public String hat; 
} 

변경이 https://github.com/clemble/jackson-module-jsonSchema

에있는 형태로, 주석을 기반으로 JSON 스키마 프로젝트의 문제, 그리고 HyperSchema을 지원하는 풀 요청을 만들어