javaspring-mvcjson-ldhydra-core

JSON-LD document + Hydra Core generate Java code


IS there a tool which generates skeleton for a RESTful service for JSON-LD which have operation defined using hydra. For instance take below example, assume I have a Java class present Person, what would be a raw idea to build a tool which reverse engineer JSON-LD to generate a complete spring mvc code.

{
    "@context": [
        "http://www.w3.org/ns/hydra/core",
        {
            "@vocab": "https://schema.org/",
            "image": { "@type": "@id" },
            "friends": { "@type": "@id" }
        }
    ],
    "@id": "https://api.example.com/player/1234567890/friends",
    "operation": {
        "@type": "BefriendAction",
        "method": "POST",
        "expects": {
            "@id": "http://schema.org/Person",
            "supportedProperty": [
                { "property": "name", "range": "Text" },
                { "property": "alternateName", "range": "Text" },
                { "property": "image", "range": "URL" }
            ]
        }
    }
}

Solution

  • In fact there is a tool called hydra-java which helps to generate resource representations in the JSON-LD format with hydra-core additions. It also explicitly supports operations.

    As far as I understood, @user3929266 wants to generate classes from a JSON-LD + Hydra API documentation; not to generate JSON-LD from a Java class. If that's the case, I fear currently there exists no tool. But it should be rather straightforward to implement one and combine it with the features hydra-java offers.