1

I'm working in a small SDR POC project in which we decided to use the JSON-Schema because it is more meaningful for our purposes since we are trying to develop a client that understand hypermedia and create part of our view dynamically, but I'm in trouble to find all the hypermedia metadata for my entities using the JSON-schema.

These are the entities that I'm using

@Entity
public class Book {
    (...)
 
    @OneToMany(mappedBy="book")
    @JsonManagedReference
    private Set<Page> pages;
}


@Entity
public class Page {
 
    (...)
 
    @ManyToOne
    @JsonBackReference
    private Book book;
 
}

When I perform a GET on the /profile/Books using the accept header value as "application/schema+json":

    curl -H 'Accept:application/schema+json' http://localhost:8080/profile/books

I receive this output:

{
   "title": "Book",
   "properties":    {
      "pages":       {
         "title": "Pages",
         "readOnly": false,
         "type": "string",
         "format": "uri"
      },
      "name":       {
         "title": "Name",
         "readOnly": false,
         "type": "string"
      }
   },
   "definitions": {},
   "type": "object",
   "$schema": "http://json-schema.org/draft-04/schema#"
}

This JSON-schema output doesn't have the links for all the CRUD operations for the Book entity, nor the links to the related entities like Pages or metadata to define its properties.

The default ALPS output (https://datatracker.ietf.org/doc/html/draft-amundsen-richardson-foster-alps-01) provided by /profile isn't meaningful enough because it does not shows all possible action links for the entity , nor the specific types.

The HAL output (https://datatracker.ietf.org/doc/html/draft-kelly-json-hal-07) for the /books describe the links for all book instances and their interaction links with other entities but nothing about metadata.

What is the correct way to output the JSON-schema metadata for an entity in SDR? Is there any way in which I could be able to produce a JSON Hyper-Schema (https://datatracker.ietf.org/doc/html/draft-luff-json-hyper-schema-00) from a SDR resource ?

Community
  • 1
  • 1
  • "$schema": "http://json-schema.org/draft-04/schema#" is pointing to json meta schema, but it is missing the link to hyper schema for sure. – lnrdo Jan 27 '16 at 13:15
  • "pages": { "title": "Pages", "readOnly": false, "type": "string", "format": "uri" }, is also misleading, because it is a Set inside the entity and is described as a String. It should be a complex object, possibly with a schema property or URI. – lnrdo Jan 27 '16 at 13:16
  • 1
    Books have pages --not use pages. So it is a composition and not an aggregation. This should be taken into consideration when mapping related resources, i.e. page 1 is part of book A and not an independent resource. This is completely different from a relationship between book and author. – lnrdo Jan 27 '16 at 13:20

0 Answers0