Skip to content

HectorBst/jsonschema2pojo-interfaces

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Coverage Violations Maven Central License

jsonschema2pojo-interfaces

This project is a jsonschema2pojo extension dedicated to interface generation.

Features

Interfaces

This extension generate interfaces. It acts like a post-processing tool removing all field and method bodies.

E.g., this schema:

{
	"title": "Sample entity",
	"type": "object",
	"properties": {
		"field": {
			"title": "A field",
			"type": "string"
		}
	}
}

Will produce:

public interface Entity {

	String getField();

	void setField(String field);
}

Maven configuration

Here is an example of how the extension can be added to the jsonschema2pojo Maven plugin.

<plugin>
	<groupId>org.jsonschema2pojo</groupId>
	<artifactId>jsonschema2pojo-maven-plugin</artifactId>
	<version>${jsonschema2pojo-interfaces.version}</version>
	<executions>
		<execution>
			<goals>
				<goal>generate</goal>
			</goals>
			<configuration>
				...
				<!-- Extension RuleFactory -->
				<customRuleFactory>
					dev.hctbst.jsonschema2pojo.interfaces.InterfacesRuleFactory
				</customRuleFactory>
			</configuration>
		</execution>
	</executions>
	<dependencies>
		<!-- Extension dependency -->
		<dependency>
			<groupId>dev.hctbst</groupId>
			<artifactId>jsonschema2pojo-interfaces</artifactId>
			<version>${jsonschema2pojo-interfaces.version}</version>
		</dependency>
</plugin>

A more complete example is available here.

License

This project is released under version 2.0 of the Apache License.