Helper for JSON Schema 2 Pojo

Custom annotators to be used along with jsonschema2pojo plugin on Maven. With this custom annotator, you can add lombok and JPA support to generated codes.

License

License

Categories

Categories

GNU Compiler for Java Build Tools
GroupId

GroupId

io.github.paulushcgcj
ArtifactId

ArtifactId

helper-js2pojo
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

Helper for JSON Schema 2 Pojo
Custom annotators to be used along with jsonschema2pojo plugin on Maven. With this custom annotator, you can add lombok and JPA support to generated codes.
Project URL

Project URL

https://paulushcgcj.github.io/
Project Organization

Project Organization

Paulo Gomes da Cruz Junior
Source Code Management

Source Code Management

https://github.com/paulushcgcj/helperjs2pojo.git

Download helper-js2pojo

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.paulushcgcj/helper-js2pojo/ -->
<dependency>
    <groupId>io.github.paulushcgcj</groupId>
    <artifactId>helper-js2pojo</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.paulushcgcj/helper-js2pojo/
implementation 'io.github.paulushcgcj:helper-js2pojo:1.0.1'
// https://jarcasting.com/artifacts/io.github.paulushcgcj/helper-js2pojo/
implementation ("io.github.paulushcgcj:helper-js2pojo:1.0.1")
'io.github.paulushcgcj:helper-js2pojo:jar:1.0.1'
<dependency org="io.github.paulushcgcj" name="helper-js2pojo" rev="1.0.1">
  <artifact name="helper-js2pojo" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.paulushcgcj', module='helper-js2pojo', version='1.0.1')
)
libraryDependencies += "io.github.paulushcgcj" % "helper-js2pojo" % "1.0.1"
[io.github.paulushcgcj/helper-js2pojo "1.0.1"]

Dependencies

compile (3)

Group / Artifact Type Version
org.jsonschema2pojo : jsonschema2pojo-core jar 0.5.1
org.hibernate : hibernate-core jar 5.3.5.Final
org.projectlombok : lombok jar 1.18.2

Project Modules

There are no modules declared in this project.

HelperJS 2 Pojo

pipeline status coverage report Sonar Coverage Quality Gate Status

Maven Central Bintray GitHub release

This package is intended to be used as custom Annotator to JsonSchema2Pojo.

With this custom annotator, you can add lombok and JPA support to generated codes.

For released versions go directly to maven central

How to use it

In your pom.xml file, add the following inside your build plugins entry, replacing where needed:

<plugin>
    <groupId>org.jsonschema2pojo</groupId>
    <artifactId>jsonschema2pojo-maven-plugin</artifactId>
    <version>0.5.1</version>
    <dependencies>
        <dependency>
            <groupId>io.github.paulushcgcj</groupId>
            <artifactId>helper-js2pojo</artifactId>
            <version>X.Y.Z</version>
        </dependency>
    </dependencies>
    <configuration>
        <removeOldOutput>true</removeOldOutput>
        <useCommonsLang3>true</useCommonsLang3>
        <includeConstructors>false</includeConstructors>
        <includeAccessors>false</includeAccessors>
        <includeAdditionalProperties>false</includeAdditionalProperties>
        <includeJsr303Annotations>true</includeJsr303Annotations>
        <sourceDirectory>${basedir}/src/main/resources/your_folder_here</sourceDirectory>
        <targetPackage>your.package.folder.structure.here</targetPackage>
        <outputDirectory>${basedir}/target/generated-sources/your_folder_here</outputDirectory>
        <propertyWordDelimiters>-</propertyWordDelimiters>
        <customAnnotator>full.path.to.annotator</customAnnotator>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Annotators

You can choose the annotator that best suits your needs. Below you will find all annotators found on this package:

Lombok

The io.github.paulushcgcj.js2pojo.LombokAnnotator annotator will add Lombok dependencies to your generated file, removing that bunch of boilerplate code, replacing it with Lombok annotations. With this you will end up with a much more cleaner code.

JPA

If you need to add some of the JPA annotations, like @Entity and @Id, all you have to do is add the custom annotator io.github.paulushcgcj.js2pojo.HibernateAnnotator. Also you will need to add to your schema an entry marking it with entity as true.

Ex:

{
  "$id": "https://example.com/person.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Person",
  "type": "object",
  "properties": {
    "entity": true,
    "firstName": {
      "type": "string",
      "description": "The person's first name."
    },
    "lastName": {
      "type": "string",
      "description": "The person's last name."
    },
    "age": {
      "description": "Age in years which must be equal to or greater than zero.",
      "type": "integer",
      "minimum": 0
    }
  }
}

Lobok + JPA

If you want just a single annotator that gives you both worlds, you can use the io.github.paulushcgcj.js2pojo.HibernateLombokAnnotator and have both things in the same annotator.

Versions

Version
1.0.1