Skip to content

About

JSON API server implementation in Java using JAX-RS, Bean Validation, and Java Persistence (JPA)

Resources

Stars

5 stars

Watchers

1 watching

Forks

Latest commit

 

History

588 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON:API - REST, Validation, Persistence (jsonapi-rvp)

Build Status Quality Gate Status Maven Central javadoc

Implementation of a JSON:API server in Java using JAX-RS, Bean Validation, and Java Persistence (JPA). This library is under active development and APIs may not be stable. Please open issues for feature requests or bug reports.

Roadmap

  • Simplify configuration, minimize custom interfaces/classes in client application code
  • API end point generates JavaScript client module and entities
  • Align client interface with JPA EntityManager

Maven Coordinates

Replace VERSION with the latest from Maven Central: Maven Central

<dependency>
  <groupId>io.xlate</groupId>
  <artifactId>jsonapi-rvp</artifactId>
  <version>VERSION</version>
</dependency>

Example

@Path("/blogapi")
@Transactional // when using JTA transactions
public class BlogResources extends JsonApiResource {

    @PostConstruct
    void configure() {
        Set<JsonApiResourceType<?>> resourceTypes = new HashSet<>();

        resourceTypes.add(JsonApiResourceType.define("posts", Post.class)
                                             .build());
        resourceTypes.add(JsonApiResourceType.define("comments", Comment.class)
                                             .build());

        super.initialize(resourceTypes);
    }

}

@Entity
@Table(name = "POSTS")
public class Post {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;

    @Column
    private String title;

    @Column
    private String text;

    @OneToMany(mappedBy = "post")
    private List<Comment> comments;

    // ... Getters and Setters
}

@Entity
@Table(name = "COMMENTS")
public class Comment {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;

    @Column
    private