Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing apidoc as RDF graph #144

Closed
cr3a7ure opened this issue Sep 30, 2016 · 3 comments
Closed

Parsing apidoc as RDF graph #144

cr3a7ure opened this issue Sep 30, 2016 · 3 comments
Labels

Comments

@cr3a7ure
Copy link

Continued from this issue #142 .
As jsonld spec states (https://www.w3.org/TR/json-ld/#identifying-blank-nodes), if there is no '@id' key, then we might end up in a BlankNode. I'm not sure if this is the right place to describe the issue, but i think we should think about it. Have a look at this example:


 "@id": "http://schema.org/Flight",
"@type": "hydra:Class",
"rdfs:label": "Flight",
"hydra:title": "Flight",
"hydra:description": "An airline flight.",
"hydra:supportedProperty": [
{ /blank_node_start
    "@id": <----------------missing id--------------------------------?
    "@type": "hydra:SupportedProperty",
    "hydra:property": {
        "@id": "#Flight/id", <----------
        "@type": "rdf:Property",
        "rdfs:label": "id",
        "domain": "http://schema.org/Flight",
       "range": "xmls:integer"
    },
"hydra:title": "id",
"hydra:required": false,
"hydra:readable": false,
"hydra:writable": true
},/blank_node_end

so what we have is BlankNode_23 ---> '@type' ---> "hydra:SupportedProperty"
etc, meaning that it would be difficult to check the hydra properties [title,required,readable,writable].

The same is true for supportedOperations and others. I believe that this has to do with Hydra itself.
Below is some js code, in order to remove blank nodes, but it may refer the same nodes twice, i'm not sure. I'm editing the jsonld and then parse it through rdflib.js . You can see the parts that have no '@id' .


hydraObject = JSON.parse(hydraDoc);

hydraObject['hydra:supportedClass'].forEach(function(supClass){
    supClass['hydra:supportedProperty'].forEach(function(obj){
        obj['@id'] = obj['hydra:property']['@id']+'/hydra'
        // console.log(obj['hydra:property']['@id'])
    })
    // console.log(supClass["hydra:supportedOperation"])
    if (Array.isArray(supClass["hydra:supportedOperation"])) {
        supClass["hydra:supportedOperation"].forEach(function(obj){
            obj['@id'] = supClass['@id'] + '/' + obj["hydra:method"]
            // console.log(obj['@id'])
        })
    }
    if (supClass['@id'].includes("Entrypoint")) {
        supClass['hydra:supportedOperation']['@id'] = supClass['@id'] + '/' + supClass['hydra:supportedOperation']['hydra:method']
        console.log(supClass['hydra:supportedProperty'])
        supClass['hydra:supportedProperty'].forEach(function(obj){
            // console.log(obj)
            obj['hydra:property']['hydra:supportedOperation'].forEach(function(propObj){
                propObj['@id'] = obj['@id'] + '/' + propObj['hydra:method']
            })
        })
    }

})
console.log(hydraObject)
hydraDoc = JSON.stringify(hydraObject);

I'm posting this for thoughts rather than a solution

@dunglas
Copy link
Member

dunglas commented Sep 30, 2016

I don't really get why blank nodes are a problem.

Our implementation is inspired of the output of https://github.com/lanthaler/HydraBundle and works well with Hydra console (https://github.com/lanthaler/HydraConsole).

Maybe the Hydra mailing list is a better place to discuss that?

/cc @lanthaler

@lanthaler
Copy link

Yeah. @cr3a7ure, why do you think the blank nodes are problematic?

@Simperfit
Copy link
Contributor

@cr3a7ure any update on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants