在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:FasterXML/jackson-module-jsonSchema开源软件地址:https://github.com/FasterXML/jackson-module-jsonSchema开源编程语言:Java 100.0%开源软件介绍:JSON Schema ModuleJacksonThis module supports the creation of a JSON Schema (v3) Note that since JSON Schema draft version 3 and 4 are incompatible, this module CAN NOT, as-is, support v4. There is another module mbknor-jackson-jsonSchema that does support v4, however. It is possible that in future this repo could have 2 different modules; one for v3, another v4. And if necessary, more if future revisions also prove incompatible. StatusVersion 2.4 was considered the first stable version of the module. Future plans (lack thereof)Due to lack of support by community, this module is NOT planned to be supported beyond Jackson 2.x -- no work has been done for it to work with future Jackson 3.0. Users are encouraged to use more up-to-date JSON Schema support tools. Example Usage(from TestGenerateJsonSchema) simply add a dependency (this is from my gradle config)
ObjectMapper mapper = new ObjectMapper();
// configure mapper, if necessary, then create schema generator
JsonSchemaGenerator schemaGen = new JsonSchemaGenerator(mapper);
JsonSchema schema = schemaGen.generateSchema(SimpleBean.class); This will yield a java pojo representing a JSON Schema, which can itself easily be serialized with jackson, or configured with java. Customizing the generation should be simply a matter of locating the particular stage of generation you want to override, and replacing or extending that particular object in the dependency injection cycle in schemafactory wrapper. Adding Property ProcessingSee Required FieldsJSON Schema has the ability to mark fields as required. This module supports this via the JsonSchema Hypermedia supportGeneric supportCurrent implementation is partial for IETF published draft v4 (http://json-schema.org/latest/json-schema-hypermedia.html). Currently 2 aspects of IETF supported:
You can enable HypermediaSupport using HyperSchemaFactoryWrapper personVisitor = new HyperSchemaFactoryWrapper();
ObjectMapper mapper = new ObjectMapper();
mapper.acceptJsonFormatVisitor(Person.class, personVisitor);
JsonSchema personSchema = personVisitor.finalSchema(); By default all default values for Link Description Object are ignored in the output (method = GET, enctype = application/json, mediaType = application/json), to enable default setIgnoreDefaults(true) Describing JSON hyper-schemaYou can describe hyperlinks, using annotations @JsonHyperSchema & @Link
Would generate following values:
MoreCheck out Project Wiki for more information (javadocs, downloads). |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论