Skip to content
This repository has been archived by the owner on Mar 30, 2020. It is now read-only.

Commit

Permalink
release 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CarstenWickner committed Jun 10, 2019
1 parent 111c4c9 commit f872952
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 4 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [3.0.0] – 2019-06-10
### Added
- Populate "description" as per `@JsonPropertyDescription` (falling-back on `@JsonClassDescription`).
- Apply alternative field names defined in `@JsonProperty` annotations.
- Ignore fields that are deemed to be ignored according to various `jackson-annotations` (e.g. `@JsonIgnore`, `@JsonIgnoreType`, `@JsonIgnoreProperties`) or are otherwise supposed to be excluded.

[Unreleased]: https://github.com/victools/jsonschema-generator/compare/v3.0.0...HEAD
[3.0.0]: https://github.com/victools/jsonschema-generator/releases/tag/v3.0.0
57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,55 @@
# jsonschema-module-jackson
Module for the jsonschema-generator – deriving JSON Schema attributes from jackson annotations
# Java JSON Schema Generation – Module jackson
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.victools/jsonschema-module-jackson/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.victools/jsonschema-module-jackson)

Module for the `jsonschema-generator` – deriving JSON Schema attributes from `jackson` annotations.

## Features
1. Populate "description" as per `@JsonPropertyDescription` (falling-back on `@JsonClassDescription`).
2. Apply alternative field names defined in `@JsonProperty` annotations.
3. Ignore fields that are deemed to be ignored according to various `jackson-annotations` (e.g. `@JsonIgnore`, `@JsonIgnoreType`, `@JsonIgnoreProperties`) or are otherwise supposed to be excluded.

Schema attributes derived from validation annotations on getter methods are also applied to their associated fields.

## Usage
### Dependency (Maven)
```xml
<dependency>
<groupId>com.github.victools</groupId>
<artifactId>jsonschema-module-jackson</artifactId>
<version>3.0.0</version>
</dependency>
```

### Code
#### Passing into SchemaGeneratorConfigBuilder.with(Module)
```java
import com.github.victools.jsonschema.generator.SchemaGeneratorConfigBuilder;
import com.github.victools.jsonschema.module.jackson.JacksonModule;
```
```java
JacksonModule module = new JacksonModule();
SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(objectMapper)
.with(module);
```

#### Complete Example
```java
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.victools.jsonschema.generator.OptionPreset;
import com.github.victools.jsonschema.generator.SchemaGenerator;
import com.github.victools.jsonschema.generator.SchemaGeneratorConfig;
import com.github.victools.jsonschema.generator.SchemaGeneratorConfigBuilder;
import com.github.victools.jsonschema.module.jackson.JacksonModule;
```
```java
ObjectMapper objectMapper = new ObjectMapper();
JacksonModule module = new JacksonModule();
SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(objectMapper, OptionPreset.PLAIN_JSON)
.with(module);
SchemaGeneratorConfig config = configBuilder.build();
SchemaGenerator generator = new SchemaGenerator(config);
JsonNode jsonSchema = generator.generateSchema(YourClass.class);

System.out.println(jsonSchema.toString());
```
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<groupId>com.github.victools</groupId>
<artifactId>jsonschema-module-jackson</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0</version>
<packaging>jar</packaging>

<licenses>
Expand All @@ -27,7 +27,7 @@
<connection>scm:git:ssh://github.com/victools/jsonschema-module-jackson.git</connection>
<developerConnection>scm:git:ssh://git@github.com/victools/jsonschema-module-jackson.git</developerConnection>
<url>https://github.com/victools/jsonschema-module-jackson</url>
<tag>HEAD</tag>
<tag>v3.0.0</tag>
</scm>

<organization>
Expand Down

0 comments on commit f872952

Please sign in to comment.